<jupyter_start><jupyter_text>1단계 : 데이터 로딩 + EDA Data Load<jupyter_code>import pandas as pd
![ ! -f  iris0.csv ]&&wget http://j.finfra.com/_file/iris0.csv
iris=pd.read_csv("iris0.csv")
iris<jupyter_output><empty_output><jupyter_text>EDA<jupyter_code>import seaborn as sns
import matplotlib.pyplot as plt
sns.set_style("whitegrid");
sns.pairplot(iris,hue="Species");
plt.show()<jupyter_output><empty_output><jupyter_text>2단계 : 학습 데이터/ 평가 데이터로 분리<jupyter_code>from sklearn.model_selection import train_test_split
X_train, X_test, y_train, y_test = train_test_split(iris.iloc[:,0:4], iris['Species'])
display(X_train.shape, X_test.shape, y_train.shape, y_test.shape)<jupyter_output><empty_output><jupyter_text>3단계 : 학습(Training)<jupyter_code>from sklearn.neighbors import KNeighborsClassifier

model = KNeighborsClassifier(n_neighbors=1) # 기본값은 5
model.fit(X_train, y_train)<jupyter_output><empty_output><jupyter_text>4단계 : 평가<jupyter_code>score = model.score(X_test, y_test) # score를 이용해 평가
print(score) #원래 잘 분리된 데이터라 높게 나왔다
pred_y=model.predict(X_test)
pred_y==y_test<jupyter_output>0.9736842105263158<jupyter_text>5단계 : 모델 저장<jupyter_code>from joblib import dump
dump(model,'model.joblib')<jupyter_output><empty_output><jupyter_text>6단계 : 서비스 활용<jupyter_code>from joblib import load
model_rebuild = load('model.joblib') 
model_rebuild.predict(X_test[0:1])<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.12851985559566786, 'fraction_numerical': 0.023104693140794223, 'mean_word_length': 9.661538461538461, 'pattern_counts': {'":': 0, '<': 28, '<?xml version=': 0, '>': 28, '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': '7', 'dir': 'jupyter-structured-clean-dedup', 'id': '505843', 'license': 'MIT', 'n_tokens_mistral': 663, 'n_tokens_neox': 698, 'n_words': 82, 'path': '00_Background/NoneNLP_background/AnalyticProcess.ipynb', 'repo_name': 'Finfra/AI_NLP', 'size': '1385'}