# Logistic Regression
from sklearn.linear_model import LogisticRegression
lgr = LogisticRegression()
# training
lgr.fit(X_train, y_train)
lgr.coef_
array([[-1.74894748e+00, 2.05970508e+00, 6.90864943e-01,
-1.13234564e+00, 5.70392800e-01, -1.52202120e-03,
3.35484430e-01, 2.87431155e-01, 1.24852192e-01,
6.05941756e-01]])
lgr.intercept_
array([-0.489761])
상대적으로 .coef_ 값이 큰 첫 번째, 두 번째
feature에 대해서 label을 color로 주고 scatter
plot을 그려보자
# Logistic Regression
from sklearn.linear_model import LogisticRegression
lgr = LogisticRegression()
# training
lgr.fit(X_train, y_train)
lgr.coef_
array([[-1.74894748e+00, 2.05970508e+00, 6.90864943e-01,
-1.13234564e+00, 5.70392800e-01, -1.52202120e-03,
3.35484430e-01, 2.87431155e-01, 1.24852192e-01,
6.05941756e-01]])
# Support Vector Machines (SVM)
from sklearn.svm import SVC
svc = SVC(kernel='linear')
# training
svc.fit(X, y)
svc.coef_
array([[-1.10086514, 0.96241273, 0.45270636, -0.46822568,
0.21103224,
0.24624928, 0.21930329, -0.13029874, -0.22471887,
0.43350556]])
# Logistic Regression
from sklearn.linear_model import LogisticRegression
lgr = LogisticRegression()
# training
lgr.fit(X_train, y_train)
lgr.coef_
array([[-1.74894748e+00, 2.05970508e+00, 6.90864943e-01,
-1.13234564e+00, 5.70392800e-01, -1.52202120e-03,
3.35484430e-01, 2.87431155e-01, 1.24852192e-01,
6.05941756e-01]])
# Random forest classifier
from sklearn.ensemble import RandomForestClassifier
rfc= RandomForestClassifier(n_estimators=100, max_depth=200)
# training
rfc.fit(X, y)
rfc.feature_importances_
array([0.25357745, 0.26571728, 0.09979086, 0.17900508,
0.02387162,
0.02279699, 0.02225427, 0.04759967, 0.02854178, 0.056845
])