Skip to content

Commit

Permalink
#7; add ValueMapper in src.preprocess
Browse files Browse the repository at this point in the history
  • Loading branch information
abhi8893 committed Jul 2, 2021
1 parent 7175b3d commit fde7099
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions mlops/mpg-pred-end-to-end-ml/src/preprocess.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@

from sklearn.base import BaseEstimator, TransformerMixin
import pandas as pd

class ValueMapper(BaseEstimator, TransformerMixin):

def __init__(self, mapper: dict):
self.mapper = mapper

def fit(self, X, y=None):
# TODO: Get column wise default mappings
return self

def transform(self, X):
X = X.apply(lambda col: col.map(self.mapper)).to_numpy()
return X

0 comments on commit fde7099

Please sign in to comment.