Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Back to the Machine Learning fundamentals: How to write code for Model deployment (Part 3/3)
def train():
# Read Data
data = pd.read_csv(DATA_INGESTION['data_path'])
target = DATA_INGESTION['data_map']['target']
variables = DATA_INGESTION['data_map']['variables']
#Preprocessing
flt = data['umbrella_limit']>=0
data = data[flt]
data[target] = data[target].map(FEATURES_ENGINEERING['target_encoding'])
#Split data
X_train, X_test, y_train, y_test = train_test_split(data[variables], data[target],
test_size=PREPROCESSING['train_test_split_params']['test_size'],
random_state=PREPROCESSING['train_test_split_params']['random_state'])
#Train Pipeline
Pipeline_Fit = pipeline.fit(X_train, y_train)
#Save Model
PostProcessing.save(Pipeline_Fit, PIPE_TRAINING['pipe_path'])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.