"""
# Load dependencies
"""
!pip install pycaret
!pip install sweetviz
import pandas as pd
import sweetviz as sv

from pycaret.regression import *
train = pd.read_csv('../input/tabular-playground-series-aug-2021/train.csv').drop("id", axis=1)#.sample(frac=0.05)
test = pd.read_csv('../input/tabular-playground-series-aug-2021/test.csv').drop("id", axis=1)
sample_submission = pd.read_csv('../input/tabular-playground-series-aug-2021/sample_submission.csv')
"""
# Exploratory Data Analysis
"""
my_report = sv.analyze(train, target_feat='loss')
my_report.show_notebook()
"""
# Model Training
"""
exp_clf = setup(train, 
                target="loss",
                silent= True)
N_SELECT = 5
K=5
SCORE_METRIC='RMSE'
# return best model
best = compare_models(sort = SCORE_METRIC, n_select=N_SELECT,
                      exclude = ['et', 'rf', 'svm'], fold=K)
"""
# Model Ensembling
"""
blended = blend_models(estimator_list = best, fold=K, optimize=SCORE_METRIC)
final_model = finalize_model(blended)
"""
# Model Analysis
"""
plot_model(final_model)
"""
# Sub
"""
# Final prediction
pred_esb = predict_model(final_model, test)

# Get predictions
sample_submission['loss'] = pred_esb['Label']

# Write submission
sample_submission.to_csv('submission.csv',index=False)