Sanity Check Analysis

mlbugdetection.sanity.check_type_input_model(model)[source]

Check the type of the input model and returns the model object

mlbugdetection.sanity.sanity_check(model, samples, target)[source]
Sanity Test

Analyzes the sanity of a model with samples and return a bool that represents if the tests passed or not.

Parameters
  • model (sklearn model or str) – The model to be used for prediction. Could be a model object or a path to a model file.

  • samples (pandas DataFrame) – The samples (or sample) to be used for prediction, which the model need to predict correctly.

  • target (str) – The name of the column containing the target variable.

Return type

bool True if the model is sane, False otherwise.

mlbugdetection.sanity.sanity_check_with_indexes(model, samples, target)[source]
Sanity Test With Indexes

Analyzes the sanity of a model with samples and shows a Analysis Report that shows if the tests passed or not. If the tests failed, it will show the indexes of the samples that were misclassified.

Parameters
  • model (sklearn model or str) – The model to be used for prediction. Could be a model object or a path to a model file.

  • samples (pandas DataFrame) – The samples (or sample) to be used for prediction, which the model need to predict correctly.

  • target (str) – The name of the column containing the target variable.

Returns

For more information: >>> from mlbugdetection.analysis_report import AnalysisReport >>> help(AnalysisReport)

Return type

AnalysisReport object with following attributes

model_namestr

Name of the model being analysed.

analysed_featurestr

Name of the feature being analysed.

metricsdictionary

Dictionary with all the calculated metrics, such as:

‘sanity’bool

If the model is sane or not.

‘sanity_indexes’: List

List of indexes of the samples that were misclassified.