Question
I have to create a custom transformer that Adds an attribute to the end of the data (i.e. new last column) that is equal to
I have to create a custom transformer that Adds an attribute to the end of the data (i.e. new last column) that is equal to 315x13x5 for each observation. And Drops the entire 4x4 feature column. (See further instructions below.) Your class should include a parameter with a default value of True that deletes the 4x4 feature column when its value is True, but preserves the 4x4 feature column when its value is False. I am very lost on how to make the custom transformer. This is what I have but I know its wrong. My data has 5 columns.
from sklearn.base import BaseEstimator, TransformerMixin
x1_ix, x2_ix, x3_ix, x4_ix, x5_ix = 0,1,2,3,4
class Assignment4Transformer(BaseEstimator, TransformerMixin): def __init__(self, add_x6 = True): self.add_x6 = add_x6 def fit(self, data, y=None): return self def transform(self, data): x6 = (x1_ix**3) / (x5_ix) return x6
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