HW3Zhuorui TuoSupervised Learning - Jupyter Notebook

.pdf
School
Culinary Institute of America **We aren't endorsed by this school
Course
ACCT MANAGERIAL
Subject
Management
Date
Oct 25, 2023
Pages
27
Uploaded by kjkszpjemp on coursehero.com
2023/9/17 13:40 HW3_Zhuorui Tuo_Supervised Learning - Jupyter Notebook localhost:8888/notebooks/HW3_Zhuorui Tuo_Supervised Learning.ipynb# 1/27 HW 3 Supervised Learning (Total Points - 5) You have to submit two files for this part of the HW 1. FirstNameLastName_Hw3.ipynb (colab notebook) 2. FirstNameLastName_Hw3.pdf pdf file** For Task1: You are also provided HW3_EDA_Template. You can folllow this template to complete Task1. Import/Install the packages In [ ]: In [ ]: In [ ]: In [ ]: Running on Colab . . . 1.6.1 1.3.0 if 'google.colab' in str (get_ipython()): print ( 'Running on Colab' ) else : print ( 'Not Running on Colab' ) if 'google.colab' in str (get_ipython()): ! pip install -- upgrade feature_engine scikit - learn - q from google.colab import drive drive .mount( '/content/drive' ) import feature_engine import sklearn print (feature_engine.__version__) print (sklearn.__version__)
2023/9/17 13:40 HW3_Zhuorui Tuo_Supervised Learning - Jupyter Notebook localhost:8888/notebooks/HW3_Zhuorui Tuo_Supervised Learning.ipynb# 2/27 In [21]: Specify Project Folder Location In [ ]: # Import packages for data manipulation and mathematical operations import pandas as pd # For data manipulation using dataframes import numpy as np # For mathematical operations # Import packages for data visualization import matplotlib.pyplot as plt # For basic plots import seaborn as sns # For more advanced plots import scipy.stats as stats # For statistical tests and transformations # To display plots inline in Jupyter Notebooks % matplotlib inline # Import packages for saving and loading machine learning models import joblib # To save and load ML models # Import packages for file and system operations from pathlib import Path # For OS-agnostic file paths import sys # For system-specific parameters and functions # Import packages for data splitting and model evaluation from sklearn.model_selection import train_test_split # For data splitting from sklearn.model_selection import StratifiedKFold # For stratified cros from sklearn.model_selection import KFold # For simple cross-validatio # Import packages for data preprocessing from sklearn.preprocessing import OneHotEncoder # For one-hot enco from sklearn.preprocessing import StandardScaler # For standardizing # Import packages for building pipelines from sklearn.pipeline import Pipeline # For creating pipelines # Import packages for hyperparameter tuning from sklearn.model_selection import GridSearchCV # For grid search c # Import packages for machine learning algorithms from sklearn.neighbors import KNeighborsClassifier # For K-Nearest Ne # Import packages for fetching datasets from sklearn.datasets import fetch_openml # To fetch datasets from Op # Import packages for feature transformations # For logarithmic transformations # To use scikit-learn transformers within feature-engine if 'google.colab' in str (get_ipython()): base_folder = Path( '/content/drive/MyDrive/data/' ) # CHANGE TO LOC # You need the else block only if you are NOT using COLAB else : base_folder = Path( '/home/harpreet/Insync/google_drive_shaannoor/d
2023/9/17 13:40 HW3_Zhuorui Tuo_Supervised Learning - Jupyter Notebook localhost:8888/notebooks/HW3_Zhuorui Tuo_Supervised Learning.ipynb# 3/27 In [ ]: Import Custom Functions from Python file In [15]: In [16]: In [17]: In [1]: Task: Classification on the 'credit-g' dataset (10 points) The goal is to classify people described by a set of attributes as good or bad credit risks. Download Data: You can download the dataset using the commands below and see it's description at https://www.openml.org/d/31 (https://www.openml.org/d/31) --------------------------------------------------------------------------- NameError Traceback (most recent call last) ~\AppData\Local\Temp\ipykernel_8956\358982227.py in <module> ----> 1 sys . path . append ( str ( custom_function_folder )) NameError : name 'custom_function_folder' is not defined Out[17]: ['C:\\Users\\Terry', 'C:\\Users\\Terry\\anaconda3\\python39.zip', 'C:\\Users\\Terry\\anaconda3\\DLLs', 'C:\\Users\\Terry\\anaconda3\\lib', 'C:\\Users\\Terry\\anaconda3', '', 'C:\\Users\\Terry\\anaconda3\\lib\\site-packages', 'C:\\Users\\Terry\\anaconda3\\lib\\site-packages\\win32', 'C:\\Users\\Terry\\anaconda3\\lib\\site-packages\\win32\\lib', 'C:\\Users\\Terry\\anaconda3\\lib\\site-packages\\Pythonwin', 'C:\\Users\\Terry\\anaconda3\\lib\\site-packages\\IPython\\extensions', 'C:\\Users\\Terry\\.ipython'] # CHANGE TO LOCATION BASED ON YOUR GOOGLE DRIVE save_model_folder = base_folder / 'models/ml_fall_2023' # CHANGE TO L custom_function_folder = base_folder / 'custom-functions' # CHANGE TO save_model_folder.mkdir(exist_ok = True , parents = True ) % load_ext autoreload % autoreload 2 sys.path.append( str (custom_function_folder)) sys.path from eda_plots import diagnostic_plots, plot_target_by_category
Page1of 27
Uploaded by kjkszpjemp on coursehero.com