Kaggle competition: PUBG Finish Placement Prediction (Kernels Only)
<SOS> metric: MAE Kaggle data source: pubg-finish-placement-prediction-(kernels-only)<categorify>
%matplotlib inline
%pylab inline
warnings.filterwarnings(action='ignore')
data['OverallQual'].replace([1, 2], 3, inplace=True)
 data['OverallQual'].replace([10], 9, inplace=True )<data_type_conversions>
plt.figure(figsize =(20, 20))
data['OverallQual'] = data.OverallQual.astype('int' )<drop_column>
df = pd.read_csv('.. /input/train_V2.csv' )
data = data.drop(['RoofMatl'],axis=1 )<count_values>
del df
data.OverallCond.value_counts()<categorify>
train_df = pd.read_csv(".. /input/train_V2.csv")
 test_df = pd.read_csv(".. /input/test_V2.csv" )
mean_encoder(data,['MSSubClass','BldgType','HouseStyle','OverallCond','RoofStyle','Exterior1st','Exterior2nd','MasVnrType','ExterQual','ExterCond','Foundation','PavedDrive'])
<filter>
matchTyp = ['squad-fpp', 'duo', 'solo-fpp', 'squad', 'duo-fpp', 'solo',
'normal-squad-fpp', 'crashfpp', 'flaretpp', 'normal-solo-fpp',
'flarefpp', 'normal-duo-fpp', 'normal-duo', 'normal-squad',
'crashtpp', 'normal-solo']
mapping = {}
for i, j in enumerate(matchTyp):
mapping[i] = j
train_df["matchTypeMap"] = train_df["matchType"].apply(lambda x: ''.join(str(i)for i, j in mapping.items() if x == j)).map(int64)
 test_df["matchTypeMap"] = test_df["matchType"].apply(lambda x: ''.join(str(i)for i, j in mapping.items() if x == j)).map(int64 )
data[data.YearBuilt>data.YearRemodAdd]<feature_engineering>
train_df.drop(["matchType"], axis =1, inplace=True)
 test_df.drop(["matchType"], axis =1, inplace=True )
data.loc[data.YearBuilt>data.YearRemodAdd,'YearRemodAdd']=2002<feature_engineering>
train_df.dropna(inplace = True)
 train_df.isnull().any().any()
data['YearBuilt'] = np.power(np.abs(85-(2010 - data.YearBuilt)) ,2 )<predict_on_test>
X = train_df.drop(["Id", "groupId", "matchId", "winPlacePerc"], axis = 1)
 y = train_df["winPlacePerc"]
test = test_df.drop(["Id", "groupId", "matchId"], axis = 1 )
quick_predict(data.loc['train'].drop(['SalePrice','tmpPrice'],axis=1),data.loc['train'].tmpPrice )<define_variables>
del train_df
basement_cols = ['BsmtQual','BsmtCond','BsmtExposure','BsmtFinType1','BsmtFinSF1','BsmtFinType2','BsmtFinSF2','BsmtUnfSF','TotalBsmtSF','BsmtFullBath','BsmtHalfBath']<compute_test_metric>
model = xgboost.XGBRegressor(max_depth=17, gamma=0.3, learning_rate= 0.1)
 model.fit(X,y)
 del X
del y
adaptative_correlation(data.BsmtFinSF2,data.tmpPrice )<drop_column>
pred = model.predict(test )
<categorify><EOS> 
test_id = test_df["Id"]
submit_xg = pd.DataFrame({'Id': test_id, "winPlacePerc": pred} , columns=['Id', 'winPlacePerc'])
 print(submit_xg.head())
 submit_xg.to_csv("submission.csv", index = False )