ac50 classification 모델을 만드는 중
6개 assay에 대해서 각각 model1(SVM poly), model2(SVM RBF), model3(RF) 로 학습을 시키고 test set에 대한 결과를 얻어내기 위해 다음과 같이 코드를 짰다.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
|
from sklearn.ensemble import RandomForestClassifier
for i in assays :
X_all = X[ dataframe[i].isnull() == False ]
Y_all= dataframe[i][dataframe[i].isnull() == False]
p = 0.8
X_test = X_all[int(n*p):]
Y_test = Y_all[int(n*p):]
X_train = X_all[:int(n*p)]
Y_train = Y_all[:int(n*p)]
model2 = SVC(kernel='poly', random_state=0,
gamma=10, C=1.0).fit(X_train, Y_train)
model3 = SVC(kernel='rbf', random_state=0, gamma=1,
C=1.0).fit(X_train, Y_train)
model4 = RandomForestClassifier(max_depth=2, n_estimators=100, random_state=0)
# model5 = create_dnn_model()
df[i] = [ model2.score(X_test,Y_test),
1]
http://colorscripter.com/info#e" target="_blank" style="color:#e5e5e5text-decoration:none">Colored by Color Scripter
|
http://colorscripter.com/info#e" target="_blank" style="text-decoration:none;color:white">cs |
모델 fit 함수와 score함수를 for 문 안에 넣었다. 그런데 코드가 수월하게 실행이 되지 않고...멈춘다.
그래서 for문을 제외하고 .
각각 1개 assay씩 돌려 보았는데 잘 되었다.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
|
from sklearn.ensemble import RandomForestClassifier
i = assays[2]
X_all = X[ dataframe[i].isnull() == False ]
Y_all= dataframe[i][dataframe[i].isnull() == False]
p = 0.8
X_test = X_all[int(n*p):]
Y_test = Y_all[int(n*p):]
X_train = X_all[:int(n*p)]
Y_train = Y_all[:int(n*p)]
model2 = SVC(kernel='poly', random_state=0,
gamma=10, C=1.0).fit(X_train, Y_train)
model3 = SVC(kernel='rbf', random_state=0, gamma=1,
C=1.0).fit(X_train, Y_train)
model4 = RandomForestClassifier(max_depth=2, n_estimators=100, random_state=0)
# model5 = create_dnn_model()
df[i] = [ model2.score(X_test,Y_test),
1]
http://colorscripter.com/info#e" target="_blank" style="color:#e5e5e5text-decoration:none">Colored by Color Scripter
|
http://colorscripter.com/info#e" target="_blank" style="text-decoration:none;color:white">cs |
문제가 무럭아? 왜 for문을 사용하면 수월하게 되지 않는가?
너무 빨라서? 그럼 시간 간격을 줘 볼까? 그럼 되러냐.