A common technique to estimate the accuracy of a predictive model is k-fold cross-validation. In k-fold cross-validation, the original sample is randomly partitioned into a number of sub-samples with an approximately equal number of records. Of these sub-samples, a single sub-sample is retained as the validation data for testing the model, and the remaining sub-samples are combined to be used as training data. The cross-validation process is then repeated as many times as there are sub-samples, with each of the sub-samples used exactly once as the validation data (Table 1).
The k evaluation results can then be averaged (or otherwise combined) to produce a single estimation. The advantage of this method is that all observations are used for both training and validation, and each observation is used for validation exactly once.
Functions for modelling and machine learning in e.g., R and Python’s Scikit-learn often contain build-in cross-validation routines. But it is also fairly easy to build such a routine yourself. This tutorial shows how one can easily build a k-fold cross-validation routine in GRASS GIS, e.g., to evaluate the predictive performance of two interpolation techniques, the inverse Distance Weighting and bilinear spline interpolation.
GRASS GIS offers some useful but basic plotting options for raster data. However, for plotting of data in attribute tables and for more advanced graphs, we need to use other software tools. In this tutorial I explore some of the possibilities offered by Pandas plot() and how we can further tune plots using matplotlib / pyplot library.
Did you ever add a legend to your categorical raster map in GRASS GIS that displayed many more categories than your map actually has? It can happen if that map was ‘cut out’ from a larger region using r.mapcalc. For example, if I have a vegetation map of eastern Africa, and I need one for Rwanda only. I would do something like: Continue reading “GRASS GIS categorical maps and legends”→
In a recent post Anita Graser (aka underdark) showed how to create illuminated or Tanaka contours in QGIS using various functions available in the toolbox and some custom functions.
Here I want to explore a slightly different way to achieve the same, using GRASS GIS to compute the azimuth, brightness and line width. I’ll use the command line, but you can do the same using the menu in GRASS, or the corresponding GRASS functions in the QGIS processing toolbox.
In R you can use system calls or the spgrass6 package to run GRASS GIS functions. To do this, you need to run R from within GRASS GIS. This is as simple as starting GRASS GIS and subsequently starting R from the command line. See the GRASS-wiki for a more detailed background.
The issue at hand
One of the user-cases is when you want to (1) run a GRASS function on e.g., a raster layer and (2) capture the console output in a R data frame. For example, you can run the following in R:
I just came across this blog with (by the time of writing) sixty two-minutes video tutorials on how to do things in R. Especially nice for those who like to learn by watching and listening. But do pay attention while watching because one way the videos are kept short is really fast talking…