public class CrossValidation extends Object implements Serializable, Cloneable

is the loss incurred when the prediction is
for the actual y. The inner summation is
over the examples in the test sample held out for each fold.
If the predictive model is an instance of a decision tree, cross-validation
is performed on each optimal sub-tree determined by cost-complexity
pruning. Let the symbol
denote the full training data set,
the
sub-sample. Then
use
to indicate the set of predictions
corresponding to the kth optimal sub-tree fitted on the
training sample
. To select
one sub-tree from among the configurations, two criteria are the minimum
![]()
![]()
![]()

| Constructor and Description |
|---|
CrossValidation(PredictiveModel pm)
Creates a
CrossValidation object. |
| Modifier and Type | Method and Description |
|---|---|
void |
crossValidate()
Performs V-Fold cross-validation.
|
double |
getCrossValidatedError()
Returns the cross-validated error.
|
int |
getNumberOfSampleFolds()
Returns the number of folds set for the cross validation selection.
|
int |
getNumberOfThreads()
Returns the maximum number of
java.lang.Thread instances
that may be used for parallel processing. |
double[] |
getRiskStandardErrors()
Returns the estimated standard errors for the risk values.
|
double[] |
getRiskValues()
Returns the vector of risk values.
|
void |
setNumberOfSampleFolds(int nFolds)
Sets the number of folds to use in cross validation selection.
|
void |
setNumberOfThreads(int numberOfThreads)
Sets the maximum number of
java.lang.Thread instances that
may be used for parallel processing. |
void |
setRandomObject(Random r)
Sets the random object to be used in the permutation of observation data.
|
public CrossValidation(PredictiveModel pm) throws PredictiveModel.PredictiveModelException
CrossValidation object.pm - an object of a class that extends PredictiveModel.PredictiveModel.PredictiveModelExceptionpublic void crossValidate()
throws PredictiveModel.PredictiveModelException,
NoSuchMethodException,
InstantiationException,
IllegalAccessException,
InvocationTargetException
PredictiveModel.PredictiveModelException - an exception has occurred in the common
PredictiveModel programming interface methods or an
exception class that has extended the
PredictiveModelException class.NoSuchMethodException - the PredictiveModel subclass is missing a
constructor with the expected signature (see
com.imsl.datamining.PredictiveModel.PredictiveModel).InstantiationException - the object has failed to instantiate. This
maybe have occurred if your PredictiveModel subclass is not concrete.IllegalAccessException - the currently executing method does not
have access to the definition of the specified class, field, method or
constructor.InvocationTargetException - an exception has occurred within one of
the method. Use java.lang.Throwable.getCause() to extract the initiating
exception.public double getCrossValidatedError()
throws PredictiveModel.StateChangeException
PredictiveModel object. If the response variable is
quantitative/continuous, the error is the mean squared prediction error,
also weighted if weights are set in the PredictiveModel object.double equal to the cross-validated prediction
error.PredictiveModel.StateChangeException - an input
parameter in the PredictiveModel changed that might affect
the model estimates or predictions.public int getNumberOfSampleFolds()
int that indicates the number of folds.public int getNumberOfThreads()
java.lang.Thread instances
that may be used for parallel processing.int containing the maximum number of
java.lang.Thread instances that may be used for parallel
processing.
The actual number of threads used in parallel processing will be the
lesser of numberOfThreads and nFolds, the
number of folds set for cross-validation. This assessment is made to
optimize use of resources.
public double[] getRiskStandardErrors()
In most cases the length is 1. For
DecisionTree,
CrossValidation returns an array of length >= 1.
double array containing the estimated standard
errors for the risk values.public double[] getRiskValues()
In most cases the length is 1. For
DecisionTree,
CrossValidation returns an array of length >= 1.
double array containing the estimated risk values.public void setNumberOfSampleFolds(int nFolds)
nFolds - an int that specifies the number of folds to
use in cross validation selection.
nFolds must be between 1 and the number of observations
(xy.length), inclusive. If nFolds = 1 the full
data set is used once to generate the PredictiveModel. In other
words, no cross-validation is performed. If 1 <
xy.length/nFolds
3,
leave-one-out cross validation is performed.
Default: nFolds = 10.
public void setNumberOfThreads(int numberOfThreads)
java.lang.Thread instances that
may be used for parallel processing.numberOfThreads - an int specifying the maximum number
of java.lang.Thread instances that may be used for parallel
processing.
The actual number of threads used in parallel processing will be the
lesser of numberOfThreads and nFolds, the
number of folds set for cross-validation. This assessment is made to
optimize use of resources.
Default: numberOfThreads = 1.
Copyright © 1970-2015 Rogue Wave Software
Built March 24 2015.