njab.sklearn.scoring module#

class njab.sklearn.scoring.ConfusionMatrix(y_true, y_pred)[source]#

Bases: object

Wrapper for sklearn.metrics.confusion_matrix

property as_array#

Return sklearn.metrics.confusion_matrix array

as_classification_series() Series[source]#

Classification labels as pandas.Series.

as_dataframe(names=('true', 'pred')) DataFrame[source]#

Create pandas.DataFrame and return. Names rows and columns.

classification_label() dict[source]#

Classification labels as dict.

njab.sklearn.scoring.get_custom_pred(clf, X: DataFrame, cutoff=0.5) Series[source]#

Calculate predicted class for binary classifier using the specified cutoff. Keep indices of from data X.

njab.sklearn.scoring.get_label_binary_classification(y_true: int, y_pred: int) str[source]#

Get labels (TP, FN, TN, FP) for single case in binary classification.

njab.sklearn.scoring.get_lr_multiplicative_decomposition(results: Results, X: DataFrame, prob: Series, y: Series) DataFrame[source]#

Multiplicative decompositon of odds at the base of the logistic regresion model.

njab.sklearn.scoring.get_pred(clf, X: DataFrame) Series[source]#

Predict class for binary classifier and keep indices of from data X.

njab.sklearn.scoring.get_score(clf, X: DataFrame, pos=1) Series[source]#

Extract score from binary classifier for class one (target class).

njab.sklearn.scoring.get_target_count_per_bin(score: Series, y: Series, n_bins: int = 10) DataFrame[source]#

Created pivot table with y summed per equality sized bin of scores.