CVFolds.cpp File Reference

Go to the source code of this file.

Functions

double trainProblem (const RegressionDataset &training, RegressionDataset const &validation, double regularization)
 
int main ()
 

Function Documentation

◆ main()

int main ( )

What is Cross Validation(CV)? In Cross Validation the dataset is partitioned in several validation data sets. For a given validation dataset the remainder of the dataset

  • every other validation set - forms the training part. During every evaluation of the error function, the problem is solved using the training part and the final error is computed using the validation part. The mean of all validation sets trained this way is the final error of the solution found. This quite complex procedure is used to minimize the bias introduced by the dataset itself and makes overfitting of the solution harder.

Definition at line 63 of file CVFolds.cpp.

References shark::createCVSameSize(), shark::LabeledDataDistribution< InputType, LabelType >::generateDataset(), shark::CVFolds< DatasetTypeT >::size(), shark::CVFolds< DatasetTypeT >::training(), trainProblem(), and shark::CVFolds< DatasetTypeT >::validation().

◆ trainProblem()

double trainProblem ( const RegressionDataset training,
RegressionDataset const &  validation,
double  regularization 
)

In this example, you will learn to create and use partitions for cross validation. This tutorial describes a handmade solution which does not use the Crossvalidation error function which is also provided by shark. We do this, because it gives a better on what Cross Validation does. The Test Problem receives the regularization parameter and a dataset and returns the errror. skip to the main if you are not interested in the problem itself. But here you can also see how to create regularized error functions. so maybe it's still worth taking a look ;)

Definition at line 28 of file CVFolds.cpp.

References shark::ErrorFunction::init(), shark::IRpropPlus::init(), shark::initRandomUniform(), shark::LabeledData< InputT, LabelT >::inputs(), shark::LabeledData< InputT, LabelT >::labels(), shark::ErrorFunction::setRegularizer(), and shark::IRpropPlus::step().

Referenced by main().