{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# Hyperparameters and Parameters\n", "> In this introductory chapter you will learn the difference between hyperparameters and parameters. You will practice extracting and analyzing parameters, setting hyperparameter values for several popular machine learning algorithms. Along the way you will learn some best practice tips & tricks for choosing which hyperparameters to tune and what values to set & build learning curves to analyze your hyperparameter choices. This is the Summary of lecture \"Hyperparameter Tuning in Python\", via datacamp.\n", "\n", "- toc: true \n", "- badges: true\n", "- comments: true\n", "- author: Chanseok Kang\n", "- categories: [Python, Datacamp, Machine_Learning]\n", "- image: images/accuracy_learning_curve.png" ] }, { "cell_type": "code", "execution_count": 1, "metadata": {}, "outputs": [], "source": [ "import numpy as np\n", "import pandas as pd\n", "import matplotlib.pyplot as plt" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Introduction\n", "- Parameters\n", " - Components of the model learned during the modeling process\n", " - Do not set these manually\n" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### Extracting a Logistic Regression parameter\n", "You are now going to practice extracting an important parameter of the logistic regression model. The logistic regression has a few other parameters you will not explore here but you can review them in the [scikit-learn.org](https://scikit-learn.org/) documentation for the `LogisticRegression()` module under 'Attributes'.\n", "\n", "This parameter is important for understanding the direction and magnitude of the effect the variables have on the target.\n", "\n", "In this exercise we will extract the coefficient parameter (found in the `coef_` attribute), zip it up with the original column names, and see which variables had the largest positive effect on the target variable." ] }, { "cell_type": "code", "execution_count": 2, "metadata": {}, "outputs": [ { "data": { "text/html": [ "
\n", " | ID | \n", "LIMIT_BAL | \n", "AGE | \n", "PAY_0 | \n", "PAY_2 | \n", "PAY_3 | \n", "PAY_4 | \n", "PAY_5 | \n", "PAY_6 | \n", "BILL_AMT1 | \n", "... | \n", "SEX_2 | \n", "EDUCATION_1 | \n", "EDUCATION_2 | \n", "EDUCATION_3 | \n", "EDUCATION_4 | \n", "EDUCATION_5 | \n", "EDUCATION_6 | \n", "MARRIAGE_1 | \n", "MARRIAGE_2 | \n", "MARRIAGE_3 | \n", "
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
0 | \n", "1 | \n", "20000 | \n", "24 | \n", "2 | \n", "2 | \n", "-1 | \n", "-1 | \n", "-2 | \n", "-2 | \n", "3913 | \n", "... | \n", "1 | \n", "0 | \n", "1 | \n", "0 | \n", "0 | \n", "0 | \n", "0 | \n", "1 | \n", "0 | \n", "0 | \n", "
1 | \n", "2 | \n", "120000 | \n", "26 | \n", "-1 | \n", "2 | \n", "0 | \n", "0 | \n", "0 | \n", "2 | \n", "2682 | \n", "... | \n", "1 | \n", "0 | \n", "1 | \n", "0 | \n", "0 | \n", "0 | \n", "0 | \n", "0 | \n", "1 | \n", "0 | \n", "
2 | \n", "3 | \n", "90000 | \n", "34 | \n", "0 | \n", "0 | \n", "0 | \n", "0 | \n", "0 | \n", "0 | \n", "29239 | \n", "... | \n", "1 | \n", "0 | \n", "1 | \n", "0 | \n", "0 | \n", "0 | \n", "0 | \n", "0 | \n", "1 | \n", "0 | \n", "
3 | \n", "4 | \n", "50000 | \n", "37 | \n", "0 | \n", "0 | \n", "0 | \n", "0 | \n", "0 | \n", "0 | \n", "46990 | \n", "... | \n", "1 | \n", "0 | \n", "1 | \n", "0 | \n", "0 | \n", "0 | \n", "0 | \n", "1 | \n", "0 | \n", "0 | \n", "
4 | \n", "5 | \n", "50000 | \n", "57 | \n", "-1 | \n", "0 | \n", "-1 | \n", "0 | \n", "0 | \n", "0 | \n", "8617 | \n", "... | \n", "0 | \n", "0 | \n", "1 | \n", "0 | \n", "0 | \n", "0 | \n", "0 | \n", "1 | \n", "0 | \n", "0 | \n", "
5 rows × 32 columns
\n", "