PLASTIC#
- class capymoa.classifier.PLASTIC[source]#
Bases:
MOAClassifierPLASTIC classifier.
PLASTIC [1] is an incremental decision tree that restructures the otherwise pruned subtree. PLASTIC improves upon Extremely Fast Decision Trees (EFDT) by not only revisiting previously splits but also trying to maintain as much as possible of the structure once a split is redone. This process is possible because of the decision tree plasticity: one can alter a tree’s structure without affecting its predictions.
>>> from capymoa.classifier import PLASTIC >>> from capymoa.datasets import ElectricityTiny >>> from capymoa.evaluation import prequential_evaluation >>> >>> stream = ElectricityTiny() >>> classifier = PLASTIC(stream.get_schema()) >>> results = prequential_evaluation(stream, classifier, max_instances=1000) >>> print(f"{results['cumulative'].accuracy():.1f}") 84.4
- __init__(
- schema: Schema,
- grace_period: int = 200,
- reevaluation_period: int = 200,
- nominal_estimator: str = 'NominalAttributeClassObserver',
- split_criterion: str | SplitCriterion = 'InfoGainSplitCriterion',
- split_confidence: float = 1e-07,
- tie_threshold: float = 0.05,
- tie_threshold_reevaluation: float = 0.05,
- rel_min_delta_g: float = 0.5,
- binary_splits: bool = False,
- leaf_prediction: Literal['MC', 'NB', 'NBA'] = 'NBA',
- max_depth: int = 20,
- max_branch_length: int = 5,
Construct PLASTIC classifier.
- Parameters:
grace_period – The number of instances a leaf should observe between split attempts.
reevaluation_period – The number of instances an internal node should observe between re-evaluation attempts.
nominal_estimator – Nominal estimator to use.
split_criterion – Split criterion to use.
split_confidence – The allowable error in split decision when using fixed confidence. Values closer to 0 will take longer to decide.
tie_threshold – Threshold below which a split will be forced to break ties.
tie_threshold_reevaluation – Threshold below which a split will be forced to break ties during reevaluation.
rel_min_delta_g – Relative minimum information gain to split a tie during reevaluation.
binary_splits – Only allow binary splits.
leaf_prediction –
Leaf prediction to use.
MC: Majority classNB: Naive BayesNBA: Naive Bayes Adaptive
max_depth – Maximum allowed depth of tree.
max_branch_length – Maximum allowed length of branches during restructuring.
- predict(instance: Instance) int | None[source]#
Predict the label of an instance.
The base implementation calls
predict_proba()and returns the label with the highest probability.- Parameters:
instance – The instance to predict the label for.
- Returns:
The predicted label or
Noneif the classifier is unable to make a prediction.
- predict_proba(
- instance,
Return probability estimates for each label.
- Parameters:
instance – The instance to estimate the probabilities for.
- Returns:
An array of probabilities for each label or
Noneif the classifier is unable to make a prediction.
- train(instance)[source]#
Train the classifier with a labeled instance.
- Parameters:
instance – The labeled instance to train the classifier with.
- random_seed: int#
The random seed for reproducibility.
When implementing a classifier ensure random number generators are seeded.