<jupyter_start><jupyter_text>Pipeline<jupyter_code>from sklearn.pipeline import Pipeline
from sklearn.preprocessing import StandardScaler

num_attribs = list(df.drop("entity", axis=1))  # numerical attributes

cat_attribs = ["entity"]  # categorical attributes

# numerical and categorical pipelines
num_pipeline = Pipeline([
    #        ('imputer', Imputer(strategy="median")),
    #        ('attribs_adder', CombinedAttributesAdder()),
    ('selector', DataFrameSelector(num_attribs)),
    ('std_scaler', StandardScaler()),
])

cat_pipeline = Pipeline([
    ('selector', DataFrameSelector(cat_attribs)),
    ('cat_encoder', CategoricalEncoder(encoding="ordinal")),
])
from sklearn.pipeline import FeatureUnion

full_pipeline = FeatureUnion(transformer_list=[
    ("num_pipeline", num_pipeline),
    #("cat_pipeline", cat_pipeline),
])

from sklearn.utils import shuffle
df = shuffle(df)
fulldata = full_pipeline.fit_transform(df)
cat_encoder = CategoricalEncoder(encoding="ordinal")
fulldata_labels = df['entity'].values.reshape(-1, 1)
fulldata_labels_ordinal = cat_encoder.fit_transform(fulldata_labels)
from sklearn import svm
from sklearn.discriminant_analysis import QuadraticDiscriminantAnalysis
from sklearn.ensemble import RandomForestClassifier, AdaBoostClassifier
from sklearn.gaussian_process import GaussianProcessClassifier
from sklearn.gaussian_process.kernels import RBF
from sklearn.model_selection import cross_val_score
from sklearn.naive_bayes import GaussianNB
from sklearn.neighbors import KNeighborsClassifier
from sklearn.neural_network import MLPClassifier
from sklearn.tree import DecisionTreeClassifier
from sklearn.tree import DecisionTreeRegressor
algos =[ (svm.SVC(),'svm svc'), # C-Support Vector Classification.
         (svm.LinearSVC(), 'svm_linear'), # Linear Support Vector Classification.
         (svm.NuSVC(), 'nusvc'), # Nu-Support Vector Classification.
         (svm.NuSVR(), 'nusvr'), # Nu Support Vector Regression.
         (svm.SVR(),'svr'), # Epsilon-Support Vector Regression.
         (DecisionTreeClassifier(),'dtree'),
         (DecisionTreeRegressor(),'dtreerg'),
         (KNeighborsClassifier(n_neighbors=3),'near'),
         (MLPClassifier(solver='adam',
                           alpha=1e-5,
                           hidden_layer_sizes=(5, 2),
                           #random_state=1,
                           max_iter=10000,
                           learning_rate='adaptive'),'neural'),
        (KNeighborsClassifier(3),'knei_3'),
        #(GaussianProcessClassifier(1.0 * RBF(1.0)),'gaussian'),
        (RandomForestClassifier(max_depth=5, n_estimators=10, max_features=1),'randomforest'),
        (AdaBoostClassifier(),'adaboost'),
        (GaussianNB(),'gaussianNB'),
        (QuadraticDiscriminantAnalysis(),'quadratic')
]


for al in algos:
    classifier, name = al
    
    scores = cross_val_score(classifier,
                             fulldata,
                             fulldata_labels_ordinal.ravel()
                             #scoring='accuracy'
                            )

    print("Accuracy %s: %0.2f (+/- %0.4f)" % (name, scores.mean(), scores.std() * 2 * 100))
df_cat = df['entity']
df_encoded, df_categories = df_cat.factorize()
df_categories


fulldata = full_pipeline.fit_transform(df)
cat_encoder = CategoricalEncoder(encoding="ordinal")
fulldata_labels = df['entity'].values.reshape(-1, 1)
fulldata_labels_ordinal = cat_encoder.fit_transform(fulldata_labels)

dtc = DecisionTreeClassifier()
scores = cross_val_score(dtc,
                             fulldata,
                             fulldata_labels_ordinal.ravel()
                             #scoring='accuracy'
                            )
from sklearn.model_selection import cross_val_predict
dtc = DecisionTreeClassifier()
y_train_pred = cross_val_predict(dtc,
                             fulldata,
                             fulldata_labels_ordinal.ravel()
                             #scoring='accuracy'
                            )

from sklearn.metrics import confusion_matrix
conf_mx = confusion_matrix(fulldata_labels_ordinal.ravel(),y_train_pred)

conf_mx
%matplotlib inline
import matplotlib.pyplot as plt

alpha = ['Lab-2', 'Lab-C', 'Lab-B', 'Lab-D', 'Lab-1', 'Lab-A']

fig = plt.figure()
ax = fig.add_subplot(111)
cax = ax.matshow(conf_mx, cmap=plt.cm.gray)

ax.set_xticklabels(['']+alpha)
ax.set_yticklabels(['']+alpha)

save_fig('conf_mat')

plt.show()
row_sums = conf_mx.sum(axis=1, keepdims=True)
norm_conf_mx = conf_mx / row_sums
np.fill_diagonal(norm_conf_mx, 0)
#plt.matshow(norm_conf_mx, cmap=plt.cm.gray)
#plt.matshow(norm_conf_mx)

#Index(['np_windows10x86.raw', 'np_tohiba.raw', 'np_x58pc.raw', 'np_freebsd.raw', 'np_ubuntu.raw', 'np_nuc.raw'
    
# 1 ubuntu
# 2 windows10x86
# a nuc
# b x58
# c toshiba
# d freebsd    
alpha = ['Lab-2', 'Lab-C', 'Lab-B', 'Lab-D', 'Lab-1', 'Lab-A']

fig = plt.figure()
ax = fig.add_subplot(111)
cax = ax.matshow(norm_conf_mx, cmap=plt.cm.gray)
#fig.colorbar(cax)

ax.set_xticklabels(['']+alpha)
ax.set_yticklabels(['']+alpha)

ax.set_xticklabels(['']+alpha)
ax.set_yticklabels(['']+alpha)

save_fig('conf_mat_errors')

plt.show()
# http://scikit-learn.org/stable/auto_examples/model_selection/plot_confusion_matrix.html#sphx-glr-auto-examples-model-selection-plot-confusion-matrix-py
print(__doc__)

import itertools
import numpy as np
import matplotlib.pyplot as plt

from sklearn import svm, datasets
from sklearn.model_selection import train_test_split
from sklearn.metrics import confusion_matrix

# import some data to play with
#iris = datasets.load_iris()
X = fulldata
y = fulldata_labels_ordinal.ravel()
class_names = ['Lab-2', 'Lab-C', 'Lab-B', 'Lab-D', 'Lab-1', 'Lab-A']


# Split the data into a training set and a test set
X_train, X_test, y_train, y_test = train_test_split(X, y, random_state=0)

# Run classifier, using a model that is too regularized (C too low) to see
# the impact on the results
classifier = DecisionTreeClassifier()
y_pred = classifier.fit(X_train, y_train).predict(X_test)


def plot_confusion_matrix(cm, classes,
                          normalize=False,
                          title='Confusion matrix',
                          cmap=plt.cm.Blues):
    """
    This function prints and plots the confusion matrix.
    Normalization can be applied by setting `normalize=True`.
    """
    if normalize:
        cm = cm.astype('float') / cm.sum(axis=1)[:, np.newaxis]
        print("Normalized confusion matrix")
    else:
        print('Confusion matrix, without normalization')

    print(cm)

    plt.imshow(cm, interpolation='nearest', cmap=cmap)
    plt.title(title)
    plt.colorbar()
    tick_marks = np.arange(len(classes))
    plt.xticks(tick_marks, classes, rotation=45)
    plt.yticks(tick_marks, classes)

    fmt = '.2f' if normalize else 'd'
    thresh = cm.max() / 2.
    for i, j in itertools.product(range(cm.shape[0]), range(cm.shape[1])):
        plt.text(j, i, format(cm[i, j], fmt),
                 horizontalalignment="center",
                 color="white" if cm[i, j] > thresh else "black")

    plt.tight_layout()
    plt.ylabel('True label')
    plt.xlabel('Predicted label')

# Compute confusion matrix
cnf_matrix = confusion_matrix(y_test, y_pred)
np.set_printoptions(precision=2)

# Plot non-normalized confusion matrix
#plt.figure()
#plot_confusion_matrix(cnf_matrix, classes=class_names,
#                      title='Confusion matrix, without normalization')

# Plot normalized confusion matrix
plt.figure()
plot_confusion_matrix(cnf_matrix, classes=class_names, normalize=True,
                      title='Normalized confusion matrix')

save_fig('conf_mat')


plt.figure()

row_sums = cnf_matrix.sum(axis=1, keepdims=True)
norm_conf_mx = cnf_matrix / row_sums
np.fill_diagonal(norm_conf_mx, 0)

plot_confusion_matrix(norm_conf_mx, classes=class_names, normalize=True,
                      title='Normalized confusion errors')

save_fig('conf_mat_errors')

plt.show()
from sklearn.decomposition import PCA<jupyter_output><empty_output><jupyter_text>graficos<jupyter_code>#filter
#df_4 = df[df.entity != 'np_windows10x86.raw']
df_4 = df

df_4 = df_4[df_4.entity != 'np_ubuntu.raw']
#df_4 = df_4[df_4.entity != 'np_x58pc.raw']
#df_4 = df_4[df_4.entity != 'np_tohiba.raw']
df_4 = df_4[df_4.entity != 'np_nuc.raw']
#df_4 = df_4[df_4.entity != 'np_freebsd.raw']

print(df_4['entity'].value_counts())

fulldata = full_pipeline.fit_transform(df_4)
cat_encoder = CategoricalEncoder(encoding="ordinal")
fulldata_labels = df_4['entity'].values.reshape(-1, 1)
fulldata_labels_ordinal = cat_encoder.fit_transform(fulldata_labels)


pca = PCA(n_components=2)
pca.fit(fulldata)

fulldata_pca2 = pca.transform(fulldata)
df_4.shape
fulldata_labels_ordinal.shape






print(__doc__)

import numpy as np
import matplotlib.pyplot as plt
from sklearn import svm, datasets


def make_meshgrid(x, y, h=.02):
    """Create a mesh of points to plot in

    Parameters
    ----------
    x: data to base x-axis meshgrid on
    y: data to base y-axis meshgrid on
    h: stepsize for meshgrid, optional

    Returns
    -------
    xx, yy : ndarray
    """
    x_min, x_max = x.min() - 1, x.max() + 1
    y_min, y_max = y.min() - 1, y.max() + 1
    xx, yy = np.meshgrid(np.arange(x_min, x_max, h),
                         np.arange(y_min, y_max, h))
    return xx, yy


def plot_contours(ax, clf, xx, yy, **params):
    """Plot the decision boundaries for a classifier.

    Parameters
    ----------
    ax: matplotlib axes object
    clf: a classifier
    xx: meshgrid ndarray
    yy: meshgrid ndarray
    params: dictionary of params to pass to contourf, optional
    """
    Z = clf.predict(np.c_[xx.ravel(), yy.ravel()])
    Z = Z.reshape(xx.shape)
    out = ax.contourf(xx, yy, Z, **params)
    return out


# import some data to play with
#iris = datasets.load_iris()
# Take the first two features. We could avoid this by using a two-dim dataset
#X = iris.data[:, :2]
#y = iris.target

X = fulldata_pca2[:300]
y = fulldata_labels_ordinal.ravel()[:300]

# we create an instance of SVM and fit out data. We do not scale our
# data since we want to plot the support vectors
C = 1.0  # SVM regularization parameter
models = (svm.SVC(kernel='linear', C=C),
          svm.LinearSVC(C=C),
          svm.SVC(kernel='rbf', gamma=0.7, C=C),
          svm.SVC(kernel='poly', degree=3, C=C))
models = (clf.fit(X, y) for clf in models)
print("training...", end=" ")
#models = (clf.fit(fulldata_pca2, fulldata_labels_ordinal.ravel()) for clf in models)
print("...done")


# title for the plots
titles = ('SVC with linear kernel',
          'LinearSVC (linear kernel)',
          'SVC with RBF kernel',
          'SVC with polynomial (degree 3) kernel')

# Set-up 2x2 grid for plotting.
fig, sub = plt.subplots(2, 2)
plt.subplots_adjust(wspace=0.4, hspace=0.4)

X0, X1 = X[:, 0], X[:, 1]
xx, yy = make_meshgrid(X0, X1)

for clf, title, ax in zip(models, titles, sub.flatten()):
    plot_contours(ax, clf, xx, yy,
                  cmap=plt.cm.coolwarm, alpha=0.8)
    ax.scatter(X0, X1, c=y, cmap=plt.cm.coolwarm, s=20, edgecolors='k')
    ax.set_xlim(xx.min(), xx.max())
    ax.set_ylim(yy.min(), yy.max())
    ax.set_xlabel('Sepal length')
    ax.set_ylabel('Sepal width')
    ax.set_xticks(())
    ax.set_yticks(())
    ax.set_title(title)
    
save_fig('svm_pca2')

plt.show()<jupyter_output><empty_output><jupyter_text>multi<jupyter_code>fulldata = full_pipeline.fit_transform(df_A)
cat_encoder = CategoricalEncoder(encoding="ordinal")
fulldata_labels = df_A['entity'].values.reshape(-1, 1)
fulldata_labels_ordinal_A = cat_encoder.fit_transform(fulldata_labels)


pca = PCA(n_components=2)
pca.fit(fulldata)
fulldata_pca2_A = pca.transform(fulldata)


# dois
#df_B = df[df.entity != 'np_windows10x86.raw']
df_B = df
#df_B = df_B[df_B.entity != 'np_ubuntu.raw']
df_B = df_B[df_B.entity != 'np_x58pc.raw']
df_B = df_B[df_B.entity != 'np_tohiba.raw']
df_B = df_B[df_B.entity != 'np_nuc.raw']
df_B = df_B[df_B.entity != 'np_freebsd.raw']


fulldata = full_pipeline.fit_transform(df_B)
cat_encoder = CategoricalEncoder(encoding="ordinal")
fulldata_labels = df_B['entity'].values.reshape(-1, 1)
fulldata_labels_ordinal_B = cat_encoder.fit_transform(fulldata_labels)


pca = PCA(n_components=2)
pca.fit(fulldata)
fulldata_pca2_B = pca.transform(fulldata)





df_A['entity'].value_counts()
print(__doc__)


# Code source: <NAME>
#              <NAME>
# Modified for documentation by <NAME>
# License: BSD 3 clause

import numpy as np
import matplotlib.pyplot as plt
from matplotlib.colors import ListedColormap
from sklearn.model_selection import train_test_split
from sklearn.preprocessing import StandardScaler
from sklearn.datasets import make_moons, make_circles, make_classification
from sklearn.neural_network import MLPClassifier
from sklearn.neighbors import KNeighborsClassifier
from sklearn.svm import SVC
from sklearn.gaussian_process import GaussianProcessClassifier
from sklearn.gaussian_process.kernels import RBF
from sklearn.tree import DecisionTreeClassifier
from sklearn.ensemble import RandomForestClassifier, AdaBoostClassifier
from sklearn.naive_bayes import GaussianNB
from sklearn.discriminant_analysis import QuadraticDiscriminantAnalysis

h = .02  # step size in the mesh

names = ["Nearest Neighbors", "Linear SVM", "RBF SVM", "Gaussian Process",
         "Decision Tree", "Random Forest", "Neural Net", "AdaBoost",
         "Naive Bayes", "QDA"]



names =["Decision Tree Classifier",
        "Random Forest Classifier",
        "C-Support Vector Classification",
        "K-nearest Neighbors",
        "Multi-layer Perceptron Classifier"
       ]

classifiers = [
    DecisionTreeClassifier(),
    RandomForestClassifier(),
    KNeighborsClassifier(),
    SVC(),
    KNeighborsClassifier(),
    MLPClassifier() 
]
    #SVC(kernel="linear", C=0.025),
    #SVC(gamma=2, C=1),
    #GaussianProcessClassifier(1.0 * RBF(1.0)),
    #DecisionTreeClassifier(max_depth=5),
    
    #RandomForestClassifier(max_depth=5, n_estimators=10, max_features=1),
    
    #MLPClassifier(alpha=1),
    #AdaBoostClassifier(),
    #GaussianNB(),
    #QuadraticDiscriminantAnalysis()]

X, y = make_classification(n_features=2, n_redundant=0, n_informative=2,
                           random_state=1, n_clusters_per_class=1)
rng = np.random.RandomState(2)
X += 2 * rng.uniform(size=X.shape)
linearly_separable = (X, y)

datasets = [None #make_moons(noise=0.3, random_state=0),)
            #make_circles(noise=0.2, factor=0.5, random_state=1),
            #linearly_separable
            ]
             
datasets = [
    (fulldata_pca2_A[:2000], fulldata_labels_ordinal_A.ravel()[:2000])
    #(fulldata_pca2_B[:2000], fulldata_labels_ordinal_B.ravel()[:2000])
]

figure = plt.figure(figsize=(27, 9))
i = 1
# iterate over datasets
for ds_cnt, ds in enumerate(datasets):
    # preprocess dataset, split into training and test part
    
    X, y = ds
    
    X = StandardScaler().fit_transform(X)
    X_train, X_test, y_train, y_test = \
        train_test_split(X, y, test_size=.4, random_state=42)

    x_min, x_max = X[:, 0].min() - .5, X[:, 0].max() + .5
    y_min, y_max = X[:, 1].min() - .5, X[:, 1].max() + .5
    xx, yy = np.meshgrid(np.arange(x_min, x_max, h),
                         np.arange(y_min, y_max, h))

    # just plot the dataset first
    cm = plt.cm.RdBu
    cm_bright = ListedColormap(['#FF0000', '#0000FF'])
    ax = plt.subplot(len(datasets), len(classifiers) + 1, i)
    if ds_cnt == 0:
        ax.set_title("Input data", size=18)
    # Plot the training points
    ax.scatter(X_train[:, 0], X_train[:, 1], c=y_train, cmap=cm_bright,
               edgecolors='k')
    # and testing points
    ax.scatter(X_test[:, 0], X_test[:, 1], c=y_test, cmap=cm_bright, alpha=0.6,
               edgecolors='k')
    ax.set_xlim(xx.min(), xx.max())
    ax.set_ylim(yy.min(), yy.max())
    ax.set_xticks(())
    ax.set_yticks(())
    i += 1

    # iterate over classifiers
    for name, clf in zip(names, classifiers):
        ax = plt.subplot(len(datasets), len(classifiers) + 1, i)
        clf.fit(X_train, y_train)
        score = clf.score(X_test, y_test)

        # Plot the decision boundary. For that, we will assign a color to each
        # point in the mesh [x_min, x_max]x[y_min, y_max].
        if hasattr(clf, "decision_function"):
            Z = clf.decision_function(np.c_[xx.ravel(), yy.ravel()])
        else:
            Z = clf.predict_proba(np.c_[xx.ravel(), yy.ravel()])[:, 1]

        # Put the result into a color plot
        Z = Z.reshape(xx.shape)
        ax.contourf(xx, yy, Z, cmap=cm, alpha=.8)

        # Plot also the training points
        ax.scatter(X_train[:, 0], X_train[:, 1], c=y_train, cmap=cm_bright,
                   edgecolors='k')
        # and testing points
        ax.scatter(X_test[:, 0], X_test[:, 1], c=y_test, cmap=cm_bright,
                   edgecolors='k', alpha=0.6)

        ax.set_xlim(xx.min(), xx.max())
        ax.set_ylim(yy.min(), yy.max())
        ax.set_xticks(())
        ax.set_yticks(())
        if ds_cnt == 0:
            ax.set_title(name,size=18)
        ax.text(xx.max() - .3, yy.min() + .3, ('%.2f' % score).lstrip('0'),
                size=18, horizontalalignment='right')
        i += 1

plt.tight_layout()
save_fig('multi_different')
plt.show()
print(__doc__)


# Code source: <NAME>
#              <NAME>
# Modified for documentation by <NAME>
# License: BSD 3 clause

import numpy as np
import matplotlib.pyplot as plt
from matplotlib.colors import ListedColormap
from sklearn.model_selection import train_test_split
from sklearn.preprocessing import StandardScaler
from sklearn.datasets import make_moons, make_circles, make_classification
from sklearn.neural_network import MLPClassifier
from sklearn.neighbors import KNeighborsClassifier
from sklearn.svm import SVC
from sklearn.gaussian_process import GaussianProcessClassifier
from sklearn.gaussian_process.kernels import RBF
from sklearn.tree import DecisionTreeClassifier
from sklearn.ensemble import RandomForestClassifier, AdaBoostClassifier
from sklearn.naive_bayes import GaussianNB
from sklearn.discriminant_analysis import QuadraticDiscriminantAnalysis

h = .02  # step size in the mesh

names = ["Nearest Neighbors", "Linear SVM", "RBF SVM", "Gaussian Process",
         "Decision Tree", "Random Forest", "Neural Net", "AdaBoost",
         "Naive Bayes", "QDA"]



names =["Decision Tree Classifier",
        "Random Forest Classifier",
        "C-Support Vector Classification",
        "K-nearest Neighbors",
        "Multi-layer Perceptron Classifier"
       ]

classifiers = [
    DecisionTreeClassifier(),
    RandomForestClassifier(),
    KNeighborsClassifier(),
    SVC(),
    KNeighborsClassifier(),
    MLPClassifier() 
]
    #SVC(kernel="linear", C=0.025),
    #SVC(gamma=2, C=1),
    #GaussianProcessClassifier(1.0 * RBF(1.0)),
    #DecisionTreeClassifier(max_depth=5),
    
    #RandomForestClassifier(max_depth=5, n_estimators=10, max_features=1),
    
    #MLPClassifier(alpha=1),
    #AdaBoostClassifier(),
    #GaussianNB(),
    #QuadraticDiscriminantAnalysis()]

X, y = make_classification(n_features=2, n_redundant=0, n_informative=2,
                           random_state=1, n_clusters_per_class=1)
rng = np.random.RandomState(2)
X += 2 * rng.uniform(size=X.shape)
linearly_separable = (X, y)

datasets = [None #make_moons(noise=0.3, random_state=0),)
            #make_circles(noise=0.2, factor=0.5, random_state=1),
            #linearly_separable
            ]
             
datasets = [
    #(fulldata_pca2_A[:2000], fulldata_labels_ordinal_A.ravel()[:2000])
    (fulldata_pca2_B[:2000], fulldata_labels_ordinal_B.ravel()[:2000])
]

figure = plt.figure(figsize=(27, 9))
i = 1
# iterate over datasets
for ds_cnt, ds in enumerate(datasets):
    # preprocess dataset, split into training and test part
    
    X, y = ds
    
    X = StandardScaler().fit_transform(X)
    X_train, X_test, y_train, y_test = \
        train_test_split(X, y, test_size=.4, random_state=42)

    x_min, x_max = X[:, 0].min() - .5, X[:, 0].max() + .5
    y_min, y_max = X[:, 1].min() - .5, X[:, 1].max() + .5
    xx, yy = np.meshgrid(np.arange(x_min, x_max, h),
                         np.arange(y_min, y_max, h))

    # just plot the dataset first
    cm = plt.cm.RdBu
    cm_bright = ListedColormap(['#FF0000', '#0000FF'])
    ax = plt.subplot(len(datasets), len(classifiers) + 1, i)
    if ds_cnt == 0:
        ax.set_title("Input data", size=18)
    # Plot the training points
    ax.scatter(X_train[:, 0], X_train[:, 1], c=y_train, cmap=cm_bright,
               edgecolors='k')
    # and testing points
    ax.scatter(X_test[:, 0], X_test[:, 1], c=y_test, cmap=cm_bright, alpha=0.6,
               edgecolors='k')
    ax.set_xlim(xx.min(), xx.max())
    ax.set_ylim(yy.min(), yy.max())
    ax.set_xticks(())
    ax.set_yticks(())
    i += 1

    # iterate over classifiers
    for name, clf in zip(names, classifiers):
        ax = plt.subplot(len(datasets), len(classifiers) + 1, i)
        clf.fit(X_train, y_train)
        score = clf.score(X_test, y_test)

        # Plot the decision boundary. For that, we will assign a color to each
        # point in the mesh [x_min, x_max]x[y_min, y_max].
        if hasattr(clf, "decision_function"):
            Z = clf.decision_function(np.c_[xx.ravel(), yy.ravel()])
        else:
            Z = clf.predict_proba(np.c_[xx.ravel(), yy.ravel()])[:, 1]

        # Put the result into a color plot
        Z = Z.reshape(xx.shape)
        ax.contourf(xx, yy, Z, cmap=cm, alpha=.8)

        # Plot also the training points
        ax.scatter(X_train[:, 0], X_train[:, 1], c=y_train, cmap=cm_bright,
                   edgecolors='k')
        # and testing points
        ax.scatter(X_test[:, 0], X_test[:, 1], c=y_test, cmap=cm_bright,
                   edgecolors='k', alpha=0.6)

        ax.set_xlim(xx.min(), xx.max())
        ax.set_ylim(yy.min(), yy.max())
        ax.set_xticks(())
        ax.set_yticks(())
        if ds_cnt == 0:
            ax.set_title(name,size=18)
        ax.text(xx.max() - .3, yy.min() + .3, ('%.2f' % score).lstrip('0'),
                size=18, horizontalalignment='right')
        i += 1

plt.tight_layout()
save_fig('multi_same')
plt.show()
from sklearn.metrics import precision_score, recall_score

precision_score(y_train_5, y_train_pred)<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.13320230490909904, 'fraction_numerical': 0.016572117746906687, 'mean_word_length': 3.364132553606238, 'pattern_counts': {'":': 0, '<': 19, '<?xml version=': 0, '>': 20, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '3', 'dir': 'jupyter-structured-clean-dedup', 'id': '640735', 'license': 'MIT', 'n_tokens_mistral': 8316, 'n_tokens_neox': 7927, 'n_words': 1656, 'path': '100 scratchbook categorization.ipynb', 'repo_name': 'luminoso/th-ml-patternrecognition', 'size': '22435'}