6 Sun
ํ์
์ค๋ฌด์์๊ฒ ๋ฐฐ์ฐ๋ Kaggle ๋จธ์ ๋ฌ๋ ์
๋ฌธ
๊ฒฐ์ ํธ๋ฆฌ(Decision Tree) ์๊ฐ
๊ฒฐ์ ํธ๋ฆฌ
๋ฐ์ดํฐ ๋ง์ด๋์์ ์ผ๋ฐ์ ์ผ๋ก ์ฌ์ฉ๋๋ ๋ฐฉ๋ฒ๋ก
๋ช๋ช ์ ๋ ฅ ๋ณ์๋ฅผ ๋ฐํ์ผ๋ก ๋ชฉํ ๋ณ์์ ๊ฐ์ ์์ธก ํ๋ ๋ชจ๋ธ์ ์์ฑํ๋ ๊ฒ์ด ๋ชฉํ
์ฅ์
์๊ณ ๋ฆฌ์ฆ์ ๋์๊ณผ์ ์ด ์ง๊ด์
ํ์ต ์๊ฐ์ด ๋น ๋ฆ
๊ฐ๋ณ ํน์ง๋ค์ ๊ฐ๋ณ์ ์ผ๋ก ํ๋จํ๋ฏ๋ก ์ ๊ทํ๊ฐ ํ์ํ์ง ์๋ค
๋จ์
์ค๋ฒํผํ ์ ๋น ์ง๊ธฐ ์ฝ๋ค
ํนํ ํธ๋ฆฌ์ ๊น์ด๊ฐ ๊น์ด์ง ์๋ก
๊ตฌํ
sklearn.tree.DecisionTreeClassifer
sklearn.tree.DecisionTreeRegressor
Titanic ์ฌ๊ณ ๋ฐ์ดํฐ ์๊ฐ
1912๋ ํ์ดํ๋ ์ฌ๊ณ ๋น์์ ์น๊ฐ์ ๋ํ ๋ฐ์ดํฐ
Binary Classification
1 : ์์กด
0 : ์ฌ๋ง
๋ฐ์ดํฐ ๊ฐ์ : 891
ํน์ง

๋ฒ์ฃผํ ์ปฌ๋ผ(Categorical Column) & ์์นํ ์ปฌ๋ผ(Numerical Column)
๋ฒ์ฃผํ ์ปฌ๋ผ
๊ฐ์ด [1, 2, 3], ["๋ด๋ถ", "์ธ๋ถ"] ์ ๊ฐ์ด ํ์ ๋๋ ๋ฐ์ดํฐ
[sex, embarked, class, who, adult_male, deck, embark-town, alive, alone]
์์นํ ์ปฌ๋ผ
๊ฐ์ด 1, 2, 3, 5, ... ๋๋ 1.2, 4.51, 3.1415, .. ์ ๊ฐ์ด ์ซ์ ์ถ์ผ๋ก ๋ฌดํํ ์์นํ ์ ์๋ ๋ฐ์ดํฐ
[age, sibsp, parch, fare]
Categorical Column ๋ค๋ฃจ๊ธฐ - LabelEncoder
LabelEncoder
๋จธ์ ๋ฌ๋ ์๊ณ ๋ฆฌ์ฆ์ string ํํ์ ๊ฐ์ ์ฒ๋ฆฌํ ์ ์๋ค. ์ซ์ํ ๊ฐ์ผ๋ก ๋ณ๊ฒฝํด์ค์ผ๋ง ํ๋ฉฐ scikit-learn์์ ์ ๊ณตํ๋
preprocessing.LabelEncoder
ํด๋์ค๋ฅผ ์ด์ฉํด์ string ํํ์ ๊ฐ์ ์ซ์ํ ๊ฐ์ผ๋ก ๋ณ๊ฒฝํ ์ ์๋ค.
>>> from sklearn import preprocessing
>>> le = preprocessing.LabelEncoder()
>>> le.fit([1, 2, 2, 6])
LabelEncoder()
>>> le.classes_
array([1, 2, 6])
>>> le.transform([1, 1, 2, 6])
array([0, 0, 1, 2]...)
>>> le.inverse_transform([0, 0, 1, 2])
array([1, 1, 2, 6])
>>> le = preprocessing.LabelEncoder()
>>> le.fit(["paris", "paris", "tokyo", "amsterdam"])
LabelEncoder()
>>> list(le.classes_)
['amsterdam', 'paris', 'tokyo']
>>> le.transform(["tokyo", "tokyo", "paris"])
array([2, 2, 1]...)
>>> list(le.inverse_transform([2, 2, 1]))
['tokyo', 'tokyo', 'paris']
๊ฒฐ์ ํธ๋ฆฌ(Decision Tree)๋ฅผ ์ด์ฉํด์ ํ์ดํ๋ ์์กด์ ์์ธกํด๋ณด๊ธฐ
์ฌ์ฉ ์๊ณ ๋ฆฌ์ฆ
DecisionTreeClassifier
์ถ๊ฐ์ ์ธ ์ ์ฉ๊ธฐ๋ฒ
EDA, Exploratory Data Analysis
Data Cleansing, ๊ฒฐ์ธก์น ์ฒ๋ฆฌ
df.info()
๋ฐ์ดํฐ ์ปฌ๋ผ๋ณ ํ์ ๊ณผ ๊ฐ์ด ์๋ ํ์ ๊ฐฏ์ ๋ฑ์ ์ ์ ์๋ค
๋ฐ์ดํฐ ๋ถ๋ฌ์ค๊ธฐ
seaborn ๋ผ์ด๋ธ๋ฌ๋ฆฌ ์์ ํ์ดํ๋ ๋ฐ์ดํฐ์ ์ด ์ ์ฅ๋์ด ์๋ค.
titanic_df = sns.load_dataset('titanic')
PART 1. EDA
titanic_df.info()
<class 'pandas.core.frame.DataFrame'>
RangeIndex: 891 entries, 0 to 890
Data columns (total 15 columns):
# Column Non-Null Count Dtype
--- ------ -------------- -----
0 survived 891 non-null int64
1 pclass 891 non-null int64
2 sex 891 non-null object
3 age 714 non-null float64
4 sibsp 891 non-null int64
5 parch 891 non-null int64
6 fare 891 non-null float64
7 embarked 889 non-null object
8 class 891 non-null category
9 who 891 non-null object
10 adult_male 891 non-null bool
11 deck 203 non-null category
12 embark_town 889 non-null object
13 alive 891 non-null object
14 alone 891 non-null bool
dtypes: bool(2), category(2), float64(2), int64(4), object(5)
memory usage: 80.6+ KB
๋ฒ์ฃผํ ์ปฌ๋ผ๊ณผ, ์์นํ ์ปฌ๋ผ์ผ๋ก ๋๋์ด์ ๋ฆฌ์คํธ๋ฅผ ๋ง๋ญ๋๋ค. (์ถํ ๋ถ์ ์ ๋ฐ๋ณต๋๋ ์ฝ๋๋ฅผ ์ค์ผ ์ ์์ด์)
๋ฒ์ฃผํ(categorical) ๋ฐ์ดํฐ๋ ๊ฐ์ด [1, 2, 3], ["๋ด๋ถ", "์ธ๋ถ"]์ ๊ฐ์ด ๋ช ๊ฐ์ง ๋ถ๋ฅ๋ก ํ์ ๋๋ ๋ฐ์ดํฐ ์ ๋๋ค.
์์นํ(numerical) ๋ฐ์ดํฐ๋ ๊ฐ์ด 1,2,3,5,..., 1.2, 4.51, 3.1415์ ๊ฐ์ด ์ซ์ ์ถ์ผ๋ก ๋ฌดํํ ์์นํ ์ ์๋ ๋ฐ์ดํฐ ์ ๋๋ค.
categorical_cols = ["sex", "embarked", "class", "who", "adult_male", "deck", "embark_town", "alive", "alone"]
numerical_cols = ["age","sibsp","parch","fare"]
๋ฐ์ดํฐ์ ํต๊ณ๋ ์ดํด๋ณด๊ธฐ
.describe() ํจ์๋ก ๊ฐ ์ด์ ๋ํ ๋๋ต์ ์ธ ํต๊ณ ๊ฐ๋ค์ ๋ณผ ์ ์์ต๋๋ค. (ํ๊ท , ์์ 25/50/75% ๊ฐ, ์ต๋/์ต์ ๊ฐ ๋ฑ)
titanic_df.describe()
survived
pclass
age
sibsp
parch
fare
count
891.000000
891.000000
714.000000
891.000000
891.000000
891.000000
mean
0.383838
2.308642
29.699118
0.523008
0.381594
32.204208
std
0.486592
0.836071
14.526497
1.102743
0.806057
49.693429
min
0.000000
1.000000
0.420000
0.000000
0.000000
0.000000
25%
0.000000
2.000000
20.125000
0.000000
0.000000
7.910400
50%
0.000000
3.000000
28.000000
0.000000
0.000000
14.454200
75%
1.000000
3.000000
38.000000
1.000000
0.000000
31.000000
max
1.000000
3.000000
80.000000
8.000000
6.000000
512.329200
# .value_counts()๋ฅผ ํตํด ๊ฐ ์ปฌ๋ผ๋ณ๋ก ๋ช ๊ฐ์ row๊ฐ ์๋์ง ์
์ ์์ต๋๋ค
for col in categorical_cols:
print(col + " ์นด์ดํธ::")
print(titanic_df.loc[:, col].value_counts())
print()
sex ์นด์ดํธ::
male 577
female 314
Name: sex, dtype: int64
embarked ์นด์ดํธ::
S 644
C 168
Q 77
Name: embarked, dtype: int64
class ์นด์ดํธ::
Third 491
First 216
Second 184
Name: class, dtype: int64
who ์นด์ดํธ::
man 537
woman 271
child 83
Name: who, dtype: int64
adult_male ์นด์ดํธ::
True 537
False 354
Name: adult_male, dtype: int64
deck ์นด์ดํธ::
C 59
B 47
D 33
E 32
A 15
F 13
G 4
Name: deck, dtype: int64
embark_town ์นด์ดํธ::
Southampton 644
Cherbourg 168
Queenstown 77
Name: embark_town, dtype: int64
alive ์นด์ดํธ::
no 549
yes 342
Name: alive, dtype: int64
alone ์นด์ดํธ::
True 537
False 354
Name: alone, dtype: int64
๋ฐ์ดํฐ์ ๋ถํฌ ๋์ผ๋ก ์ดํด๋ณด๊ธฐ
์์นํ ์ปฌ๋ผ๋ค์ ๋ถํฌ๋ฅผ ๊ทธ๋ ค๋ด ์๋ค. ํต๊ณ๋์ boxplot์ผ๋ก ์ดํด๋ณด๊ณ , ๋ถํฌ๋ histplot์ผ๋ก ๊ทธ๋ฆฝ๋๋ค.
๋ณธ๊ฒฉ์ ์ผ๋ก ๋ฐ๋ณต๋ฌธ์ ์ฌ์ฉํด ๋ณผ๊น์? ์ด ์ฝ๋์์๋ ๋ฐ๋ณต๋ฌธ์ ์ด์ฉํ์ฌ ์ฌ๋ฌ๊ฐ์ ์ฐจํธ๋ฅผ ๊ทธ๋ฆฝ๋๋ค.
plt.subplots๋ฅผ ํตํด ์ฌ๋ฌ ๊ฐ์ ๋ํ์ง๋ฅผ ์์ฑํฉ๋๋ค. (nrows ร ncols)
for๋ฌธ ์์์๋ ๊ฐ ๋ํ์ง(ax)์ seaborn์ผ๋ก ์ฐจํธ๋ฅผ ๊ทธ๋ฆฝ๋๋ค. figure๋ ๊ทธ๋ฆผ ์ ์ฒด๋ฅผ ์๋ฏธํฉ๋๋ค.
figure, ax_list = plt.subplots(nrows=1, ncols=4)
figure.set_size_inches(12,5)
for i in range(4):
col = numerical_cols[i]
sns.boxplot(data=titanic_df, y=col, showfliers=True, ax=ax_list[i])
ax_list[i].set_title(f"distribution '{col}'")

figure, ax_list = plt.subplots(nrows=1, ncols=4)
figure.set_size_inches(12,3)
for i in range(4):
sns.histplot(data=titanic_df.loc[:, numerical_cols[i]], ax=ax_list[i])
ax_list[i].set_title(f"distribution '{numerical_cols[i]}'")

๋ฒ์ฃผํ ์ปฌ๋ผ๋ค์ ๋ถํฌ๋ฅผ ๊ทธ๋ ค๋ด ๋๋ค. ๋ฒ์ฃผํ์ด๋ฏ๋ก countplot์ ํตํด ๊ฐ ๋ฒ์ฃผ๋ณ๋ก ๊ฐ์๋ฅผ ์ ์ ์์ต๋๋ค.
๋ฒ์ฃผํ ์ปฌ๋ผ์ด ์ด 9๊ฐ ์ด๋ฏ๋ก, 3x3 ๋ํ์ง ๋ ์ด์์์ผ๋ก ํ๋์ฉ ๊ทธ๋ํ๋ฅผ ๊ทธ๋ ค๋ด ๋๋ค.
ax_list_list๋ [[], []] ํํ์ 2์ฐจ์ ๋ฆฌ์คํธ ์ ๋๋ค. for ๋ฌธ์ผ๋ก ๋ฐ๋ณตํ๊ธฐ ์ํด 1์ฐจ์ ๋ฆฌ์คํธ๋ก ํ์ด์ค๋๋ค.
1์ฐจ์ ๋ฆฌ์คํธ ax_list๊ฐ 9๊ฐ์ ๋ํ์ง (ax)๋ฅผ ๊ฐ๋๋ก ํ์ด์ ํ ๋นํ๋๋ฐ,
.reshape()
๋ผ๋ numpy ํจ์๋ฅผ ์ฌ์ฉํฉ๋๋ค.
figure, ax_list_list = plt.subplots(nrows=3, ncols=3);
figure.set_size_inches(10,10)
ax_list = ax_list_list.reshape(9) # ๋ค์ฐจ์ ํ๋ ฌ์ ์ฐจ์์ ์ํ๋ ๋ชจ์์ผ๋ก ๋ณ๊ฒฝํฉ๋๋ค.
print(ax_list_list.shape)
print(ax_list.shape)
for i in range(len(categorical_cols)):
col = categorical_cols[i]
sns.countplot(data=titanic_df, x=col, ax=ax_list[i])
ax_list[i].set_title(col)
plt.tight_layout()
(3, 3)
(9,)

๋ฐ์ดํฐ๋ก๋ถํฐ ์ ์๋ฏธํ ์ ๋ณด ๋ฐ๊ตดํ๊ธฐ
์ฌ์ค, ์ฌ๊ธฐ์๋ถํฐ๋ EDA์ ๋ฒ์๋ฅผ ๋์ด์ญ๋๋ค. ๊ทธ๋๋ ํ์น๊ฐ์ '์์กด'์ ์ด๋ค ๊ฒ๋ค์ด ์ํฅ์ ๋ฏธ์น๋์ง ๊ถ๊ธํ์์ฃ ? ๋ช ๊ฐ์ง ๊ฐ์ค์ ์ธ์ฐ๊ณ ๊ทธ๋ํ๋ฅผ ๊ทธ๋ ค '์์กด'์ ์ํฅ์ ๋ฏธ์น๋ ์์ธ์ด ๋ฌด์์ธ์ง ์ดํด๋ด ์๋ค
์ฑ๋ณ๊ณผ ์์กด ์ฌ๋ถ
sns.countplot(data=titanic_df, x='sex', hue='survived');

hue๋ฅผ ์ด์ฉํ์ฌ ๊ทธ๋ํ์์ ํน์ ์ปฌ๋ผ์ ๊ทธ๋ฃน ์ง์ด์ ๋ณผ ์ ์๋ค
์ข์ ๋ฑ๊ธ๊ณผ ์์กด ์ฌ๋ถ
sns.countplot(data=titanic_df, x='pclass', hue='survived');

9๊ฐ์ ๋ฒ์ฃผํ ๋ถ๋ฅ์ ๋ํด, ์์กด ์ฌ๋ถ๋ก ๊ทธ๋ํ ๊ทธ๋ฆฌ๊ธฐ
# hue ์ธ์๋ก 'survived' ์ปฌ๋ผ์ ์
๋ ฅ, ๊ฐ ๋ถ๋ฅํ ๋ฐ์ดํฐ ๋ณ๋ก ์์กด/์ฌ๋ง ๋ถ๋ฆฌํ์ฌ ์ดํด๋ณด๊ธฐ
figure, ax_list_list = plt.subplots(nrows=3, ncols=3);
figure.set_size_inches(10,10)
ax_list = ax_list_list.reshape(9)
print(ax_list_list.shape)
print(ax_list.shape)
for i in range(len(categorical_cols)):
col = categorical_cols[i]
sns.countplot(data=titanic_df, x=col, ax=ax_list[i], hue='survived')
ax_list[i].set_title(col)
plt.tight_layout()
(3, 3)
(9,)

๋จ์ฑ๋ณด๋ค ์ฌ์ฑ์ ์์กด๋ฅ ์ด ๋ ๋์ต๋๋ค (๋จ์ฑ > ์ฌ์ฑ > ์์ด)
ํ์น์ง(embarked)๊ฐ C์ธ ๊ฒฝ์ฐ ์์กด์จ์ด ๋์ต๋๋ค
1๋ฑ์ > 2๋ฑ์ > 3๋ฑ์ ์์ผ๋ก ์์กด์จ์ด ๋์ต๋๋ค
B,D,E ๋ฑ ์์น์ ์น๊ฐ๋ค์ด ์์กด์จ์ด ๋์ต๋๋ค
๋ํ๋ก ์น๊ฐ์ ์์กด์จ์ด ๋ฎ์ต๋๋ค
์์กด ์ฌ๋ถ๋ณ๋ก ๋์ด์ ํ์คํ ๊ทธ๋จ ๊ทธ๋ ค๋ณด๊ธฐ
sns.histplot(data=titanic_df, x='age', hue='survived', bins=30, alpha=0.3);

์ฑ๋ณ๊ณผ ์ข์ ๋ฑ๊ธ์ ๋ฐ๋ผ, ๋์ด์ boxplot ๊ทธ๋ ค๋ณด๊ธฐ
sns.boxplot(data=titanic_df, x='sex', y='age', hue='pclass');

Part2. Decision Tree๋ก ํ์ดํ๋ ์์กด์ ์์ธกํ๊ธฐ
๊ฒฐ์ธก์น ์ฑ์ฐ๊ธฐ
titanic_df.info()
<class 'pandas.core.frame.DataFrame'>
RangeIndex: 891 entries, 0 to 890
Data columns (total 15 columns):
# Column Non-Null Count Dtype
--- ------ -------------- -----
0 survived 891 non-null int64
1 pclass 891 non-null int64
2 sex 891 non-null object
3 age 714 non-null float64
4 sibsp 891 non-null int64
5 parch 891 non-null int64
6 fare 891 non-null float64
7 embarked 889 non-null object
8 class 891 non-null category
9 who 891 non-null object
10 adult_male 891 non-null bool
11 deck 203 non-null category
12 embark_town 889 non-null object
13 alive 891 non-null object
14 alone 891 non-null bool
dtypes: bool(2), category(2), float64(2), int64(4), object(5)
memory usage: 80.6+ KB
# numerical value
titanic_df['age'].fillna(titanic_df['age'].mean(), inplace=True)
# categorical value
titanic_df['deck'].fillna(titanic_df['deck'].describe()['top'], inplace=True)
titanic_df['embarked'].fillna(titanic_df['embarked'].describe()['top'], inplace=True)
titanic_df
survived
pclass
sex
age
sibsp
parch
fare
embarked
class
who
adult_male
deck
embark_town
alive
alone
0
0
3
male
22.000000
1
0
7.2500
S
Third
man
True
C
Southampton
no
False
1
1
1
female
38.000000
1
0
71.2833
C
First
woman
False
C
Cherbourg
yes
False
2
1
3
female
26.000000
0
0
7.9250
S
Third
woman
False
C
Southampton
yes
True
3
1
1
female
35.000000
1
0
53.1000
S
First
woman
False
C
Southampton
yes
False
4
0
3
male
35.000000
0
0
8.0500
S
Third
man
True
C
Southampton
no
True
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
886
0
2
male
27.000000
0
0
13.0000
S
Second
man
True
C
Southampton
no
True
887
1
1
female
19.000000
0
0
30.0000
S
First
woman
False
B
Southampton
yes
True
888
0
3
female
29.699118
1
2
23.4500
S
Third
woman
False
C
Southampton
no
False
889
1
1
male
26.000000
0
0
30.0000
C
First
man
True
C
Cherbourg
yes
True
890
0
3
male
32.000000
0
0
7.7500
Q
Third
man
True
C
Queenstown
no
True
๋ฒ์ฃผํ ๋ชจ๋ธ์ ๋ชจ๋ธ์์ ์๋ํ ์์์ผ๋ฏ๋ก sklearn์ preprocessing์ ์ด์ฉํ์ฌ ๋ฒ์ฃผํ ๋ฐ์ดํฐ๋ฅผ ์์นํํ๋ค
from sklearn import preprocessing
le = preprocessing.LabelEncoder()
titanic_df['sex'] = le.fit(titanic_df['sex']).transform(titanic_df['sex'])
titanic_df['adult_male'] = le.fit(titanic_df['adult_male']).transform(titanic_df['adult_male'])
titanic_df['alone'] = le.fit(titanic_df['alone']).transform(titanic_df['alone'])
titanic_df['embarked'] = le.fit(titanic_df['embarked']).transform(titanic_df['embarked'])
titanic_df['deck'] = le.fit(titanic_df['deck']).transform(titanic_df['deck'])
titanic_df['who'] = le.fit(titanic_df['who']).transform(titanic_df['who'])
titanic_df
survived
pclass
sex
age
sibsp
parch
fare
embarked
class
who
adult_male
deck
embark_town
alive
alone
0
0
3
1
22.000000
1
0
7.2500
2
Third
1
1
2
Southampton
no
0
1
1
1
0
38.000000
1
0
71.2833
0
First
2
0
2
Cherbourg
yes
0
2
1
3
0
26.000000
0
0
7.9250
2
Third
2
0
2
Southampton
yes
1
3
1
1
0
35.000000
1
0
53.1000
2
First
2
0
2
Southampton
yes
0
4
0
3
1
35.000000
0
0
8.0500
2
Third
1
1
2
Southampton
no
1
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
886
0
2
1
27.000000
0
0
13.0000
2
Second
1
1
2
Southampton
no
1
887
1
1
0
19.000000
0
0
30.0000
2
First
2
0
1
Southampton
yes
1
888
0
3
0
29.699118
1
2
23.4500
2
Third
2
0
2
Southampton
no
0
889
1
1
1
26.000000
0
0
30.0000
0
First
1
1
2
Cherbourg
yes
1
890
0
3
1
32.000000
0
0
7.7500
1
Third
1
1
2
Queenstown
no
1
891 rows ร 15 columns
# drop duplicated columns
drop_cols = ["class", "embark_town", "alive"]
titanic_df = titanic_df.drop(drop_cols, axis=1)
titanic_df
survived
pclass
sex
age
sibsp
parch
fare
embarked
who
adult_male
deck
alone
0
0
3
1
22.000000
1
0
7.2500
2
1
1
2
0
1
1
1
0
38.000000
1
0
71.2833
0
2
0
2
0
2
1
3
0
26.000000
0
0
7.9250
2
2
0
2
1
3
1
1
0
35.000000
1
0
53.1000
2
2
0
2
0
4
0
3
1
35.000000
0
0
8.0500
2
1
1
2
1
...
...
...
...
...
...
...
...
...
...
...
...
...
886
0
2
1
27.000000
0
0
13.0000
2
1
1
2
1
887
1
1
0
19.000000
0
0
30.0000
2
2
0
1
1
888
0
3
0
29.699118
1
2
23.4500
2
2
0
2
0
889
1
1
1
26.000000
0
0
30.0000
0
1
1
2
1
890
0
3
1
32.000000
0
0
7.7500
1
1
1
2
1
ํธ๋ ์ด๋ ๋ฐ์ดํฐ ์ค๋นํ๊ธฐ
X = titanic_df.iloc[:,1:]
y = titanic_df['survived']
# 80%๋ ํธ๋ ์ด๋ ๋ฐ์ดํฐ, 20%๋ ํ
์คํธ ๋ฐ์ดํฐ๋ก ๋๋๋๋ค.
X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.2)
from sklearn.tree import DecisionTreeClassifier
dt_clf = DecisionTreeClassifier()
dt_clf.fit(X_train, y_train)
y_pred = dt_clf.predict(X_test)
print('์์ธก ์ ํ๋: %.2f' % accuracy_score(y_test, y_pred))
์์ธก ์ ํ๋: 0.81
Last updated
Was this helpful?