166 lines
3.8 KiB
Plaintext
166 lines
3.8 KiB
Plaintext
{
|
|
"cells": [
|
|
{
|
|
"cell_type": "markdown",
|
|
"metadata": {
|
|
"toc": true
|
|
},
|
|
"source": [
|
|
"# WS 05 Klassifikation - DecisionTreeClassifier "
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "markdown",
|
|
"metadata": {},
|
|
"source": [
|
|
"* untersuchen Sie verschiedene Werte von min_impurity_decrease bei DecisionTreeClassifier auf die erreichbare Performance (Accuracy)\n",
|
|
"* grenzen Sie dabei den zu untersuchenden Wertebereich schrittweise ein\n",
|
|
"* stellen Sie dazu die Ergebnisse wie folgt dar\n",
|
|
" * grafisch als Liniendiagramm\n",
|
|
" * in der Konsole mit bestem Score und entsprechendem Parameterwert\n",
|
|
"* Hinweis\n",
|
|
" * `range()`: erstellt einen Bereich von Ganzzahligen Werten mit identischer Schrittweite\n",
|
|
" * `np.arange()`: (Funktion von numpy) erstellt mit analoger Parametrisierung einen Bereich mit Gleitkommawerten"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": 3,
|
|
"metadata": {},
|
|
"outputs": [],
|
|
"source": [
|
|
"## prepare env, read and prepare data\n",
|
|
"import pandas as pd\n",
|
|
"import numpy as np\n",
|
|
"import matplotlib.pyplot as plt\n",
|
|
"import seaborn as sns\n",
|
|
"\n",
|
|
"sns.set()\n",
|
|
"\n",
|
|
"codepath = '../2_code' ## for import of user defined module\n",
|
|
"datapath = '../3_data'\n",
|
|
"\n",
|
|
"from sys import path\n",
|
|
"path.insert(1, codepath)\n",
|
|
"\n",
|
|
"from os import chdir\n",
|
|
"chdir(datapath)\n",
|
|
"\n",
|
|
"from bfh_cas_pml import prep_data\n",
|
|
"\n",
|
|
"X_train, X_test, y_train, y_test = prep_data('bank_data_prep.csv',\n",
|
|
" target='y',\n",
|
|
" seed=1234)"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": 4,
|
|
"metadata": {
|
|
"scrolled": true,
|
|
"tags": []
|
|
},
|
|
"outputs": [
|
|
{
|
|
"name": "stdout",
|
|
"output_type": "stream",
|
|
"text": [
|
|
"0.0\n",
|
|
"0.01\n",
|
|
"0.02\n",
|
|
"0.03\n",
|
|
"0.04\n",
|
|
"0.05\n",
|
|
"0.06\n",
|
|
"0.07\n",
|
|
"0.08\n",
|
|
"0.09\n"
|
|
]
|
|
}
|
|
],
|
|
"source": [
|
|
"from sklearn.tree import DecisionTreeClassifier\n",
|
|
"model = DecisionTreeClassifier()\n",
|
|
"\n",
|
|
"scores = []\n",
|
|
"params = np.arange(0, 0.1, 0.01)\n",
|
|
"\n",
|
|
"for param in params:\n",
|
|
" print(param)\n",
|
|
" ## tbd\n",
|
|
" \n",
|
|
"\n",
|
|
" "
|
|
]
|
|
}
|
|
],
|
|
"metadata": {
|
|
"kernelspec": {
|
|
"display_name": "Python 3 (ipykernel)",
|
|
"language": "python",
|
|
"name": "python3"
|
|
},
|
|
"language_info": {
|
|
"codemirror_mode": {
|
|
"name": "ipython",
|
|
"version": 3
|
|
},
|
|
"file_extension": ".py",
|
|
"mimetype": "text/x-python",
|
|
"name": "python",
|
|
"nbconvert_exporter": "python",
|
|
"pygments_lexer": "ipython3",
|
|
"version": "3.11.7"
|
|
},
|
|
"toc": {
|
|
"base_numbering": "0",
|
|
"nav_menu": {},
|
|
"number_sections": true,
|
|
"sideBar": true,
|
|
"skip_h1_title": false,
|
|
"title_cell": "WS 08 Klassifikation - DecisionTreeClassifier",
|
|
"title_sidebar": "Contents",
|
|
"toc_cell": true,
|
|
"toc_position": {
|
|
"height": "calc(100% - 180px)",
|
|
"left": "10px",
|
|
"top": "150px",
|
|
"width": "165px"
|
|
},
|
|
"toc_section_display": true,
|
|
"toc_window_display": true
|
|
},
|
|
"varInspector": {
|
|
"cols": {
|
|
"lenName": 16,
|
|
"lenType": 16,
|
|
"lenVar": 40
|
|
},
|
|
"kernels_config": {
|
|
"python": {
|
|
"delete_cmd_postfix": "",
|
|
"delete_cmd_prefix": "del ",
|
|
"library": "var_list.py",
|
|
"varRefreshCmd": "print(var_dic_list())"
|
|
},
|
|
"r": {
|
|
"delete_cmd_postfix": ") ",
|
|
"delete_cmd_prefix": "rm(",
|
|
"library": "var_list.r",
|
|
"varRefreshCmd": "cat(var_dic_list()) "
|
|
}
|
|
},
|
|
"types_to_exclude": [
|
|
"module",
|
|
"function",
|
|
"builtin_function_or_method",
|
|
"instance",
|
|
"_Feature"
|
|
],
|
|
"window_display": false
|
|
}
|
|
},
|
|
"nbformat": 4,
|
|
"nbformat_minor": 4
|
|
}
|