truelearn.models
.KnowledgeComponent#
- class truelearn.models.KnowledgeComponent(*args, **kwds)[source]#
Bases:
BaseKnowledgeComponent
A concrete class that implements BaseKnowledgeComponent.
Examples
>>> from truelearn.models import KnowledgeComponent >>> kc = KnowledgeComponent(mean=0.0, variance=1.0) >>> kc KnowledgeComponent(mean=0.0, variance=1.0, timestamp=None, title=None, description=None, url=None) >>> KnowledgeComponent(mean=0.0, variance=1.0, title="Hello World", description="First Program") KnowledgeComponent(mean=0.0, variance=1.0, timestamp=None, title='Hello World', description='First Program', url=None) >>> # update the mean and variance >>> kc.update(mean=1.0, variance=2.0) >>> kc KnowledgeComponent(mean=1.0, variance=2.0, timestamp=None, title=None, description=None, url=None) >>> # clone with new mean and variance >>> kc.clone(mean=0.0, variance=1.0) KnowledgeComponent(mean=0.0, variance=1.0, timestamp=None, title=None, description=None, url=None)
Attributes
- timestamp#
The POSIX timestamp of when the knowledge component was last updated.
- Type:
Optional[float]
Methods
__init__
(*, mean, variance[, timestamp, ...])Init the KnowledgeComponent object.
clone
(*, mean, variance[, timestamp])Generate a copy of the current knowledge component with given mean, variance and timestamp.
Export the knowledge component into a dictionary.
update
(*[, mean, variance, timestamp])Update the mean, variance, and timestamp of the current knowledge component.
- __init__(*, mean: float, variance: float, timestamp: Optional[float] = None, title: Optional[str] = None, description: Optional[str] = None, url: Optional[str] = None) None [source]#
Init the KnowledgeComponent object.
- Parameters:
mean – A float indicating the mean of the knowledge component.
variance – A float indicating the variance of the knowledge component.
timestamp – A float indicating the POSIX timestamp of when the knowledge component was last updated.
title – An optional string storing the title of the knowledge component.
description – An optional string that describes the knowledge component.
url – An optional string storing the url of the knowledge component.
- Returns:
None.
- clone(*, mean: float, variance: float, timestamp: Optional[float] = None) Self [source]#
Generate a copy of the current knowledge component with given mean, variance and timestamp.
- Parameters:
* – Use to reject positional arguments.
mean – The new mean of the KnowledgeComponent.
variance – The new variance of the KnowledgeComponent.
timestamp – An optional new POSIX timestamp of the KnowledgeComponent. If None is given, the timestamp of the cloned knowledge component is assigned to None.
- Returns:
A cloned knowledge component with given mean, variance and timestamp.
- export_as_dict() Dict[str, Any] [source]#
Export the knowledge component into a dictionary.
- Returns:
A dictionary mapping the name of the variables to their value.
- update(*, mean: Optional[float] = None, variance: Optional[float] = None, timestamp: Optional[float] = None) None [source]#
Update the mean, variance, and timestamp of the current knowledge component.
If the given parameters are None, the corresponding attributes of the current knowledge component will not be updated.
- Parameters:
* – Use to reject positional arguments.
mean – The new mean of the knowledge component.
variance – The new variance of the knowledge component.
timestamp – The new POSIX timestamp that indicates the update time of the knowledge component.
- Returns:
None.