n_estimators가 영향을 미치는 Random Forest Regressor 성능을 확인하려고합니다.임의의 Forest Regressor- Python이 재생성되지 않습니다.
seed = np.random.seed(1962)
rng = np.random.RandomState(1962)
np.random.seed(1962)
estimators = [pow(2,3),10,pow(2,4),pow(2,5),pow(2,6),pow(2,7),pow(2,8),500,pow(2,9),pow(2,10),pow(2,11)]
#oob_train = {}
train_acc = {}
test_acc = {}
for w in range(0,len(estimators),1):
modelrfe = RandomForestRegressor(n_estimators = estimators[w],random_state=rng, n_jobs = -1)
model_params = estimators[w]
modelrfe.fit(train_x1,train_y1)
train_acc[model_params] = mean_absolute_error(scale_data.inverse_transform(train_y1.reshape(-1,1)),scale_data.inverse_transform(modelrfe.predict(train_x1).reshape(-1,1)))
test_acc[model_params] = mean_absolute_error(scale_data.inverse_transform(test_y1.reshape(-1,1)),scale_data.inverse_transform(modelrfe.predict(test_x1).reshape(-1,1)))
train_acc = pd.DataFrame(train_acc.items())
train_acc.columns = ['keys','Trainerror']
test_acc = pd.DataFrame(test_acc.items())
test_acc.columns = ['keys','Testerror']
error_df3 = pd.merge(train_acc, test_acc, on='keys')
error_df3 = pd.DataFrame(error_df3)
재현 할 수 없습니다. 처음에는 rng도 정의했습니다.
참고 : For 루프를 1 : Nrow (데이터 프레임)라고 가정하면 여러 모델을 통과합니다. & For 루프의 시작 부분에 r시드를 정의했습니다.
도와주세요! .
2 출력이 이상적이었습니다. 여기에 키는 n_estimators를 참조
[여기 이미지 설명을 입력합니다] [시뮬레이션 1] [여기 이미지 설명을 입력합니다] [시뮬레이션 2]
이미지 첨부를 잊었습니다. 또한, [MCVE] (https://stackoverflow.com/help/mcve) –
긴 코드를 제공 할 수 있다면 더 좋을 것입니다. 그래서 나는 관련성을 추가하지 않았습니다. Algo에 대해 random_state 변수를 사용하는 것과 같이 재현성있게 만들기 위해 Algo에 대해 묻습니다. –