def prcurve(dataset): if dataset == "binary": X, y = load_spam() model = RidgeClassifier() kws = {} elif dataset == "multiclass": X, y = load_game() X = OrdinalEncoder().fit_transform(X) y = LabelEncoder().fit_transform(y) model = MultinomialNB() kws = { "per_class": True, "iso_f1_curves": True, "fill_area": False, "micro": False, } else: raise ValueError("uknown dataset") X_train, X_test, y_train, y_test = tts(X, y, test_size=0.2, shuffle=True) oz = PRCurve(model, ax=newfig(), **kws) oz.fit(X_train, y_train) oz.score(X_test, y_test) savefig(oz, "precision_recall_{}".format(dataset))
def discrimination(): X, y = load_spam() oz = DiscriminationThreshold(LogisticRegression(solver="lbfgs"), ax=newfig()) oz.fit(X, y) savefig(oz, "discrimination_threshold")
def discrimination_threshold(ax=None): data = load_spam(return_dataset=True) X, y = data.to_pandas() viz = DiscriminationThreshold(RandomForestClassifier(n_estimators=10), ax=ax) return tts_plot(viz, X, y, score=False)
def confusion_matrix(ax=None): data = load_spam(return_dataset=True) X, y = data.to_pandas() viz = PrecisionRecallCurve(LogisticRegression(), ax=ax) return tts_plot(viz, X, y)