truelearn.learning
.PersistentClassifier#
- class truelearn.learning.PersistentClassifier(*, engage_with_last: bool = False)[source]#
Bases:
BaseClassifier
A classifier that makes predictions based on whether the learner has engaged with the last learnable unit.
Examples
>>> from truelearn.learning import PersistentClassifier >>> from truelearn.models import EventModel >>> persistent = PersistentClassifier() >>> persistent PersistentClassifier() >>> # prepare an event model with empty knowledge >>> events = [EventModel(), EventModel(), EventModel()] >>> engage_stats = [False, True, False] >>> for event, engage_stats in zip(events, engage_stats): ... persistent = persistent.fit(event, engage_stats) ... print(persistent.predict(event)) ... False True False
Methods
__init__
(*[, engage_with_last])Init PersistentClassifier object.
fit
(x, y)Train the model.
get_params
([deep])Get parameters for this Classifier.
predict
(x)Predict whether the learner will engage in the learning event.
Predict the probability that the learner will engage in the learning event.
set_params
(**args)Set the parameters of this Classifier.
- __init__(*, engage_with_last: bool = False) None [source]#
Init PersistentClassifier object.
- Parameters:
engage_with_last – whether the learner engages with the last learnable unit.
- Raises:
TrueLearnTypeError – Types of parameters do not satisfy their constraints.
TrueLearnValueError – Values of parameters do not satisfy their constraints.
- fit(x: EventModel, y: bool) Self [source]#
Train the model.
- Parameters:
x – A representation of a learning event.
y – A bool indicating whether the learner engages in the learning event.
- Returns:
The updated classifier object.
- get_params(deep: bool = True) Dict[str, Any] [source]#
Get parameters for this Classifier.
- Parameters:
deep – If True, will return the parameters for this Classifier and contained sub-objects that inherit BaseClassifier class.
- Returns:
A dict mapping variable names to the corresponding objects.
- predict(x: EventModel) bool [source]#
Predict whether the learner will engage in the learning event.
- Parameters:
x – A representation of a learning event.
- Returns:
A bool indicating whether the learner will engage in the learning event.
- predict_proba(x: EventModel) float [source]#
Predict the probability that the learner will engage in the learning event.
- Parameters:
x – A representation of a learning event.
- Returns:
A float indicating the probability that the learner will engage in the learning event.
- set_params(**args) Self [source]#
Set the parameters of this Classifier.
A value can be reset only if the given parameter has the same type as the original value.
- Parameters:
**args – Keyword arguments. The key should match the parameter names of the classifier. The arguments should have the correct type.
- Returns:
The updated classifier.
- Raises:
TrueLearnTypeError – Types of parameters do not satisfy their constraints.
TrueLearnValueError – Values of parameters do not satisfy their constraints.
InvalidArgumentError – If the given argument name is not in the class.