{ "cells": [ { "cell_type": "markdown", "metadata": { "toc": true }, "source": [ "# WS 14 Random Search CV" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "* untersuchen Sie Kombinationen von Parameterwerten bei RandomForestClassifier\n", "* Vorschlag:\n", " * n_estimators in [50, 100, 150, 200]\n", " * max_features in [3, 5, 7, 9]\n", " * criterion in ['gini', 'entropy']\n", " * min_samples_leaf in [1, 2, 3, 4]\n", "* wenden Sie 5-fach Kreuzvalidierung an\n", "* setzen Sie die Anzahl der zu untersuchenden Kombinationen auf 12\n", "* arbeiten Sie ohne setzen von random_state, damit anschliessend die Ergebnisse verglichen werden können" ] }, { "cell_type": "code", "execution_count": 3, "metadata": {}, "outputs": [], "source": [ "## import libraries\n", "import pandas as pd\n", "import numpy as np\n", "\n", "## load data\n", "datapath = '../3_data'\n", "from os import chdir; chdir(datapath)\n", "bank_df = pd.read_csv('bank_data_prep.csv')\n", "\n", "## features - target - split\n", "X = bank_df.drop('y', axis=1)\n", "y = bank_df['y']" ] }, { "cell_type": "code", "execution_count": 4, "metadata": {}, "outputs": [], "source": [ "## import classes from sklearn\n", "from sklearn.ensemble import RandomForestClassifier\n", "from sklearn.model_selection import RandomizedSearchCV\n", "\n", "## define parameter grid\n", "## tbd\n", "#parameter_grid = ...\n", "\n", "\n", "\n", "## define RandomizedSearchCV\n", "## tbd\n", "\n", "\n", "\n", "## run RandomizedSearchCV\n", "## tbd\n", "\n", "\n", "\n", "## evaluate RandomizedSearchCV\n", "## tbd\n", "\n", "\n" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "**Fazit:**\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": "", "nav_menu": {}, "number_sections": true, "sideBar": true, "skip_h1_title": false, "title_cell": "WS 17 Validierung - Random Search CV", "title_sidebar": "Contents", "toc_cell": true, "toc_position": { "height": "calc(100% - 180px)", "left": "10px", "top": "150px", "width": "195.867px" }, "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()) " } }, "position": { "height": "306.85px", "left": "862px", "right": "20px", "top": "137px", "width": "350px" }, "types_to_exclude": [ "module", "function", "builtin_function_or_method", "instance", "_Feature" ], "window_display": false } }, "nbformat": 4, "nbformat_minor": 4 }