Model Validation in Python
Kasey Jones
Data Scientist
... | Bottom-Left | Bottom-Middle | Bottom-Right | Class |
---|---|---|---|---|
... | X | O | O | positive |
... | O | X | O | positive |
... | O | O | X | positive |
... | X | X | O | negative |
... | ... | ... | ... | ... |
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
rfc.predict_proba(X_test)
array([[0. , 1. ],
[0.1, 0.9],
[0.1, 0.9],
...])
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
Model Validation in Python