18 lines
421 B
Python
18 lines
421 B
Python
|
import numpy as np
|
||
|
from sklearn.base import BaseEstimator, TransformerMixin
|
||
|
|
||
|
|
||
|
class CarsFeatures(BaseEstimator, TransformerMixin):
|
||
|
def __init__(self):
|
||
|
pass
|
||
|
|
||
|
def fit(self, X, y=None):
|
||
|
return self
|
||
|
|
||
|
def transform(self, X, y=None):
|
||
|
X["Age"] = 2020 - X["Prod. year"]
|
||
|
return X
|
||
|
|
||
|
def get_feature_names_out(self, features_in):
|
||
|
return np.append(features_in, ["Age"], axis=0)
|