■Kaggle Practice for Beginners -House SalePrice (PyCaretを使ってみた)- by Google Colaboratory

# 0. Introduction
 I'd like to show how to use PyCaret thru House Sale Price Competition to introduce how easy to use this library.
This introduction is only to show very basic flow, so if you want to improve your score on Kaggle, you need to add some procedures, such as preprocessing steps and modeling techniques.

# 1. Setting for Google Colaboratory

Setup thru Google Colaboratory environment using these command below to activate connection with Kaggle.
 
```python
from google.colab import files
files.upload()
!pip install kaggle
!mkdir -p ~/.kaggle
!mv kaggle.json ~/.kaggle/
!chmod 600 /root/.kaggle/kaggle.json
```

Copy and paste the **[API](https://www.kaggle.com/c/house-prices-advanced-regression-techniques/data)** linked to datasets you want to download from Kaggle.
Don't forget putting "!" mark into front of this command.

```python
# This is an example of House SalePrice
!kaggle competitions download -c house-prices-advanced-regression-techniques
```


# 2. Install PyCaret

```python
!pip install pycaret
```

# 3. Import Dataset

```python
import numpy as np 
import pandas as pd 

train = pd.read_csv("/content/train.csv")
test = pd.read_csv("/content/test.csv")
train.head() 
```

# 4. Setup PyCaret


```python
from pycaret.regression import *
reg = setup(train, target='SalePrice', session_id= 0)   
```

[**session_id: int, default = None**](https://pycaret.org/regression/)
If None, a random seed is generated and returned in the Information grid. The unique number is then distributed as a seed in all functions used during the experiment. This can be used for later reproducibility of the entire experiment.

# 5. Compare Models


[**Compare Models**](https://pycaret.org/regression/)
  compare_models(blacklist = None, fold = 10,  round = 4,  sort = ‘R2’, turbo = True)
This function uses all models in the model library and scores them using K-fold Cross Validation. The output prints a score grid that shows MAE, MSE, RMSE, R2, RMSLE and MAPE by fold (default CV = 10 Folds) of all the available models in model library.

['tr']   Thielsen Regressor required long training time, so I removed the method this time.
['lar']  Least Angle Regression showed too large amount of MAE, so I omitted this time.

```python
compare_models(blacklist=['tr', 'lar'])
```
![image.png](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/626074/8d40f40d-8b3d-7341-e748-0e1fb7e2f84c.png)

# 6.Create Models

```python
llar1 = create_model('llar', verbose=False)
```

# 7. Predictions

```python
predict_model(llar1)
predictions_llar1 = predict_model(llar1, data=test)
```
```python
test_ID = test['Id']
predictions_llar_Label = predictions_llar1['Label']
my_submission = pd.DataFrame()
my_submission["Id"] = test_ID
my_submission["SalePrice"] = predictions_llar_Label
my_submission.to_csv('submission_llar.csv', index=False)
```

# 8. Submission
Copy and paste the **[API](https://www.kaggle.com/c/house-prices-advanced-regression-techniques/submissions)** linked to submission page you want to submit to Kaggle.
Don't forget putting "!" mark into front of this command.


```python

# Submission to Kaggle
!kaggle competitions submit -c house-prices-advanced-regression-techniques -f submission_llar.csv -m "Message" 
```


## References:
**LINKS**
   >- [kaggleの住宅価格予測問題（House Prices）を解いてみる](https://medium-s.jp/kaggle-house-prices/)
   >- [住宅価格を予測する〜Kaggle House Priceチュートリアルに挑む](https://yolo-kiyoshi.com/2018/12/17/post-1003/)
   >- [Kaggle page "House Price"](https://www.kaggle.com/c/house-prices-advanced-regression-techniques/overview/evaluation)
   >- [COURSERA -Online Learning System-](https://www.coursera.org/)
   >- [PyCaret を使って東京の中古マンション価格を予測してみよう！](https://qiita.com/bashiiiwa/items/6fa8d2d59f795e71c1fb)