ValueError: Input 0 of layer "sequential" is incompatible with the layer: expected shape=(None, 100, 1), found shape=(None, 21)
LSTM 다룰 때 중요한 부분! 에러 ValueError: Input 0 of layer "sequential" is incompatible with the layer: expected shape=(None, 100, 1), found shape=(None, 21) 원인 LSTM 모델을 사용할 때는, train 차원을 바꾸어야 하는데, 차원 변경을 해 주지 않으면 발생하는 에러 해결 X_train = X_train.reshape(X_train.shape[0], X_train[1], 1) 명령으로 2차원 데이터를 3차원으로 변경하면 됨.
2022. 1. 20.
GridSearchCV 평가 - 최적 파라미터 출력
코드 from sklearn.model_selection import GridSearchCV params = { 'n_estimators':[100], 'max_depth' : [6,8,10.,12], 'min_samples_leaf' : [8,12, 18], 'min_samples_split' : [8,16, 20] } rf_clf = RandomForestClassifier(random_state=0) model = rf_clf grid_cv = GridSearchCV(model, param_grid=params, cv=2, n_jobs=-1) grid_cv.fit(X_train, y_train) print('Best parameter:\n', grid_cv.best_params_) print('Hi..
2022. 1. 17.
def roc_curve_plot() 함수 코드
def roc_curve_plot(y_test, pred_proba_c1): fprs, tprs, thresholds = roc_curve(y_test, pred_proba_c1) plt.plot(fprs, tprs, label='ROC') plt.plot([0,1], [0,1], 'k--', label='Random') start, end = plt.xlim() plt.xticks(np.round(np.arange(start, end, 0.1), 2)) plt.xlim(0,1);plt.ylim(0,1) plt.xlabel('FPR( 1 - sensitivity )'); plt.ylabel('TPR( Recall )') plt.legend()
2022. 1. 17.