pip install mldsutils
from mldsutils.mldsutils import *
import numpy as np
from sklearn.neighbors import KNeighborsClassifier
from sklearn.svm import SVC
from sklearn.datasets import make_classification
classifiers = [KNeighborsClassifier(3),
SVC(kernel="linear", C=0.025),
SVC(gamma=2, C=10),]
clf_names = ['k-Nearest Neighbors(3)',
'Support Vector Machine with Linear Kernel',
'Support Vector Machine with RBF Kernel']
X1, y1 = make_classification(n_features=20, n_samples=2000,n_redundant=0, n_informative=20,
n_clusters_per_class=1,class_sep=0.5)
d1,d2 = run_classifiers(X1,y1,
clf_lst=classifiers,names = clf_names,
runtime=True,
metric='f1',verbose=True)
d1
d1.describe().T
d2
d2.describe().T
Visualizing the results with the plot_bars function
Make sure to pass the correct titles of the plots. Otherwise, default strings will be plotted which may indicate wrong thing for your experiment.
plot_bars(d1,t1="Mean F1 score of algorithms",
t2="Std.dev of the F1 scores of algorithms")
plot_bars(d2,t1="Mean fitting time of algorithms",
t2="Std.dev of the fitting time of algorithms")
from sklearn.neighbors import KNeighborsClassifier
from sklearn.datasets import make_classification
import matplotlib.pyplot as plt
from mldsutils.plots import *
X1, y1 = make_classification(n_features=10, n_samples=100,
n_redundant=0, n_informative=10,
n_clusters_per_class=1,class_sep=0.5)
plot_decision_boundaries(X1,y1,KNeighborsClassifier,n_neighbors=5)
plt.show()