import pandas as pd
from supervised.automl import AutoML
from supervised.preprocessing.eda import EDA

"""
Explanation: The Ames Housing dataset was compiled by Dean De Cock for use in data science education. It's an incredible alternative for data scientists looking for a modernized and expanded version of the often cited Boston Housing dataset. 
Import required libraries
End of explanation
"""


train_df = pd.read_csv("data/house_price_train.csv")
test_df = pd.read_csv("data/house_price_test.csv")

train_df.head()

print("\nThe train data size after dropping Id feature is : {} ".format(train_df.shape)) 
print("The test data size after dropping Id feature is : {} ".format(test_df.shape))

X_train = train_df.drop(['SalePrice'],axis=1)
y_train = train_df['SalePrice']

"""
Explanation: Load train and test dataset
End of explanation
"""


a = AutoML(algorithms=['Xgboost'],total_time_limit=30,
           explain_level=2,golden_features=True,
           validation_strategy={
            "validation_type": "kfold",
            "k_folds": 3,
            "shuffle": False,
            "stratify": True,
            })
a.fit(X_train,y_train)

"""
Explanation: Basic EDA and model training
Want to do basic EDA?


AutoML contains automated Exploratory data analysis for input data, by default it performs and saved the automated eda report for the given training dataset. For more details check here


The model training is done using AutoML.fit() method, you can control the and select the algorithms to be used and the training time etc, please refer docs here for more details.


Want to do automated feature engineering?
mljar provides golden features
- Golden Features are new features constructed from original data which have great predictive power. Set the golden_features parameter to True and see if work.
What to do cross-validation?
specify your cross-validation strategy in validation_stategy parameter in AutoML.
What to do ML Explainability?
AutoML provides feature importances and SHAP value explanations for tree based models. This is controlled by explain_level parameter in AutoML. Refer docs for more information.
End of explanation
"""


predictions = a.predict(test_df)
submission = pd.read_csv("data/sample_submission.csv")
submission['SalePrice'] = predictions
submission.head()

"""
Explanation: Predict on test
End of explanation
"""


