UBISS2024exam: Difference between revisions

From Sketching with Hardware at LMU Wiki
Jump to navigation Jump to search
No edit summary
No edit summary
Line 3: Line 3:
#
#
#
#
from sklearn.model_selection import train_test_split
from everywhereml.sklearn.ensemble import RandomForestClassifier


#Comment here:
#Comment here:
#
#
#
#
X = df[["X", "Y", "Z"]].diff().iloc[1:].values
max_leaf_nodes = 30
 
 
#Comment here:
#
#
clf = RandomForestClassifier(n_estimators=100, max_leaf_nodes=max_leaf_nodes)


#Comment here:
#Comment here:
#
#
#
#
y = df.Label.iloc[1:].values
clf.fit(X_train, y_train)


#Comment here:
#Comment here:
#
#
#
#
X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.3)
print(f'Score: {clf.score(X_test, y_test):3.3f}')
</syntaxhighlight>
</syntaxhighlight>

Revision as of 13:40, 13 June 2024

#Comment here:
#
#
from everywhereml.sklearn.ensemble import RandomForestClassifier

#Comment here:
#
#
max_leaf_nodes = 30


#Comment here:
#
#
clf = RandomForestClassifier(n_estimators=100, max_leaf_nodes=max_leaf_nodes)

#Comment here:
#
#
clf.fit(X_train, y_train)

#Comment here:
#
#
print(f'Score: {clf.score(X_test, y_test):3.3f}')