Kaggle competition: PUBG Finish Placement Prediction (Kernels Only)
data[data.Neighborhood=="IDOTRR"].MSZoning.value_counts()<categorify>
gc.enable()
data.loc[(data.MSZoning.isna())&(data.Neighborhood=="Mitchel"),"MSZoning"]="RL"
data.loc[(data.MSZoning.isna())&(data.Neighborhood=="IDOTRR"),"MSZoning"]="RM"<feature_engineering>
def preprocessing(is_train=True):
if is_train:
print("Preprocessing train_V2.csv")
 print("Reading the data...",end='')
 df = pd.read_csv('.. /input/train_V2.csv')
 print("Done!")
 print("Kicking out the loner...",end='')
 df = df[df['maxPlace'] > 1]
print("Done!")
 else:
print("Preprocessing test_V2.csv",)
 print("Reading the data...",end='')
 df = pd.read_csv('.. /input/test_V2.csv')
 print('Done!')
 if is_train:
print("Getting the target...",end='')
 target = df['winPlacePerc']
print("Done!")
 print('Remove target from dataframe...',end='')
 df = df.drop(['winPlacePerc'],axis=1)
 print("Done!")
 print("Dataframe Exported.")
 if is_train:
return df,target
return df
data['LotAreaSqr']=np.sqrt(data.LotArea )<count_values>
def feature_managing(df,is_train=True,lowfeature=True,valuematchtype=True):
err = 0
print("Feature Management Initiated")
 if is_train:
print("Dropping Player's Id")
 try:
df = df.drop(['Id'],axis=1)
 except:
print("Warning: 'Id' not found.")
 err += 1
else:
print('Retrive Player's Id...',end='')
 test_id = df['Id']
df = df.drop(['Id'],axis=1)
 print('Done!')
 if lowfeature:
print("Dropping MatchId")
 try:
df = df.drop(['matchId'],axis=1)
 print('Dropping GroupId')
 df = df.drop(['groupId'],axis=1)
 except:
print('Warning: MatchId and GroupId not found')
 err += 1
if valuematchtype:
mtype = ['solo','solo-fpp','duo','duo-fpp','squad','squad-fpp']
print('Determine Value for MatchType',end='')
 df.loc[df.matchType == 'solo','matchType'] = 1
print('.',end='')
 df.loc[df.matchType == 'normal-solo','matchType'] = 1
print('.',end='')
 df.loc[df.matchType == 'solo-fpp','matchType'] = 0.5
print('.',end='')
 df.loc[df.matchType == 'normal-solo-fpp','matchType'] = 0.5
print('.',end='')
 df.loc[df.matchType == 'duo','matchType'] = 2
print('.',end='')
 df.loc[df.matchType == 'normal-duo','matchType'] = 2
print('.',end='')
 df.loc[df.matchType == 'duo-fpp','matchType'] = 2.5
print('.',end='')
 df.loc[df.matchType == 'normal-duo-fpp','matchType'] = 2.5
print('.',end='')
 df.loc[df.matchType == 'squad','matchType'] = 4
print('.',end='')
 df.loc[df.matchType == 'normal-squad','matchType'] = 4
print('.',end='')
 df.loc[df.matchType == 'squad-fpp','matchType'] = 3.5
print('.',end='')
 df.loc[df.matchType == 'normal-squad-fpp','matchType'] = 4
print('.',end='')
 df.loc[df.matchType == 'crashfpp','matchType'] = 5
print('.',end='')
 df.loc[df.matchType == 'crashtpp','matchType'] = 5.5
print('.',end='')
 df.loc[df.matchType == 'flarefpp','matchType'] = 6
print('.',end='')
 df.loc[df.matchType == 'flaretpp','matchType'] = 6.5
print('Done!')
 else:
df = df.drop['matchType']
print('Generating Feature')
 print('Generate KillKnockRatio')
 df['KillKnockRatio'] = df['kills']/df['DBNOs']
print('Generate HealthItemsUsed')
 df['HealthItemsUsed'] = df['heals']+df['boosts']
print('Generate HeadshotRatio')
 df['HeadshotRatio'] = df['headshotKills']/df['kills']
print('Generate AverageDamagePerkill')
 df['AverageDamagePerKill'] = df['damageDealt']/df['kills']
print('Generate KillstreakRate')
 df['KillstreakRate'] = df['killStreaks']/df['kills']
print('Generate TotalDistance')
 df['TotalDistance'] = df['rideDistance'] + df['swimDistance'] + df['walkDistance']
print('Generate WeaponRetriveOverDistance')
 df['WROD'] = df['TotalDistance']/df['weaponsAcquired']
print('Generate WalkingHeal')
 df['walkHeal'] = df['walkDistance']/df['heals']
print('Generate WalkingKills')
 df['walkkills'] = df['walkDistance']/df['kills']
print('Generate KillPerMeters')
 df['KPM'] = df['kills']/df['walkDistance']
print('Purging NaN from Dataframe...',end='')
 try:
df[df == np.Inf] = np.NaN
df[df == np.NINF] =np.NaN
df.fillna(0,inplace=True)
 print('Done!')
 except:
print('Nothing to Purge')
 err += 1
if is_train:
print('End of Operation')
 return df
else:
print('Retrive maxPlace...',end='')
 test_edge = df['maxPlace']
test_edge = pd.DataFrame(test_edge)
 print('Done!')
 print('End of Operation')
 return df,test_id,test_edge
data.LotShape.value_counts()<data_type_conversions>
df_train,target = preprocessing(is_train=True )
data['LotFrontage']=data.LotFrontage.fillna(data.LotAreaSqr )<drop_column>
df_train = feature_managing(df_train,is_train=True,lowfeature=True,valuematchtype=True )
data = data.drop(['LotAreaSqr'],axis=1 )<drop_column>
df_train = reduce_mem_usage(df_train )
data = data.drop(['Utilities'],axis=1 )<filter>
print('scaling the dataset')
 scaler = StandardScaler()
scaler.fit(df_train)
 scaled_train = scaler.transform(df_train)
 print('scaler ready!')
 mlpreg = MLPRegressor(hidden_layer_sizes=(35,20,15),max_iter=500)
 print("begin fitting...",end='')
 mlpreg.fit(scaled_train,target)
 print("Done!" )
data[data.Exterior1st.isna() ]<count_values>
res,submis = prediction(reducemem=True,returnall=True,smoothedge=True,csvwrite=True )
data[(data.YearBuilt>1935)&(data.YearBuilt<1945)&(data.Neighborhood=='Edwards')].Exterior1st.value_counts()<data_type_conversions>
targetframe = pd.DataFrame(target )
data['Exterior1st']=data.Exterior1st.fillna('MetalSd')
 data['Exterior2nd']=data.Exterior2nd.fillna('MetalSd' )<filter>
resframe = pd.DataFrame(res)
 resframe.plot()