Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Create a custom transformer, similar to the custom transformer that we saw in the California House Prices module example. Go back and review that code,
Create a custom transformer, similar to the custom transformer that we saw in the California House Prices module example. Go back and review that code, making sure that you understand the various pieces, in order to more easily create this custom transformer.
Exercise : Create a custom transformer that takes the numerical columns from your data and performs the following transformations:
You must name your custom transformer class AssignmentTransformer Your class should include an input parameter called createnewcolumn with a default value of True that performs the following two data preparation steps when its value is True, but skips these steps and just returns the DataFrame as is when you pass a value of False.
Adds an attribute to the end of the numerical data ie new last column that is the result of the daysperweek column multiplied by the hoursperday column. We are creating this column to better compare the amount of hours worked between the individuals.
Since they are not needed with the new column, delete the daysperweek and hoursperday columns.
Remember that you only want these two steps to occur when the createnewcolumn parameter is True. Your custom transfomer will be tested in CodeGrade to make sure these steps are not ran when the createnewcolumn parameter is False.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started