분류 모델

Python에서의 모델 검증

Kasey Jones

Data Scientist

분류 모델

  • 범주형 반응:
    • 신생아의 머리 색
    • 농구 경기 승자
    • 라디오에서 다음 곡의 장르
Python에서의 모델 검증

틱택토 데이터셋

... 좌하 하단-가운데 우하 클래스
... X O O positive
... O X O positive
... O O X positive
... X X O negative
... ... ... ... ...
Python에서의 모델 검증

원하시면 Google에서 틱택토를 플레이할 수 있습니다. Google에서 Tic-Tac-Toe를 검색하세요.

Python에서의 모델 검증

.predict()로 분류하기

from sklearn.ensemble import RandomForestClassifier
rfc = RandomForestClassifier(random_state=1111)
rfc.fit(X_train, y_train)
rfc.predict(X_test)
array([1, 1, 1, 1, 0, 1, ...])
pd.Series(rfc.predict(X_test)).value_counts()
1    627
0    331
Python에서의 모델 검증

확률 예측하기

rfc.predict_proba(X_test)
array([[0. , 1. ],
       [0.1, 0.9],
       [0.1, 0.9],
       ...])
Python에서의 모델 검증
rfc = RandomForestClassifier(random_state=1111)
rfc.get_params()
{'bootstrap': True,
 'class_weight': None,
 'criterion': 'gini',
 ...}
rfc.fit(X_train, y_train)
rfc.score(X_test, y_test)
0.8989
Python에서의 모델 검증

틱택토 종료 상황을 분류해봅시다

Python에서의 모델 검증

Preparing Video For Download...