public class EnsembleSelectionLibraryModel extends EnsembleLibraryModel implements java.io.Serializable
Modifier and Type | Field and Description |
---|---|
static java.lang.String |
FILE_EXTENSION
The default file extension for ensemble library models
|
boolean |
m_Debug
The debug flag as propagated from the main EnsembleSelection class.
|
Constructor and Description |
---|
EnsembleSelectionLibraryModel()
Default Constructor
|
EnsembleSelectionLibraryModel(weka.classifiers.Classifier classifier)
Basic Constructor
|
EnsembleSelectionLibraryModel(weka.classifiers.Classifier classifier,
int seed,
java.lang.String checksum,
double validationRatio,
int folds)
Constructor for LibaryModel
|
Modifier and Type | Method and Description |
---|---|
void |
createModel(weka.core.Instances[] data,
weka.core.Instances[] hillclimbData,
java.lang.String dataDirectoryName,
int algorithm)
Creates the model.
|
double[] |
getAveragePrediction(weka.core.Instance instance)
Returns the average of the prediction of the models across all folds.
|
java.lang.String |
getChecksum()
get the checksum
|
static java.lang.String |
getFileName(java.lang.String stringRepresentation)
The purpose of this method is to get an appropriate file name for a model
based on its string representation of a model.
|
double[] |
getFoldPrediction(weka.core.Instance instance,
int fold)
Returns prediction of the classifier for the specified fold.
|
int |
getFolds()
get the number of folds
|
weka.classifiers.Classifier[] |
getModels()
Returs the array of classifiers
|
java.lang.String |
getRevision()
Returns the revision string.
|
int |
getSeed()
Get the seed
|
static java.lang.String |
getStringChecksum(java.lang.String string)
Gets a checksum for the string defining this classifier.
|
double[][] |
getValidationPredictions()
getter for validation predictions
|
double |
getValidationRatio()
get validationRatio
|
static EnsembleSelectionLibraryModel |
loadModel(java.lang.String modelFilePath)
loads the specified model
|
void |
rehydrateModel(java.lang.String workingDirectory)
The purpose of this method is to "rehydrate" the classifier object fot
this library model from the filesystem.
|
void |
releaseModel()
Releases the model from memory.
|
static void |
saveModel(java.lang.String directory,
EnsembleSelectionLibraryModel model)
Saves the given model to the specified file.
|
void |
setChecksum(java.lang.String instancesChecksum)
set the checksum
|
void |
setDebug(boolean debug)
This is used to propagate the m_Debug flag of the EnsembleSelection
classifier to this class.
|
void |
setFileName(java.lang.String fileName)
Sets the .elm file name for this library model
|
void |
setFolds(int folds)
Set the number of folds for cross validation.
|
void |
setSeed(int seed)
Set the seed
|
void |
setValidationPredictions(double[][] predictions)
setter for validation predictions
|
void |
setValidationRatio(double validationRatio)
Sets the validation set ratio (only meaningful if folds == 1)
|
void |
train(weka.core.Instances trainData,
int fold)
Train the classifier for the specified fold on the given data
|
getClassifier, getDescriptionText, getErrorText, getModelClass, getOptions, getOptionsWereValid, getStringRepresentation, setDescriptionText, setErrorText, setOptionsWereValid, testOptions, toString, updateDescriptionText
public static final java.lang.String FILE_EXTENSION
public transient boolean m_Debug
public EnsembleSelectionLibraryModel()
public EnsembleSelectionLibraryModel(weka.classifiers.Classifier classifier, int seed, java.lang.String checksum, double validationRatio, int folds)
classifier
- the classifier to useseed
- the random seed valuechecksum
- the checksumvalidationRatio
- the ration to usefolds
- the number of folds to usepublic EnsembleSelectionLibraryModel(weka.classifiers.Classifier classifier)
classifier
- the classifier to usepublic void setDebug(boolean debug)
debug
- if true additional information is outputpublic double[] getAveragePrediction(weka.core.Instance instance) throws java.lang.Exception
instance
- the instance to get predictions forjava.lang.Exception
- if something goes wrongpublic double[] getFoldPrediction(weka.core.Instance instance, int fold) throws java.lang.Exception
instance
- instance for which to make a prediction.fold
- fold number of the classifier to use.java.lang.Exception
- if prediction failspublic void createModel(weka.core.Instances[] data, weka.core.Instances[] hillclimbData, java.lang.String dataDirectoryName, int algorithm) throws java.lang.Exception
data
- the data to work withhillclimbData
- the data for hillclimbingdataDirectoryName
- the directory to usealgorithm
- the type of algorithmjava.lang.Exception
- if something goeds wrongpublic void rehydrateModel(java.lang.String workingDirectory)
workingDirectory
- the working directory to usepublic void releaseModel()
public void train(weka.core.Instances trainData, int fold) throws java.lang.Exception
trainData
- the data to train withfold
- the fold numberjava.lang.Exception
- if something goes wrong, e.g., out of memorypublic void setSeed(int seed)
seed
- the seed valuepublic int getSeed()
public void setValidationRatio(double validationRatio)
validationRatio
- the new rationpublic double getValidationRatio()
public void setFolds(int folds)
folds
- the number of folds to usepublic int getFolds()
public void setChecksum(java.lang.String instancesChecksum)
instancesChecksum
- the new checksumpublic java.lang.String getChecksum()
public weka.classifiers.Classifier[] getModels()
public void setFileName(java.lang.String fileName)
fileName
- the new filenamepublic static java.lang.String getStringChecksum(java.lang.String string)
string
- the classifier definitionpublic static java.lang.String getFileName(java.lang.String stringRepresentation)
stringRepresentation
- string representation of modelpublic static void saveModel(java.lang.String directory, EnsembleSelectionLibraryModel model)
directory
- the directory to save the model tomodel
- the model to savepublic static EnsembleSelectionLibraryModel loadModel(java.lang.String modelFilePath)
modelFilePath
- the path of the modelpublic double[][] getValidationPredictions()
public void setValidationPredictions(double[][] predictions)
predictions
- the new validation predictionspublic java.lang.String getRevision()
getRevision
in interface weka.core.RevisionHandler
getRevision
in class EnsembleLibraryModel