intial commit (forked from private repo)
This commit is contained in:
14
extracted_cells/cell22.py
Normal file
14
extracted_cells/cell22.py
Normal file
@ -0,0 +1,14 @@
|
||||
from sklearn.tree import DecisionTreeClassifier, export_text
|
||||
|
||||
# Random Forest-Vorhersagen verwenden als Ziel
|
||||
rf_predictions = rf_model.predict(X_train)
|
||||
|
||||
# Einfachen Entscheidungsbaum auf die Vorhersagen des Random Forests trainieren
|
||||
surrogate_tree = DecisionTreeClassifier(max_depth=5)
|
||||
surrogate_tree.fit(X_train, rf_predictions)
|
||||
|
||||
# Evaluieren, wie gut der Baum den Random Forest approximiert
|
||||
surrogate_predictions = surrogate_tree.predict(X_test)
|
||||
rf_test_predictions = rf_model.predict(X_test)
|
||||
surrogate_accuracy = np.mean(surrogate_predictions == rf_test_predictions)
|
||||
print(f"Genauigkeit des Surrogate-Modells: {surrogate_accuracy:.4f}")
|
||||
Reference in New Issue
Block a user