SplitSetValidationTModel, TInput Class |
Namespace: Accord.MachineLearning.Performance
public class SplitSetValidation<TModel, TInput> : SplitSetValidation<TModel, TInput, int> where TModel : class, Object, IClassifier<TInput, int>
The SplitSetValidationTModel, TInput type exposes the following members.
Name | Description | |
---|---|---|
SplitSetValidationTModel, TInput |
Initializes a new instance of the SplitSetValidationTModel, TInput class.
|
Name | Description | |
---|---|---|
DefaultValue |
Gets or sets a value to be used as the Loss in case the model throws
an exception during learning. Default is null (exceptions will not be ignored).
(Inherited from BaseSplitSetValidationTResult, TModel, TLearner, TInput, TOutput.) | |
Fit |
Gets or sets a LearnNewModelTLearner, TInput, TOutput, TModel function that can be used to create
new machine learning models using the current
learning algorithm.
(Inherited from BaseSplitSetValidationTResult, TModel, TLearner, TInput, TOutput.) | |
Indices |
Gets the group labels assigned to each of the data samples.
(Inherited from SplitSetValidationTModel, TInput, TOutput.) | |
IndicesTrainingSet |
Gets the indices of elements in the training set.
(Inherited from SplitSetValidationTModel, TInput, TOutput.) | |
IndicesValidationSet |
Gets the indices of elements in the validation set.
(Inherited from SplitSetValidationTModel, TInput, TOutput.) | |
Learner |
Gets or sets a CreateLearnerFromSubsetTLearner, TInput, TOutput function
that can be used to create a TModel from a subset of the learning dataset.
(Inherited from BaseSplitSetValidationTResult, TModel, TLearner, TInput, TOutput.) | |
Loss |
Gets or sets a ComputeLossTOutput, TInfo function that can
be used to measure how far the actual model predictions were from the expected ground-truth.
(Inherited from BaseSplitSetValidationTResult, TModel, TLearner, TInput, TOutput.) | |
ParallelOptions |
Gets or sets the parallelization options for this algorithm.
(Inherited from ParallelLearningBase.) | |
Stratify |
Gets or sets a value indicating whether the prevalence of an output
label should be balanced between training and testing sets. Default is false.
| |
Token |
Gets or sets a cancellation token that can be used
to cancel the algorithm while it is running.
(Inherited from ParallelLearningBase.) | |
TrainingSetProportion |
Gets or sets the proportion of samples that should be
reserved in the training set. Default is 80%.
(Inherited from SplitSetValidationTModel, TInput, TOutput.) | |
ValidationSetProportion |
Gets or sets the proportion of samples that should be
reserved in the validation set. Default is 20%.
(Inherited from SplitSetValidationTModel, TInput, TOutput.) |
Name | Description | |
---|---|---|
CreateValidationSplits |
Creates a list of the sample indices that should serve as the validation set.
(Overrides SplitSetValidationTModel, TInput, TOutputCreateValidationSplits(TInput, TOutput).) | |
Equals | Determines whether the specified object is equal to the current object. (Inherited from Object.) | |
Finalize | Allows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection. (Inherited from Object.) | |
GetHashCode | Serves as the default hash function. (Inherited from Object.) | |
GetType | Gets the Type of the current instance. (Inherited from Object.) | |
Learn |
Learns a model that can map the given inputs to the given outputs.
(Inherited from SplitSetValidationTModel, TInput, TOutput.) | |
LearnSubset |
Learns and evaluates a model in a single subset of the data.
(Inherited from BaseSplitSetValidationTResult, TModel, TLearner, TInput, TOutput.) | |
MemberwiseClone | Creates a shallow copy of the current Object. (Inherited from Object.) | |
ToString | Returns a string that represents the current object. (Inherited from Object.) |
Name | Description | |
---|---|---|
HasMethod |
Checks whether an object implements a method with the given name.
(Defined by ExtensionMethods.) | |
IsEqual |
Compares two objects for equality, performing an elementwise
comparison if the elements are vectors or matrices.
(Defined by Matrix.) | |
To(Type) | Overloaded.
Converts an object into another type, irrespective of whether
the conversion can be done at compile time or not. This can be
used to convert generic types to numeric types during runtime.
(Defined by ExtensionMethods.) | |
ToT | Overloaded.
Converts an object into another type, irrespective of whether
the conversion can be done at compile time or not. This can be
used to convert generic types to numeric types during runtime.
(Defined by ExtensionMethods.) |
// Ensure results are reproducible Accord.Math.Random.Generator.Seed = 0; // This is a sample code on how to use Train-Val validation (split-set) // to assess the performance of Support Vector Machines. // Consider the example binary data. We will be trying to learn a XOR // problem and see how well does SVMs perform on this data. double[][] data = { new double[] { -1, -1 }, new double[] { 1, -1 }, new double[] { -1, 1 }, new double[] { 1, 1 }, new double[] { -1, -1 }, new double[] { 1, -1 }, new double[] { -1, 1 }, new double[] { 1, 1 }, new double[] { -1, -1 }, new double[] { 1, -1 }, new double[] { -1, 1 }, new double[] { 1, 1 }, new double[] { -1, -1 }, new double[] { 1, -1 }, new double[] { -1, 1 }, new double[] { 1, 1 }, }; int[] xor = // result of xor for the sample input data { -1, 1, 1, -1, -1, 1, 1, -1, -1, 1, 1, -1, -1, 1, 1, -1, }; // Create a new Cross-validation algorithm passing the data set size and the number of folds var splitset = new SplitSetValidation<SupportVectorMachine<Linear, double[]>, double[]>() { Learner = (s) => new SequentialMinimalOptimization<Linear, double[]>() { Complexity = 1000 }, Loss = (expected, actual, p) => new ZeroOneLoss(expected).Loss(actual), Stratify = false, }; splitset.ParallelOptions.MaxDegreeOfParallelism = 1; // Compute the cross-validation var result = splitset.Learn(data, xor); // Finally, access the measured performance. double trainingErrors = result.Training.Value; // should be 0.53846153846153844 (+/- var. 0) double validationErrors = result.Validation.Value; // should be 0.33333333333333331 (+/- var. 0)