forked from choco9966/Dacon
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
10 changed files
with
14,372 additions
and
0 deletions.
There are no files selected for viewing
139 changes: 139 additions & 0 deletions
139
Real House Price Prediction/code/ENSEMBLE/Ensemble.ipynb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,139 @@ | ||
{ | ||
"cells": [ | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 7, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"import pandas as pd #Analysis \n", | ||
"import matplotlib.pyplot as plt #Visulization\n", | ||
"import seaborn as sns #Visulization\n", | ||
"import numpy as np #Analysis \n", | ||
"from scipy.stats import norm #Analysis \n", | ||
"from sklearn.preprocessing import StandardScaler #Analysis \n", | ||
"from scipy import stats #Analysis \n", | ||
"import warnings \n", | ||
"warnings.filterwarnings('ignore')\n", | ||
"%matplotlib inline\n", | ||
"\n", | ||
"from sklearn.model_selection import KFold\n", | ||
"from sklearn.metrics import mean_absolute_error\n", | ||
"import gc\n", | ||
"import lightgbm as lgb\n", | ||
"\n", | ||
"from sklearn.metrics import mean_squared_error\n", | ||
"from sklearn.linear_model import BayesianRidge" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 8, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"LGB1 = pd.read_csv(\"[190130]LGB_Quantile_not_deep.csv\") #Quantile SAMPLING\n", | ||
"LGB1.columns = ['key','LGB1']\n", | ||
"\n", | ||
"LGB4 = pd.read_csv(\"LGB_Testfile_LB5150_LV.csv\") #LAST VALIDATION SAMPLING\n", | ||
"LGB4.columns = ['key','LGB4']\n", | ||
"\n", | ||
"XGB1 = pd.read_csv(\"01.30.XGB_Bestscore-2.csv\") #5fold NOT DEEP NOT SAMPLING\n", | ||
"XGB1.columns = ['key','XGB1']\n", | ||
"\n", | ||
"XGB4 = pd.read_csv(\"01.29.Xgb_3fold.csv\") #3fold NOT DEEP NOT SAMPLING\n", | ||
"XGB4.columns = ['key','XGB4']" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 9, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"SUB = pd.merge(LGB1,LGB4,on='key')\n", | ||
"SUB = pd.merge(SUB,XGB1,on='key')\n", | ||
"SUB = pd.merge(SUB,XGB4,on='key')" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 10, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"train = pd.read_csv(\"train.csv\")[['key','transaction_real_price','city']]\n", | ||
"test = pd.read_csv(\"test.csv\")[['key','transaction_real_price','city']]\n", | ||
"test.loc[test['key']==1503614,'city'] = 0\n", | ||
"\n", | ||
"del test['transaction_real_price']\n", | ||
"\n", | ||
"busan_train = train[train['city']==0].reset_index(drop=True)\n", | ||
"busan_test = test[test['city']==0].reset_index(drop=True)\n", | ||
"\n", | ||
"seoul_train = train[train['city']==1].reset_index(drop=True)\n", | ||
"seoul_test = test[test['city']==1].reset_index(drop=True)\n", | ||
"\n", | ||
"SUB_BUSAN = pd.merge(busan_test,SUB,on='key',how='left')\n", | ||
"SUB_SEOUL = pd.merge(seoul_test,SUB,on='key',how='left')\n", | ||
"del SUB_BUSAN['city']\n", | ||
"del SUB_SEOUL['city']" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 11, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"SUB_BUSAN['LGB1_XGB1'] = 0.8*SUB_BUSAN['LGB1'] + 0.2*SUB_BUSAN['XGB1'] \n", | ||
"SUB_SEOUL['LGB1_XGB1'] = 0.7*SUB_SEOUL['LGB1'] + 0.3*SUB_SEOUL['XGB1'] \n", | ||
"\n", | ||
"SUB_BUSAN['LGB1_XGB4'] = 0.9*SUB_BUSAN['LGB1'] + 0.1*SUB_BUSAN['XGB4'] \n", | ||
"SUB_SEOUL['LGB1_XGB4'] = 0.7*SUB_SEOUL['LGB1'] + 0.3*SUB_SEOUL['XGB4'] \n", | ||
"\n", | ||
"SUB_BUSAN['transaction_real_price'] = 2.1*SUB_BUSAN['LGB1_XGB1'] -0.4*SUB_BUSAN['LGB4'] - 0.7*SUB_BUSAN['LGB1_XGB4'] \n", | ||
"SUB_SEOUL['transaction_real_price'] = 0.1*SUB_SEOUL['LGB1_XGB1'] -0.3*SUB_SEOUL['LGB4'] + 1.2*SUB_SEOUL['LGB1_XGB4'] " | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 12, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"SUB = pd.concat([SUB_BUSAN,SUB_SEOUL])\n", | ||
"SUB = SUB[['key','transaction_real_price']]\n", | ||
"SUB.to_csv(\"LAST_SOLUTION.csv\",index=False)" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [] | ||
} | ||
], | ||
"metadata": { | ||
"kernelspec": { | ||
"display_name": "Python 3", | ||
"language": "python", | ||
"name": "python3" | ||
}, | ||
"language_info": { | ||
"codemirror_mode": { | ||
"name": "ipython", | ||
"version": 3 | ||
}, | ||
"file_extension": ".py", | ||
"mimetype": "text/x-python", | ||
"name": "python", | ||
"nbconvert_exporter": "python", | ||
"pygments_lexer": "ipython3", | ||
"version": "3.6.6" | ||
} | ||
}, | ||
"nbformat": 4, | ||
"nbformat_minor": 2 | ||
} |
Oops, something went wrong.