<jupyter_start><jupyter_text>This simple classifier was used to make the initial comparison between scikit-learn and Tribuo<jupyter_code>%matplotlib inline
import matplotlib.pyplot as plt
import pandas as pd
import numpy as np
#from sklearn import cross_validation
from sklearn.model_selection import train_test_split
from sklearn import preprocessing
from sklearn.linear_model import LogisticRegression, SGDClassifier
from sklearn.preprocessing import LabelEncoder
from sklearn.metrics import classification_report, confusion_matrix
# This is the classic Iris dataset
df = pd.read_csv('../../data/bezdekIris.data', header=None)
# print(df)
X = np.array(df[[0,1,2,3]])
y = np.array(df[4])

# class_le = LabelEncoder()
# y = class_le.fit_transform(df[4].values)

X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.3, random_state=1)
print('Training data size = %d, number of features = %d' % (len(X_train), 4))
print('Testing data size = %d, number of features = %d' % (len(X_test), 4))
stdscaler = preprocessing.StandardScaler().fit(X_train)
X_train_scaled = stdscaler.transform(X_train)
X_test_scaled  = stdscaler.transform(X_test)
# lr = LogisticRegression()
# lr.fit(X_train, y_train)
# lr.fit(X_train_scaled, y_train)

sgd = SGDClassifier(max_iter=1000, learning_rate='adaptive', epsilon=0.1, eta0=1.0)
sgd.fit(X_train, y_train)
# predicted = lr.predict(X_test)
# predicted = lr.predict(X_test_scaled)

predicted = sgd.predict(X_test)
print(classification_report(y_test, predicted))
print(confusion_matrix(y_test, predicted, labels=['Iris-versicolor', 'Iris-virginica', 'Iris-setosa']))<jupyter_output>[[15  2  1]
 [ 0 13  0]
 [ 0  0 14]]
{'fraction_non_alphanumeric': 0.12221553281155931, 'fraction_numerical': 0.01926550270921132, 'mean_word_length': 6.694444444444445, 'pattern_counts': {'":': 0, '<': 4, '<?xml version=': 0, '>': 4, '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': '1', 'dir': 'jupyter-structured-clean-dedup', 'id': '381244', 'license': 'Apache-2.0', 'n_tokens_mistral': 622, 'n_tokens_neox': 606, 'n_words': 139, 'path': 'notebooks/classifier/scikit-learn Classifier Iris.ipynb', 'repo_name': 'geoffreydstewart/JavaVsPythonMLlibs', 'size': '1661'}