basic Python question

joseph pareti joepareti54 at gmail.com
Fri May 8 15:02:00 EDT 2020


In general I prefer doing:


X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.33,
random_state=42) clf = RandomForestClassifier(n_estimators = 100, max_depth=
None) *clf_f = clf.fit(X_train, y_train)* predicted_labels = clf_f.predict(
X_test) score = clf.score(X_test, y_test) score1 = metrics.accuracy_score(
y_test, predicted_labels)






rather than:

X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.33,
random_state=42) clf0=RandomForestClassifier(n_estimators=100, max_depth=
None) *clf0.fit(X_train, y_train)* y_pred =clf0.predict(X_test) score=
metrics.accuracy_score(y_test, y_pred)














Are the two codes really equivalent?
-- 
Regards,
Joseph Pareti - Artificial Intelligence consultant
Joseph Pareti's AI Consulting Services
https://www.joepareti54-ai.com/
cell +49 1520 1600 209
cell +39 339 797 0644


More information about the Python-list mailing list