BDVal API 20110316173314

edu.cornell.med.icb.learning
Interface ClassificationProblem

All Known Implementing Classes:
LibSvmProblem, WekaProblem

public interface ClassificationProblem

Abstracts a classification problem.

Author:
Fabien Campagne Date: Nov 19, 2007 Time: 9:29:19 AM

Method Summary
 int addInstance(int maxNumberOfFeatures)
          Add an instance to this problem.
 ClassificationProblem exclude(int instanceIndex)
          Returns the problem with one record excluded.
 double[] featureValues(int featureIndex, IntSet keepInstanceSet)
          Returns the values of the feature for a subset of instances of this problem.
 ClassificationProblem filter(int instanceIndex)
          Returns the problem with a single instance included.
 ClassificationProblem filter(IntSet keepInstanceSet)
          Returns a subproblem with only instances in the keepInstanceSet.
 double getLabel(int instanceIndex)
          Returns the label of an instance.
 int getSize()
          Return the number of instances in this classification problem.
 void prepareNative()
          Prepare the native representation of this problem.
 ClassificationProblem scaleFeatures(FeatureScaler scaler, IntSet testSetIndices, boolean trainingMode)
           
 ClassificationProblem scaleTestSet(FeatureScaler scaler, int testInstanceIndex)
           
 ClassificationProblem scaleTraining(FeatureScaler scaler)
          Returns a problem where features have been scaled.
 void setFeature(int instanceIndex, int featureIndex, double featureValue)
          Set feature value for an instance.
 void setInstance(int instanceIndex, double label, double[] features)
          Set feature values and label for an instance.
 void setLabel(int instanceIndex, double label)
          Set feature values and label for an instance.
 

Method Detail

getLabel

double getLabel(int instanceIndex)
Returns the label of an instance.

Parameters:
instanceIndex - Instance in the problem.
Returns:
The training label, or zero if not known.

getSize

int getSize()
Return the number of instances in this classification problem.

Returns:
the number of instances in this classification problem.

filter

ClassificationProblem filter(IntSet keepInstanceSet)
Returns a subproblem with only instances in the keepInstanceSet.

Parameters:
keepInstanceSet - Index of the records to include in the reduced problem.
Returns:
Reduced problem.

exclude

ClassificationProblem exclude(int instanceIndex)
Returns the problem with one record excluded.

Parameters:
instanceIndex - Index of the record to exclude.
Returns:
Reduced problem.

filter

ClassificationProblem filter(int instanceIndex)
Returns the problem with a single instance included.

Parameters:
instanceIndex - Index of the record to include in the filtered problem.
Returns:
Reduced problem.

setInstance

void setInstance(int instanceIndex,
                 double label,
                 double[] features)
Set feature values and label for an instance.

Parameters:
instanceIndex - Index of the instance.
label - Label for the instance.
features - Features associated with this instance.

setLabel

void setLabel(int instanceIndex,
              double label)
Set feature values and label for an instance.

Parameters:
instanceIndex - Index of the instance.
label - Label for the instance.

setFeature

void setFeature(int instanceIndex,
                int featureIndex,
                double featureValue)
Set feature value for an instance.

Parameters:
instanceIndex - Index of the instance.
featureIndex - Index of the feature
featureValue - Value of the feature for the specified instance.

addInstance

int addInstance(int maxNumberOfFeatures)
Add an instance to this problem. Allocate storage to store label and features of the instance.

Parameters:
maxNumberOfFeatures - The maximum number of features that this instance can have
Returns:
index of the instance.

prepareNative

void prepareNative()
Prepare the native representation of this problem. Adding instances is not permitted after this method has been called. Feature values and labels can be changed directly however.


scaleTraining

ClassificationProblem scaleTraining(FeatureScaler scaler)
Returns a problem where features have been scaled. This method should be called to prepare a training set. Typically, the scaler may inspect the training set, determine and cache statistics useful to scale the test set.

Parameters:
scaler - The feature scaler engine.
Returns:
A copy of training set with scaled features.

scaleTestSet

ClassificationProblem scaleTestSet(FeatureScaler scaler,
                                   int testInstanceIndex)

featureValues

double[] featureValues(int featureIndex,
                       IntSet keepInstanceSet)
Returns the values of the feature for a subset of instances of this problem.

Parameters:
featureIndex - Index of the feature to collect values for.
keepInstanceSet - Set of instances to collect over.
Returns:

scaleFeatures

ClassificationProblem scaleFeatures(FeatureScaler scaler,
                                    IntSet testSetIndices,
                                    boolean trainingMode)

BDVal API 20110316173314

Copyright © 2007-2011 Institute for Computational Biomedicine, All Rights Reserved.