Question: Create a custom transformer that: Inherits from BaseEstimator and TransformerMixin. Implements the fit and transform methods. Accepts a DataFrame as input. In the transform method:

Create a custom transformer that:
Inherits from BaseEstimator and TransformerMixin.
Implements the fit and transform methods.
Accepts a DataFrame as input.
In the transform method:
Create a new column called absences_sum that sums the absences_G1, absences_G2, and absences_G3 columns, adds the new absences_sum column to the end of the DataFrame, then drops the original three absence columns.Drop the G1 and G2 columns if the parameter drop_grades is True. It will keep the columns if drop_grades is False.
Name the custom transformer class GradeTransformer.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!