text_plain_output_1.png
from catboost import CatBoostRegressor

from sklearn.ensemble import AdaBoostRegressor

from sklearn.ensemble import GradientBoostingRegressor

from sklearn.ensemble import RandomForestRegressor

from sklearn.linear_model import Lasso,Ridge,BayesianRidge,ElasticNet,HuberRegressor,LinearRegression,LogisticRegression,SGDRegressor

from sklearn.metrics import mean_squared_error

from sklearn.model_selection import train_test_split

from sklearn.model_selection import train_test_split

from sklearn.neighbors import KNeighborsRegressor

from sklearn.tree import DecisionTreeRegressor

from xgboost import XGBRegressor

import matplotlib.pyplot as plt

import numpy as np

import numpy as np

import pandas as pd

import seaborn as sns

import warnings

df = pd.read_csv('../input/pick_time_warehouse_train.csv')

df.shape

df.columns

df.shape

def remove_outlier(df_in, col_name):
    q1 = df_in[col_name].quantile(0.25)
    q3 = df_in[col_name].quantile(0.75)
    iqr = q3 - q1
    fence_low = q1 - 1.5 * iqr
    fence_high = q3 + 1.5 * iqr
    df_out = df_in.loc[(df_in[col_name] > fence_low) & (df_in[col_name] < fence_high)]
    return df_out
def remove_outlier_cat(df_in, group):
    q1 = group.quantile(0.25)
    q3 = group.quantile(0.75)
    iqr = q3 - q1
    fence_low = q1 - 1.5 * iqr
    fence_high = q3 + 1.5 * iqr
    df_out = df_in.loc[(group > fence_low) & (group < fence_high)]
    return df_out

for i in range(10):
    df = remove_outlier(df, 'Pick_Time')

df.isnull().sum()

fig, ax = plt.subplots(figsize=(15,15))
sns.heatmap(df.corr(),annot=True, linewidths=.5,ax=ax)

for i in np.unique(df['Actual_Quantity']):
    remove_outlier_cat(df, df.groupby(['Actual_Quantity', i]))

df.columns

hr = []
minutes = []
seconds = []
for i in range(len(df['Start_Time_of_Picking'])):
    hr.append(int(df.iloc[i]['Start_Time_of_Picking'].split(':')[0]))
    a, b = df.iloc[i]['Start_Time_of_Picking'].split(':')[1].split('.')
    minutes.append(int(a))
    seconds.append(int(b))

df = pd.concat([df, pd.get_dummies(df['SKU'], drop_first=True, prefix=1)], axis=1, sort=False)
df = pd.concat([df, pd.get_dummies(df['User'], drop_first=True, prefix=2)], axis=1, sort=False)
df = pd.concat([df, pd.get_dummies(df['number_of_container_conveyor'], drop_first=True, prefix=3)], axis=1, sort=False)
df = pd.concat([df, pd.get_dummies(df['last_station_served_by_user'], drop_first=True, prefix=3)], axis=1, sort=False)
df = df.drop(['SKU', 'User', 'number_of_container_conveyor', 'last_station_served_by_user'], axis=1)

target = df.Pick_Time
del df['Pick_Time']

X_train, X_test, y_train, y_test = train_test_split(df, target, test_size=0.3, shuffle=False)
from sklearn.model_selection import train_test_split
from sklearn.metrics import accuracy_score
from sklearn.tree import DecisionTreeRegressor
from sklearn.ensemble import RandomForestRegressor
from sklearn.neighbors import KNeighborsRegressor
from sklearn.svm import SVR
from sklearn.ensemble import AdaBoostRegressor
from sklearn.ensemble import GradientBoostingRegressor
from xgboost import XGBRegressor
from catboost import CatBoostRegressor
from sklearn.linear_model import Lasso, Ridge, BayesianRidge, ElasticNet, HuberRegressor, LinearRegression, LogisticRegression, SGDRegressor
from sklearn.metrics import mean_squared_error
import numpy as np
import warnings
import keras
warnings.filterwarnings('ignore')
model = CatBoostRegressor(logging_level='Silent')
model.fit(X_train, y_train)
predictions = model.predict(X_test)

classifiers = [['DecisionTree :', DecisionTreeRegressor()], ['RandomForest :', RandomForestRegressor()], ['KNeighbours :', KNeighborsRegressor(n_neighbors=2)], ['AdaBoostClassifier :', AdaBoostRegressor()], ['GradientBoostingClassifier: ', GradientBoostingRegressor()], ['Xgboost: ', XGBRegressor()], ['CatBoost: ', CatBoostRegressor(logging_level='Silent')], ['Lasso: ', Lasso()], ['Ridge: ', Ridge()], ['BayesianRidge: ', BayesianRidge()], ['ElasticNet: ', ElasticNet()], ['HuberRegressor: ', HuberRegressor()]]
print('Accuracy Results...')
for name, classifier in classifiers:
    classifier = classifier
    classifier.fit(X_train, y_train)
    predictions = classifier.predict(X_test)
    print(name, np.sqrt(mean_squared_error(y_test, predictions)))