public final class WeightedEnsembleModel<T extends Output<T>> extends EnsembleModel<T>
Modifier and Type | Field and Description |
---|---|
protected EnsembleCombiner<T> |
combiner |
protected float[] |
weights |
models
ALL_OUTPUTS, BIAS_FEATURE, featureIDMap, generatesProbabilities, name, outputIDInfo, provenance, provenanceOutput
Constructor and Description |
---|
WeightedEnsembleModel(String name,
EnsembleModelProvenance provenance,
ImmutableFeatureMap featureIDMap,
ImmutableOutputInfo<T> outputIDInfo,
List<Model<T>> newModels,
EnsembleCombiner<T> combiner)
Unless you are implementing a
Trainer you should
not use this constructor directly. |
WeightedEnsembleModel(String name,
EnsembleModelProvenance provenance,
ImmutableFeatureMap featureIDMap,
ImmutableOutputInfo<T> outputIDInfo,
List<Model<T>> newModels,
EnsembleCombiner<T> combiner,
float[] weights)
Unless you are implementing a
Trainer you should
not use this constructor directly. |
Modifier and Type | Method and Description |
---|---|
protected EnsembleModel<T> |
copy(String name,
EnsembleModelProvenance newProvenance,
List<Model<T>> newModels)
Copies this ensemble model.
|
static <T extends Output<T>> |
createEnsembleFromExistingModels(String name,
List<Model<T>> models,
EnsembleCombiner<T> combiner)
Creates an ensemble from existing models.
|
static <T extends Output<T>> |
createEnsembleFromExistingModels(String name,
List<Model<T>> models,
EnsembleCombiner<T> combiner,
float[] weights)
Creates an ensemble from existing models.
|
Optional<Excuse<T>> |
getExcuse(Example<T> example)
Generates an excuse for an example.
|
Prediction<T> |
predict(Example<T> example)
Uses the model to predict the output for a single example.
|
copy, getModels, getNumModels, getProvenance, getTopFeatures
copy, generatesProbabilities, getExcuses, getFeatureIDMap, getName, getOutputIDInfo, innerPredict, predict, predict, setName, toString, validate
protected final float[] weights
protected final EnsembleCombiner<T extends Output<T>> combiner
public WeightedEnsembleModel(String name, EnsembleModelProvenance provenance, ImmutableFeatureMap featureIDMap, ImmutableOutputInfo<T> outputIDInfo, List<Model<T>> newModels, EnsembleCombiner<T> combiner)
Trainer
you should
not use this constructor directly. Instead use createEnsembleFromExistingModels(String, List, EnsembleCombiner)
.
Constructs an ensemble model which uses uniform weights.
name
- The model name.provenance
- The model provenance.featureIDMap
- The feature domain.outputIDInfo
- The output domain.newModels
- The list of ensemble members.combiner
- The combination function.public WeightedEnsembleModel(String name, EnsembleModelProvenance provenance, ImmutableFeatureMap featureIDMap, ImmutableOutputInfo<T> outputIDInfo, List<Model<T>> newModels, EnsembleCombiner<T> combiner, float[] weights)
Trainer
you should
not use this constructor directly. Instead use createEnsembleFromExistingModels(String, List, EnsembleCombiner, float[])
.
Constructs an ensemble model which uses uniform weights.
name
- The model name.provenance
- The model provenance.featureIDMap
- The feature domain.outputIDInfo
- The output domain.newModels
- The list of ensemble members.combiner
- The combination function.weights
- The model combination weights.public Prediction<T> predict(Example<T> example)
Model
predict does not mutate the example.
Throws IllegalArgumentException
if the example has no features
or no feature overlap with the model.
public Optional<Excuse<T>> getExcuse(Example<T> example)
Model
This attempts to explain a classification result. Generating an excuse may be quite an expensive operation.
This excuse either contains per class information or an entry with key Model.ALL_OUTPUTS.
The optional is empty if the model does not provide excuses.
getExcuse
in class EnsembleModel<T extends Output<T>>
example
- The input example.protected EnsembleModel<T> copy(String name, EnsembleModelProvenance newProvenance, List<Model<T>> newModels)
EnsembleModel
copy
in class EnsembleModel<T extends Output<T>>
name
- The new name.newProvenance
- The new provenance.newModels
- The new models.public static <T extends Output<T>> WeightedEnsembleModel<T> createEnsembleFromExistingModels(String name, List<Model<T>> models, EnsembleCombiner<T> combiner)
Uses the feature and output domain from the first model as the ensemble model's domains. The individual ensemble members use the domains that they contain.
If the output domains don't cover the same dimensions then it throws IllegalArgumentException
.
T
- The output type.name
- The ensemble name.models
- The ensemble members.combiner
- The combination function.public static <T extends Output<T>> WeightedEnsembleModel<T> createEnsembleFromExistingModels(String name, List<Model<T>> models, EnsembleCombiner<T> combiner, float[] weights)
Uses the feature and output domain from the first model as the ensemble model's domains. The individual ensemble members use the domains that they contain.
If the output domains don't cover the same dimensions then it throws IllegalArgumentException
.
If the weights aren't the same length as the models it throws IllegalArgumentException
.
T
- The output type.name
- The ensemble name.models
- The ensemble members.combiner
- The combination function.weights
- The model combination weights.Copyright © 2015–2021 Oracle and/or its affiliates. All rights reserved.