update
parent
4d0cdf876f
commit
6ad5a5ec25
|
@ -144,24 +144,23 @@
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"source": [
|
"source": [
|
||||||
"# Schritt 1: Importiere die notwendigen Bibliotheken\n",
|
"\n",
|
||||||
"from sklearn.tree import DecisionTreeClassifier\n",
|
"from sklearn.tree import DecisionTreeClassifier\n",
|
||||||
"from sklearn.metrics import accuracy_score\n",
|
"from sklearn.metrics import accuracy_score\n",
|
||||||
"\n",
|
"\n",
|
||||||
"# Schritt 2: Erstelle das Decision Tree Modell\n",
|
"\n",
|
||||||
"# Beispiel: Begrenzung der Tiefe des Baumes\n",
|
"# Beispiel: Begrenzung der Tiefe des Baumes\n",
|
||||||
"dt_classifier = DecisionTreeClassifier(max_depth=5)\n",
|
"dt_classifier = DecisionTreeClassifier(max_depth=5)\n",
|
||||||
"\n",
|
"\n",
|
||||||
"# Schritt 3: Trainiere das Modell\n",
|
"# Schritt 3: Trainieren des Modells mit Trainingsdaten\n",
|
||||||
"dt_classifier.fit(train_x, train_y)\n",
|
"dt_classifier.fit(train_x, train_y)\n",
|
||||||
"\n",
|
"\n",
|
||||||
"# Schritt 4: Vorhersagen und Auswertung auf den Validierungsdaten\n",
|
"# Schritt 4: Bewertung des Modells mit Validierungsdaten\n",
|
||||||
"valid_pred = dt_classifier.predict(valid_x)\n",
|
"valid_pred = dt_classifier.predict(valid_x)\n",
|
||||||
"valid_accuracy = accuracy_score(valid_y, valid_pred)\n",
|
"valid_accuracy = accuracy_score(valid_y, valid_pred)\n",
|
||||||
"print(f'Validierungsgenauigkeit: {valid_accuracy}')\n",
|
"print(f'Validierungsgenauigkeit: {valid_accuracy}')\n",
|
||||||
"\n",
|
"\n",
|
||||||
"# Optional: Tuning des Modells basierend auf den Validierungsergebnissen\n",
|
"# Schritt 5: Hyperparameter-Optimierung\n",
|
||||||
"# Experimentiere mit verschiedenen Parametern und trainiere bei Bedarf neu\n",
|
|
||||||
"\n",
|
"\n",
|
||||||
"# Schritt 6: Endgültige Bewertung mit Testdaten\n",
|
"# Schritt 6: Endgültige Bewertung mit Testdaten\n",
|
||||||
"test_pred = dt_classifier.predict(test_x)\n",
|
"test_pred = dt_classifier.predict(test_x)\n",
|
||||||
|
|
Loading…
Reference in New Issue