dispel.stats.learning module#
Inter-session Learning analysis.
A module where functions are provided to compute and extract learning parameters from measure collections containing processed measures. The module provides class and functions to compute and extract parameters from fitted model by curve fit and compute relevant learning related measures.
- class dispel.stats.learning.DelayParameters[source]#
Bases:
object
Class ensemble of delay parameters.
- __init__(mean, median, max)#
- class dispel.stats.learning.LearningCurve[source]#
Bases:
object
Class ensemble of learning curve parameters.
- classmethod fit(x, y)[source]#
Fit learning curve using
scipy.optimize.curve_fit()
.See
dispel.stats.learning.LearningCurve.compute_learning()
.- Parameters:
- Returns:
The fitted learning curve.
- Return type:
- get_warm_up(data)[source]#
Compute the warm-up argmax for measure values and fitted parameters.
The
warm_up
here is actually the minimum number of trials the user has to perform in order to reach 90% of the optimal performance (asymptote value) given by the model.- Parameters:
data (Series | ndarray) – A numpy array series containing ordered measure values.
- Returns:
The argmax of the first occurrence of the measure values that reaches 90% of the optimal performance given by the model.
- Return type:
- Raises:
TypeError – If the given data is not a pandas series nor a numpy array.
- class dispel.stats.learning.LearningModel[source]#
Bases:
object
Class ensemble of learning model.
- __init__(curve, new_data, r2_score, nb_outliers=0)#
- Parameters:
curve (LearningCurve) –
new_data (Series) –
r2_score (float | None) –
nb_outliers (int | None) –
- Return type:
None
- curve: LearningCurve#
The fitted learning curve.
- class dispel.stats.learning.LearningParameters[source]#
Bases:
object
Class ensemble of learning parameters.
- __init__(subject_id, measure_id, model, delay_parameters)#
- Parameters:
subject_id (str) –
measure_id (str) –
model (LearningModel) –
delay_parameters (DelayParameters) –
- Return type:
None
- delay_parameters: DelayParameters#
The delay parameters in days
- model: LearningModel#
The learning model
- class dispel.stats.learning.LearningResult[source]#
Bases:
object
The learning results for one measure and one or multiple subjects.
- append(learning_parameters)[source]#
Append new learning results for one subject to learning results.
- Parameters:
learning_parameters (LearningParameters) – The learning parameters for the measure and subject in question.
- Raises:
ValueError – If the learning parameters are for a different measure than the one concerning the learning result.
- classmethod from_parameters(learning_parameters)[source]#
Initialize learning result from parameters.
- Parameters:
learning_parameters (LearningParameters) – The learning parameters for the measure and subject in question.
- Returns:
The learning result regrouping the given information.
- Return type:
- get_new_data(subject_id)[source]#
Get the new data points without outliers.
- Parameters:
subject_id (str) – The identifier of the subject for which the new data is to be retrieved.
- Returns:
A pandas series containing the new data points for the measure in question (without outliers).
- Return type:
- Raises:
ValueError – If the subject identifier is not found in the learning analysis results.
- get_parameters(subject_id=None)[source]#
Get learning results for one or all subjects.
- Parameters:
subject_id (str | None) – The subject identifier for which the learning is to be retrieved. If
None
is provided all learning results will be given.- Returns:
If a valid subject id is given, the output is a pandas series summarizing learning results. If
None
is given the output will be a pandas data frame summarizing all learning results.- Return type:
Union[pandas.Series, pandas.DataFrame]
- Raises:
ValueError – If the subject identifier is not found in the learning analysis results.
- dispel.stats.learning.compute_delay(data)[source]#
Extract mean, median and maximum delay between consecutive sessions.
- Parameters:
data (Series) – A pandas series containing timestamps.
- Returns:
A
dispel.stats.learning.DelayParameters
with the values of the mean, median and maximum delay between consecutive trials for a given measure and subject in days.- Return type:
- dispel.stats.learning.compute_learning_model(data, tolerance=0.99, reset_trials=True)[source]#
Compute the learning model.
- Parameters:
data (Series) – A pandas series composed of measure values for only one measure and only one user and trials numbers as index.
tolerance (float) – The tolerance threshold above which the data points are to be considered outliers and therefore rejected. Should be between
0
and1
.reset_trials (bool) –
True
if the trial numbers are to be reset for the new data (without outliers).False
otherwise.
- Returns:
The output contains the following information:
The fitted learning model.
The delay parameters.
- Return type:
Tuple[LearningModel, DelayParameters]
- Raises:
ValueError – If the threshold tolerance is outside the legal bounds i.e. [0, 1].
- dispel.stats.learning.extract_learning_for_all_subjects(measure_collection, measure_id, tolerance=0.99, reset_trials=True)[source]#
Compute learning parameters for all subjects in a measure collection.
- Parameters:
measure_collection (MeasureCollection) – A measure collection containing any measures and any subjects.
measure_id (str) – The measure id on which the learning parameters are to be computed.
tolerance (float) – The tolerance threshold above which the data points are to be considered outliers and therefore rejected. Should be between
0
and1
.reset_trials (bool) –
True
if the trial numbers are to be reset for the new data (without outliers).False
otherwise.
- Returns:
The learning result for all subjects of the measure in question. See:
dispel.stats.learning.LearningResult
.- Return type:
- dispel.stats.learning.extract_learning_for_one_subject(measure_collection, subject_id, measure_id, tolerance=0.99, reset_trials=True)[source]#
Compute learning for a unique subject and a unique measure.
- Parameters:
measure_collection (MeasureCollection) – A measure collection containing any measures and any subjects.
subject_id (str) – The identifier of the subject for which the delay is to be computed.
measure_id (str) – The identifier of the measure for which the delay is to be computed.
tolerance (float) – The tolerance threshold above which the data points are to be considered outliers and therefore rejected. Should be between
0
and1
.reset_trials (bool) –
True
if the trial numbers are to be reset for the new data (without outliers).False
otherwise.
- Returns:
The learning result for one subject of the measure in question. See:
dispel.stats.learning.LearningResult
.- Return type: