+ 1

test case of random forest

why is there hidden test cases which are problematic with my random forest code: import numpy as np import pandas as pd from sklearn.ensemble import RandomForestClassifier from sklearn.model_selection import train_test_split randomState = int(input()) n = int(input()) rows = [] for i in range(n): rows.append([float(a) for a in input().split()]) X = np.array(rows) y = np.array([int(a) for a in input().split()]) X_train,X_test,y_train,y_test=train_test_split(X,y,test_size=0.3, random_state=randomState) sra=RandomForestClassifier(n_estimators=5,random_state=randomState) sra.fit(X_train,y_train) print(sra.predict(X_test))

17th Jan 2022, 8:16 AM
sara
sara - avatar
1 Respuesta
0
I dont know why...my answer is very similar but this piece of code is some different X_train, X_test, y_train, y_test = train_test_split(X, y, random_state=random_state)
26th Jan 2022, 4:06 AM
Cristian Baeza Jimenez
Cristian Baeza Jimenez - avatar