Created
January 28, 2020 14:03
-
-
Save lakshay-arora/27a0f5682418941a9ef70efbd7f698f6 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# import the BaseEstimator | |
from sklearn.base import BaseEstimator | |
# define the class OutletTypeEncoder | |
# This will be our custom transformer that will create 3 new binary columns | |
# custom transformer must have methods fit and transform | |
class OutletTypeEncoder(BaseEstimator): | |
def __init__(self): | |
pass | |
def fit(self, documents, y=None): | |
return self | |
def transform(self, x_dataset): | |
x_dataset['outlet_grocery_store'] = (x_dataset['Outlet_Type'] == 'Grocery Store')*1 | |
x_dataset['outlet_supermarket_3'] = (x_dataset['Outlet_Type'] == 'Supermarket Type3')*1 | |
x_dataset['outlet_identifier_OUT027'] = (x_dataset['Outlet_Identifier'] == 'OUT027')*1 | |
return x_dataset | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment