view test-data/scikit-script.py @ 2:bf2963c9bcdc draft default tip

planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/jupyter_job commit c21261bb8373090c26cf5195134b30538b5bc714
author bgruening
date Fri, 20 Jan 2023 10:49:03 +0000
parents f4619200cb0a
children
line wrap: on
line source

# Train a model.
from sklearn.datasets import load_iris
from sklearn.ensemble import RandomForestClassifier
from sklearn.model_selection import train_test_split

iris = load_iris()
X, y = iris.data, iris.target
X, y = X[:20], y[:20]
loss = list()
X_train, X_test, y_train, y_test = train_test_split(X, y)
clr = RandomForestClassifier(n_estimators=5)
clr.fit(X_train, y_train)
clr.score(X_test, y_test)