public class ModelBag extends java.lang.Object implements RevisionHandler
| Constructor and Description |
|---|
ModelBag(double[][][] models,
double bag_percent,
boolean debug)
Constructor for ModelBag.
|
| Modifier and Type | Method and Description |
|---|---|
void |
backwardEliminate(Instances instances,
int metric)
Find the model whose removal will help the ensemble's performance the
most, and remove it.
|
void |
forwardSelect(boolean withReplacement,
Instances instances,
int metric)
Forward select one model.
|
void |
forwardSelectOrBackwardEliminate(boolean with_replacement,
Instances instances,
int metric)
Find the best action to perform, be it adding a model or removing a
model, and perform it.
|
double[] |
getIndividualPerformance(Instances instances,
int metric)
Gets the individual performances of all the models in the bag.
|
int[] |
getModelWeights()
returns the model weights
|
java.lang.String |
getRevision()
Returns the revision string.
|
void |
shuffle(java.util.Random rand)
Shuffle the models.
|
int[] |
sortInitialize(int num,
boolean greedy,
Instances instances,
int metric)
Sort initialize the bag.
|
void |
weightAll(int weight)
Add "weight" to the number of times each model in the bag was chosen.
|
public ModelBag(double[][][] models,
double bag_percent,
boolean debug)
models - The complete set of models from which to draw our bag. First
index is for the model, second is for the instance. The last
is a prediction distribution for that instance. Models are
represented by this array of predictions for validation data,
since that's all ensemble selection needs to know.bag_percent - The percentage of the set of given models that should be used
in the Model Bag.debug - Whether the ModelBag should print debug information.public void shuffle(java.util.Random rand)
rand - the random number generator to usepublic int[] sortInitialize(int num,
boolean greedy,
Instances instances,
int metric)
throws java.lang.Exception
num - the Maximum number of models to initialize withgreedy - True if we do greedy addition, up to num. Greedy sort
initialization adds models (up to num) in order of best to
worst performance until performance no longer improves.instances - the data set (needed for performance evaluation)metric - metric for which to optimize. See EnsembleMetricHelperjava.lang.Exception - if something goes wrongpublic void weightAll(int weight)
weight - the weight to addpublic void forwardSelect(boolean withReplacement,
Instances instances,
int metric)
throws java.lang.Exception
withReplacement - whether a model can be added more than once.instances - The dataset, for calculating performance.metric - The metric to which we will optimize. See EnsembleMetricHelperjava.lang.Exception - if something goes wrongpublic void backwardEliminate(Instances instances, int metric) throws java.lang.Exception
instances - The data set, for calculating performancemetric - Metric to optimize for. See EnsembleMetricHelper.java.lang.Exception - if something goes wrongpublic void forwardSelectOrBackwardEliminate(boolean with_replacement,
Instances instances,
int metric)
throws java.lang.Exception
with_replacement - whether we can add a model more than onceinstances - The dataset, for determining performance.metric - The metric for which to optimize. See EnsembleMetricHelper.java.lang.Exception - if something goes wrongpublic int[] getModelWeights()
public double[] getIndividualPerformance(Instances instances, int metric) throws java.lang.Exception
instances - The validation data, for which we want performance.metric - The desired metric (see EnsembleMetricHelper).java.lang.Exception - if something goes wrongpublic java.lang.String getRevision()
getRevision in interface RevisionHandler