<jupyter_start><jupyter_text>ML Algorithm1.  Import data2. Clean data3. Split data into training and test set4.  Create a Model5.  Verify/Confirm the output6.  Improve<jupyter_code># !pip install sklearn
from sklearn.datasets import load_iris
iris = load_iris()
X = iris.data
y = iris.target
feature_names = iris.feature_names
target_names = iris.target_names

print(feature_names)
print(target_names)
from sklearn.model_selection import train_test_split
X_train, X_test, y_train, y_test = train_test_split(X,y, test_size=0.40)

print(X_train.shape)
print(X_test.shape)
from sklearn.neighbors import KNeighborsClassifier
knn = KNeighborsClassifier(n_neighbors=3)
knn.fit(X_train,y_train)
y_predict = knn.predict(X_test)
from sklearn import metrics
print(metrics.accuracy_score(y_test, y_predict))

sample = [
    [3,5,4,2],
    [2,3,5,4]
]
predictions = knn.predict(sample)
pred_species = [iris.target_names[p] for p in predictions]
print("predictions: ", pred_species)<jupyter_output>predictions:  ['versicolor', 'virginica']<jupyter_text>Model Persistence<jupyter_code># !pip install joblib
# from sklearn.externals import joblib
# from joblib import dump, load
import joblib
from joblib import dump, load

joblib.dump(knn, 'mlbrain.joblib')
model = joblib.load('mlbrain.joblib')
model.predict(X_test)
# Using generated joblib
predictions = model.predict(sample)
pred_species = [iris.target_names[p] for p in predictions]
print("predictions: ", pred_species)<jupyter_output>predictions:  ['versicolor', 'virginica']
{'fraction_non_alphanumeric': 0.10678971654581411, 'fraction_numerical': 0.011865524060646011, 'mean_word_length': 6.989473684210527, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, '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': '2', 'dir': 'jupyter-structured-clean-dedup', 'id': '575069', 'license': 'MIT', 'n_tokens_mistral': 570, 'n_tokens_neox': 550, 'n_words': 121, 'path': 'datasci/Iris_game.ipynb', 'repo_name': 'searchs/pymastery', 'size': '1517'}