Kaggle competition: PUBG Finish Placement Prediction (Kernels Only)
imputer = SimpleImputer(missing_values = np.nan, strategy= 'mean')
 imputer = imputer.fit(X_train[:, 3:4])
 X_train[:, 3:4] = imputer.transform(X_train[:, 3:4])
 imputer = imputer.fit(X_test[:, 3:4])
 X_test[:, 3:4] = imputer.transform(X_test[:, 3:4])
 X_train = np.delete(X_train, [4], 1)
 X_test = np.delete(X_test, [4], 1 )<categorify>
df_train = pd.read_csv(".. /input/train_V2.csv")
 df_test = pd.read_csv(".. /input/test_V2.csv")
 print("Train data set :
",df_Train.head())
 print("Test data set :
", df_Test.head() )
ct = ColumnTransformer(
 [('oh_enc', OneHotEncoder(sparse=False), [2]),],
remainder='passthrough' 
)
 X_train = ct.fit_transform(X_train)
 X_test = ct.fit_transform(X_test)
 labelencoder_y = LabelEncoder()
y_train = labelencoder_y.fit_transform(y_train )<prepare_x_and_y>
df_train.loc[df_train['winPlacePerc'].isna() ==True, 'winPlacePerc']= 0.5
X_train = np.delete(X_train, [1], 1)
 print(X_train[0:5, :])
 X_train.shape<drop_column>
df_test['winPlacePerc']= 0.0
df_train['Type']= 'Train'
df_test['Type']= 'Test'
print(df_train.shape, df_test.shape )
X_test = np.delete(X_test, [1], 1)
 print(X_test[0:5, :])
 X_test.shape<normalization>
df= pd.concat([df_train, df_test], ignore_index=True )
sc_X = StandardScaler()
X_train = sc_X.fit_transform(X_train)
 X_test = sc_X.transform(X_test )<choose_model_class>
df= reduce_mem_usage(df )
classifier = LogisticRegression()
classifier.fit(X_train, y_train)
 y_pred = classifier.predict(X_test)
 acc_log = round(classifier.score(X_train, y_train)* 100, 2)
 acc_log 
<compute_train_metric>
Y_Column = 'winPlacePerc'
ColumnList = ['assists', 'boosts', 'damageDealt', 'DBNOs',
'headshotKills', 'heals', 'killPlace', 'killPoints', 'kills',
'killStreaks', 'longestKill', 'maxPlace', 'numGroups', 'revives',
'rideDistance', 'roadKills', 'swimDistance', 'teamKills',
'vehicleDestroys', 'walkDistance', 'weaponsAcquired', 'winPoints']
for colname in ColumnList:
df[colname+ '_1']= df[colname]/(max(df[colname])- min(df[colname]))
print(colname,'_1',' created')
 df['totalDistance'] = df['rideDistance'] + df['walkDistance'] + df['swimDistance']
df['kills_assists'] =(df['kills'] + df['assists'])
 df['healthitems'] = df['heals'] + df['boosts']
df['kills_']= df['kills'] + df['longestKill']+ df['killStreaks']
df['killtypes']= df['headshotKills'] + df['roadKills']+ df['teamKills']+ df['vehicleDestroys']
df['Others']= df['damageDealt'] + df['DBNOs']+ df['revives'] + df['weaponsAcquired']
df['Points_'] = df['killPoints'] + df['winPoints']
df['Rank_Points']= df.groupby(by = ['matchId'])['Points_'].rank(ascending= False)
 df['Rank_kills']= df.groupby(by = ['matchId'])['kills_'].rank(ascending= False)
 df['Rank_killassist']= df.groupby(by = ['matchId'])['kills_assists'].rank(ascending= False)
 df['Rank_GroupPoints']= df.groupby(by = ['groupId'])['Points_'].rank(ascending= False)
 df['Rank_Groupkills']= df.groupby(by = ['groupId'])['kills_'].rank(ascending= False)
 df['Rank_killassist']= df.groupby(by = ['groupId'])['kills_assists'].rank(ascending= False)
 ColumnList = df.columns.tolist()
print(ColumnList)
 ColumnList.remove('Id')
 ColumnList.remove('groupId')
 ColumnList.remove('matchId')
 ColumnList.remove('Type')
 ColumnList.remove('winPlacePerc')
 ColumnList.remove('matchType')
 df_Train = df[df['Type']== 'Train']
df_Test = df[df['Type']== 'Test']
df_Train= df_Train.set_index(['Id', 'groupId', 'matchId','Type'])
 df_Test= df_Test.set_index(['Id', 'groupId', 'matchId','Type'])
 X_Train = df_Train[ColumnList]
Y_Train = df_Train[Y_Column]
X_test = df_Test[ColumnList]
print(X_Train.shape, Y_Train.shape, X_test.shape )
svc = SVC()
svc.fit(X_train, y_train)
 y_pred = svc.predict(X_test)
 acc_svc = round(svc.score(X_train, y_train)* 100, 2)
 acc_svc
result[:, 1] = y_pred
result<predict_on_test>
import lightgbm as lgb
from sklearn.metrics import mean_absolute_error
knn = KNeighborsClassifier(n_neighbors = 3)
 knn.fit(X_train, y_train)
 y_pred = knn.predict(X_test)
 acc_knn = round(knn.score(X_train, y_train)* 100, 2)
 acc_knn<compute_train_metric>
%%time
d_train1 = lgb.Dataset(X_Train, label=Y_Train.values)
 params = {}
params['learning_rate'] = 0.09
params['boosting_type'] = 'gbdt'
params['objective'] = 'regression'
params['metric'] = 'mae'
params['sub_feature'] = 0.8
params['num_leaves'] = 1000
params['min_data'] = 1
params['max_depth'] = 400
params['min_gain_to_split']= 0.0000001
clf1 = lgb.train(params, d_train1, 1000)
 y_pred=clf1.predict(X_test)
 print(y_pred)
linear_svc = LinearSVC()
linear_svc.fit(X_train, y_train)
 y_pred = linear_svc.predict(X_test)
 acc_linear_svc = round(linear_svc.score(X_train, y_train)* 100, 2)
 acc_linear_svc<compute_train_metric>
X_test = X_test.reset_index()
X_test["winPlacePerc"] = y_pred
X_test = X_test[['Id',"winPlacePerc"]]
df_test = df_test[['Id','groupId']]
df_test= df_test.merge(X_test, on = ['Id'] )
<train_model><EOS> 
df_test[['Id',"winPlacePerc"]].to_csv("submission.csv", index=False )