Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Take Lecture9-call-functions.ipynb and write a function for converting categorical independent variables to 0/1. Take the cell with concat() and modify it to a function (just

Take Lecture9-call-functions.ipynb and write a function for converting categorical independent variables to 0/1. Take the cell with concat() and modify it to a function (just for the first two lines of the cell). Tip: You should use a list to store the names of all the categorical independent variables, and the input of the function will be this list. In the function, use a loop to process each variable at a time.

image text in transcribed

As you can see from the result of the previous cell, the folder this file is in is automatically on the list. d pd. get_dummies (data0 ["Department"], prefix = "Department"), pd. get_dummies (data0 ["EducationField"], prefix = "EducationField"), pd. get_dummies (data0 ["Gender"], prefix = "Gender"), pd.get_dummies (data0 ["JobRole"], prefix = "JobRole"), pd.get_dummies (data0 ["MaritalStatus"], prefix = "Maritalstatus"), pd. get_dummies (data0 ["OverTime"], prefix = "OverTime")], axis = 1) data 0 = data0.drop(["BusinessTravel", "Department", "EducationField", "Gender", "JobRole", "MaritalStatus", "OverTime"], axis = 1) from my_functions import stratified_sample X_train, X_test, y_train, y_test = stratified_sample (data0, 'Attrition', 0.8) print(X_train.shape, y_train.shape, X_test.shape, y_test.shape)

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Marketing The Ultimate Marketing Tool

Authors: Edward L. Nash

1st Edition

0070460639, 978-0070460638

More Books

Students also viewed these Databases questions