Support Code Docs
These classes and functions work as a support for the predictions objects, considered the core of the package.
Metrics functions
Metrics computation is contained in standalone functions to ensure usability.
- easypred.metrics.accuracy_score(real_values, fitted_values, value_positive=1)
Return a float representing the percent of items which are equal between the real and the fitted values.
Also called: percentage correctly classified
- Parameters
real_values (numpy array | pandas series) – Array containing the true values.
fitted_values (numpy array | pandas series) – Array containing the predicted values.
value_positive (Any, optional) – This argument has no effect and it is ignored by the function. It is present so that all the binary metrics have the same interface. By default is 1.
- Returns
Accuracy score
- Return type
float
References
https://en.wikipedia.org/wiki/Accuracy_and_precision#In_binary_classification
- easypred.metrics.balanced_accuracy_score(real_values, fitted_values, value_positive=1)
Return the float representing the arithmetic mean between recall score and specificity score.
It provides an idea of the goodness of the prediction in unbalanced datasets.
- Parameters
real_values (numpy array | pandas series) – Array containing the true values.
fitted_values (numpy array | pandas series) – Array containing the predicted values.
value_positive (Any, optional) – The value in the data that corresponds to 1 in the boolean logic. It is generally associated with the idea of “positive” or being in the “treatment” group. By default is 1.
- Returns
Balanced accuracy score
- Return type
float
- easypred.metrics.f1_score(real_values, fitted_values, value_positive=0)
Return the harmonic mean of the precision and recall.
It gives an idea of an overall goodness of your precision and recall taken together.
Also called: balanced F-score or F-measure
- Parameters
real_values (numpy array | pandas series) – Array containing the true values.
fitted_values (numpy array | pandas series) – Array containing the predicted values.
value_positive (Any, optional) – The value in the data that corresponds to 1 in the boolean logic. It is generally associated with the idea of “positive” or being in the “treatment” group. By default is 1.
- Returns
F1 score
- Return type
float
References
- easypred.metrics.false_negative_rate(real_values, fitted_values, value_positive=1)
Return the ratio between the number of false negatives and the total number of real positives.
It tells the percentage of positives falsely classified as negative.
- Parameters
real_values (numpy array | pandas series) – Array containing the true values.
fitted_values (numpy array | pandas series) – Array containing the predicted values.
value_positive (Any, optional) – The value in the data that corresponds to 1 in the boolean logic. It is generally associated with the idea of “positive” or being in the “treatment” group. By default is 1.
- Returns
False negative rate
- Return type
float
- easypred.metrics.false_positive_rate(real_values, fitted_values, value_positive=1)
Return the ratio between the number of false positives and the total number of real negatives.
It tells the percentage of negatives falsely classified as positive.
- Parameters
real_values (numpy array | pandas series) – Array containing the true values.
fitted_values (numpy array | pandas series) – Array containing the predicted values.
value_positive (Any, optional) – The value in the data that corresponds to 1 in the boolean logic. It is generally associated with the idea of “positive” or being in the “treatment” group. By default is 1.
- Returns
False positive rate
- Return type
float
References
- easypred.metrics.negative_predictive_value(real_values, fitted_values, value_positive=1)
Return the ratio between the number of correctly classified negative and the total number of predicted negative.
It measures how accurate the negative predictions are.
- Parameters
real_values (numpy array | pandas series) – Array containing the true values.
fitted_values (numpy array | pandas series) – Array containing the predicted values.
value_positive (Any, optional) – The value in the data that corresponds to 1 in the boolean logic. It is generally associated with the idea of “positive” or being in the “treatment” group. By default is 1.
- Returns
Negative predictive value
- Return type
float
References
https://en.wikipedia.org/wiki/Positive_and_negative_predictive_values
- easypred.metrics.precision_score(real_values, fitted_values, value_positive=1)
Return the ratio between the number of correctly predicted positives and the total number predicted positives.
It measures how accurate the positive predictions are.
Also called: positive predicted value.
- Parameters
real_values (numpy array | pandas series) – Array containing the true values.
fitted_values (numpy array | pandas series) – Array containing the predicted values.
value_positive (Any, optional) – The value in the data that corresponds to 1 in the boolean logic. It is generally associated with the idea of “positive” or being in the “treatment” group. By default is 1.
- Returns
Precision score
- Return type
float
References
https://en.wikipedia.org/wiki/Positive_and_negative_predictive_values
- easypred.metrics.recall_score(real_values, fitted_values, value_positive=1)
Return the ratio between the correctly predicted positives and the total number of real positives.
It measures how good the model is in detecting real positives.
Also called: sensitivity, true positive rate, hit rate
- Parameters
real_values (numpy array | pandas series) – Array containing the true values.
fitted_values (numpy array | pandas series) – Array containing the predicted values.
value_positive (Any, optional) – The value in the data that corresponds to 1 in the boolean logic. It is generally associated with the idea of “positive” or being in the “treatment” group. By default is 1.
- Returns
Recall score
- Return type
float
References
https://en.wikipedia.org/wiki/Sensitivity_and_specificity#Sensitivity
- easypred.metrics.specificity_score(real_values, fitted_values, value_positive=0)
Return the ratio between the correctly predicted negatives and the total number of real negatives.
It measures how good the model is in detecting real negatives.
Also called: selectivity, true negative rate
- Parameters
real_values (numpy array | pandas series) – Array containing the true values.
fitted_values (numpy array | pandas series) – Array containing the predicted values.
value_positive (Any, optional) – The value in the data that corresponds to 1 in the boolean logic. It is generally associated with the idea of “positive” or being in the “treatment” group. By default is 1.
- Returns
Specificity score
- Return type
float
References
https://en.wikipedia.org/wiki/Sensitivity_and_specificity#Specificity