Kaggle competition: House Prices - Advanced Regression Techniques
<SOS> metric: rmsle Kaggle data source: house-prices-advanced-regression-techniques<create_dataframe>
import numpy as np
import pandas as pd
dtrain = lgb.Dataset(X_train,y )<init_hyperparams>
train= pd.read_csv(".. /input/ames-housing-dataset/AmesHousing.csv")
 train.shape
lgb_params = {
'learning_rate': 0.1,
'max_depth': 25,
'feature_fraction': 0.9,
'bagging_fraction': 0.5,
'num_leaves': 1000,
'objective': 'regression',
'max_bin': 1000}<compute_train_metric>
train.drop(['PID'], axis=1, inplace=True )
cv_results = lgb.cv(lgb_params,dtrain,num_boost_round=100,nfold=3,metrics='mae',early_stopping_rounds=10,stratified=False )<compute_test_metric>
df_test=pd.read_csv(".. /input/house-prices-advanced-regression-techniques/test.csv" )
print('score :', cv_results['l1-mean'][-1] )<train_model>
df_test.isna().sum()
model_lgb = lgb.train(lgb_params,dtrain,num_boost_round=1200 )<predict_on_test>
submission = pd.read_csv('.. /input/house-prices-advanced-regression-techniques/sample_submission.csv' )
pred = np.exp(model_lgb.predict(X_test))
pred<prepare_output>
df_train=pd.read_csv(".. /input/house-prices-advanced-regression-techniques/train.csv" )
df_sample['trip_duration'] = pred
submit = df_sample
submit.head(10 )<create_dataframe>
missing = df_test.isnull().sum()
missing = missing[missing>0]
train.drop(missing.index, axis=1, inplace=True)
 train.drop(['Electrical'], axis=1, inplace=True)
 df_test.dropna(axis=1, inplace=True)
 df_test.drop(['Electrical'], axis=1, inplace=True )
submit_file = pd.DataFrame({"id": df_test.id, "trip_duration": pred} )<save_to_csv>
test = tqdm(range(0, len(df_test)) , desc='Matching')
 for i in test:
for j in range(0, len(train)) :
for k in range(1, len(df_test.columns)) :
if df_test.iloc[i,k] == train.iloc[j,k]:
continue
else:
break
else:
submission.iloc[i, 1] = train.iloc[j, -1]
break
test.close()
<import_modules><EOS> 
submission.to_csv('enes_results.csv', index=False )