Decision Tree ใครเป็นเบาหวานอธิบายง๊ายง่าย : Machine Learning 101

Decision Tree ใครเป็นเบาหวานอธิบายง๊ายง่าย : Machine Learning 101

Decision Tree ??? ?

Machine Learning Model Classification ??????????????????????????????????????????????????? ??????????????????? ???????????????????????????? ?TREE?

????????? Node ??????????????????????????????? Node ????????????????????? ??????????????? ?????????????????????????????????? ??????????????????

????????????? (?????????????????) ???????????????????????????? ??????????? overfit ??????? ???????????????????????? ???????????????????????

Graphviz ?

???? tool ????????????????????????????????????????? ??????????????? Decision tree ??????????????????????? ???????????????????? ????????????????????????????? export ???? graphviz ??????????????????????????????

??????????

?????????????????? GridsearchCV, train_test_split ?????????????????????????????????????????????????? normalization dataset ???????? dataset ???????? mean 0 variance 1 (?????????????????????????????)

?????????????? Dataset ??? github ??????

peeratpop/Machine_Learning_0-100

Contribute to peeratpop/Machine_Learning_0-100 development by creating an account on GitHub.

github.com

?????????????????? jupyter notebook ????????????? python ???????????????? csv ??????

import pandas as pddata = pd.read_csv(?pima-indians-diabetes.csv?)data.head()

????????????????????????? dataset ??????

data.describe()

?????????? min ?????? feature ????????? 0 ?????????????????????????????????????? BMI ?????????? = 0 ????? ? ??????????? 0 ???? outlier ???????

?????????????????? 0 ???????????????????? ?????????????? 0 ?????????????? NaN

import numpy as npdata[[?Glucose_concentration?,?Blood_pressure?,?Triceps?,?Insulin?,?BMI?,?Pedigree?]] = data[[?Glucose_concentration?,?Blood_pressure?,?Triceps?,?Insulin?,?BMI?,?Pedigree?]].replace(0,np.NaN)

??????????????? NaN ?? dataset ????????

data.isnull().sum()

??????? outlier ????????????????? ????????????????????????????? imputer ???????????? NaN ??????????? ???????????????????? pandas ???????????????????????????????????????????????? fillna() ???????????????????????????? NaN ???????????? Imputer ???

data[?Glucose_concentration?].fillna(data[?Glucose_concentration?].mean(), inplace = True)data[?Blood_pressure?].fillna(data[?Blood_pressure?].mean(), inplace = True)data[?Triceps?].fillna(data[?Triceps?].median(), inplace = True)data[?Insulin?].fillna(data[?Insulin?].median(), inplace = True)data[?BMI?].fillna(data[?BMI?].median(), inplace = True)data[?Pedigree?].fillna(data[?Pedigree?].median(), inplace = True)

???????? NaN ????????????????

??????????????????????????????????????????? feature ???????????????????????????????????

def plot_box(data, cols, col_x = ?Class?): for col in cols: sns.set_style(?whitegrid?) sns.boxplot(col_x, col, data=data) plt.xlabel(col_x) # Set text for the x axis plt.ylabel(col)# Set text for y axis plt.show()num_cols = [?Number_pregnant?, ?Glucose_concentration?, ?Blood_pressure?, ?Triceps?, ?Insulin?, ?BMI?, ?Pedigree?, ?Age?]plot_box(data, num_cols)

??????????????????

??????????????????????????????????? test ?????????

y_pred = tree.predict(X_test)from sklearn.metrics import accuracy_score,classification_reportprint(accuracy_score(y_test, y_pred))print(classification_report(y_test, y_pred))

????????????????? gridsearchCV ????????????????????????????????????? 2 ??????????????????????

??????????????????????????????????? http://www.webgraphviz.com/

???????? generate graphviz ?????????????????

??????????????????????????????????????????????????????????????????????????????????????????

??????????????????????????????????????????????? ?????????????????????????????????????????????????????????????

????????????

???????????????????????????????????????????????????????????????????????????????? ?????????????????? ??? Decision tree ?????????????????????????????? Tree ??????????????? tree ???????????????????????????????????????????????????????

??????????? :

Random Forest ??????????????????????????????????.

Github : https://github.com/peeratpop/Machine_Learning_101

Medium : https://medium.com/@pingloaf

Linkedin : https://www.linkedin.com/in/peerat-limkonchotiwat/

???????????????????????????????

?????????? Machine/Deep Learning 0?100 (Introduction)

?????????? Machine Learning 0?100 zero to Mr.incredible (Introduction)

Machine Learning ??????????????????

medium.com

1

No Responses

Write a response