Encode the categorical input variables. Do not encode the target variable Attrition. You will do that in the following question.
Hints: You will create dummies for categorical variables. For example, let's say you have a variable named occupation. This variable has three levels: Engineer, Teacher, Manager. We will use binary encoding and create dummies for each of these levels to be able to encode the occupation variable. Technically, we are converting the categorical variable into new numerical variables. We will have two new variables for this occupation variable, such as occupation_teacher and occupation_manager. We do not need occupation_teacher because we can infer if the person is a teacher by checking occupation_manager and occupation_engineer variables. For example, if occupation_engineer and occupation_manager are zero, then this person is a teacher. If occupation_engineer is 1, this person is an engineer. Check Module 5g: Encoding Categorical Variables.
In [151]: # your code to encode categorical input variables goes in here
af
Do not alter the below cell. It is a test case for Question 7 IT.
In[152]:
try:
if (df['JobRole_Laboratory Technician'].mean() == 0.1761904761904762) and (df['EducationField_Marketing'].mean() == 0.10816326530612246):
score['question 7'] = 'pass'
else:
score['question 7'] = 'fail'
except:
score['question 7'] = 'fail'
score
Out[152]: {'question 1': 'pass', 'question 2': 'pass', 'question 3': 'pass', 'question 4': 'pass', 'question 5': 'pass', 'question 6': 'pass', 'question 7': 'pass'}