Monotonicity Analysis
- mlbugdetection.monotonic.check_monotonicity_multiple_samples(model, samples, feature, start, stop, step=1)[source]
Monotonicity Analysis for multiple examples
- Parameters
model (sklearn model or str) – Model that will be used to make predictions. Could be a model object or a path to a model file.
samples (pandas.DataFrame) – Pandas DataFrame containing two or more rows that will be used as base point.
feature (str) – Name of the feature being analysed.
start (int) – The starting value of the feature’s interval.
stop (int) – The end value of the feature’s interval.
step (float, default=1) – Size of the step between ranges “start” and “stop”. Ex: step = 0.1 between ranges 0 and 1 will result in [0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9]
- Returns
AnalysisReport object with following attributes – For more information: >>> from mlbugdetection.analysis_report import AnalysisReport >>> help(AnalysisReport)
model_name (str) – Name of the model being analysed.
analysed_feature (str) – Name of the feature being analysed.
feature_range (tuple) – Range of values of the feature being analysed: (start, stop).
metrics (dictionary) – Dictionary with all the calculated metrics, such as:
- ’monotonic’bool
If the list of values is monotonic.
- ’monotonic_mse’: float
MSE between the list of values and it`s closest monotonic aproximation.
- ’monotonic_means_std’: float
Standard deviation of the means of the predictions probabilities.
graphs (List) – List of all the figures created.
- mlbugdetection.monotonic.check_monotonicity_single_sample(model, sample, feature, start, stop, step=1)[source]
Monotonicity Analysis for a single example
- Parameters
model (sklearn model or str) – Model that will be used to make predictions. Could be a model object or a path to a model file.
sample (pandas.DataFrame) – Pandas DataFrame containing one row that will be used as base point.
feature (str) – Name of the feature being analysed.
start (int) – The starting value of the feature’s interval.
stop (int) – The end value of the feature’s interval.
step (float, default=1) – Size of the step between ranges “start” and “stop”. Ex: step = 0.1 between ranges 0 and 1 will result in [0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9]
- Returns
AnalysisReport object with following attributes – For more information: >>> from mlbugdetection.analysis_report import AnalysisReport >>> help(AnalysisReport)
model_name (str) – Name of the model being analysed.
analysed_feature (str) – Name of the feature being analysed.
feature_range (tuple) – Range of values of the feature being analysed: (start, stop).
metrics (dictionary) – Dictionary with all the calculated metrics, such as:
- ’monotonic’bool
If the list of values is monotonic.
- ’monotonic_mse’: float
MSE between the list of values and it`s closest monotonic aproximation.
graphs (List) – List of all the figures created.
- mlbugdetection.monotonic.monotonicity_mse(predictions)[source]
Monotonicity Mean Square Error
Calculates the MSE between a list of prediction brobabilities and the closest monotonic version of this list.
- Parameters
predictions (List) – List of prediction probabilities calculated on the check_monotonicity function.
- Returns
desc | asc (List) – List of closest monotonic version of “predictions”.
mse_desc | mse_as (int) – MSE between “predictions” and desc/asc.