-
Notifications
You must be signed in to change notification settings - Fork 0
/
food_ml.py
26 lines (19 loc) · 882 Bytes
/
food_ml.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
from sklearn.ensemble import RandomForestClassifier
from sklearn.ensemble import GradientBoostingRegressor, AdaBoostClassifier
from sklearn.linear_model import LogisticRegression
from sklearn.preprocessing import RobustScaler, MinMaxScaler
from sklearn.externals import joblib
import pickle
import numpy as np
import pandas as pd
def pipeline(url):
df = pd.read_csv(url)
labels = df.drop('class',1).to_numpy()
target = df['class']
models = [ LogisticRegression(penalty='l2',C=0.1,max_iter=1000),
RandomForestClassifier(n_estimators=100),
GradientBoostingRegressor(n_estimators=100, learning_rate=0.1, max_depth=1, random_state=0, loss='ls'),
AdaBoostClassifier(n_estimators=100) ]
for model in models:
model.fit(labels, target)
joblib.dump(model, '{}.pkl'.format(type(model).__name__))