Kaggle competition: PUBG Finish Placement Prediction (Kernels Only)
td = pd.read_csv("/kaggle/input/titanic/train.csv")
 td["Cabin"]=td.Cabin.str[0]<drop_column>
from xgboost import XGBRegressor
expected_values = train_data["Survived"]
train_data.drop("Survived", axis=1, inplace=True )<drop_column>
train = pd.read_csv('.. /input/train_V2.csv')
 test = pd.read_csv('.. /input/test_V2.csv')
 submit = pd.read_csv('.. /input/sample_submission_V2.csv' )
train_data.drop("Cabin", axis=1, inplace=True)
 test_data.drop("Cabin", axis=1, inplace=True )<split>
y_train = train['winPlacePerc']
x_train = train.drop(['Id','groupId','matchId','winPlacePerc', 'matchType'], axis=1)
 x_test = test.drop(['Id','groupId','matchId','matchType'], axis=1 )
X = train_data.values
y = expected_values.values
X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.2, random_state=1, stratify=y )<choose_model_class>
x_train['matchDuration'] = x_train['matchDuration'].fillna(x_train['matchDuration'].mean())
 x_test['matchDuration'] = x_test['matchDuration'].fillna(x_test['matchDuration'].mean() )
model = RandomForestClassifier(criterion='gini',
n_estimators=1750,
max_depth=7,
min_samples_split=6,
min_samples_leaf=6,
max_features='auto',
oob_score=True,
random_state=42,
n_jobs=-1,
verbose=1 )<predict_on_test>
x_train = x_train.fillna(x_train.mean())
 x_test = x_test.fillna(x_test.mean())
 y_train = y_train.fillna(y_train.mean() )
model.fit(X_train, y_train)
 y_pred_train = model.predict(X_train)
 y_pred_test = model.predict(X_test )<compute_test_metric>
reg = XGBRegressor(n_estimators=1650, max_depth=9, learning_rate=0.007 )
print("Training accuracy: ", accuracy_score(y_train, y_pred_train))
print("Testing accuracy: ", accuracy_score(y_test, y_pred_test))<create_dataframe>
reg.fit(x_train, y_train, eval_set=[(x_train, y_train)] )
column_values = ['Pclass', 'Sex', 'Age', 'SibSp', 'Parch', 'Fare', 'Embarked']
X_train_df = pd.DataFrame(data = X_train,
columns = column_values)
 X_test_df = pd.DataFrame(data = X_test,
columns = column_values )<compute_test_metric>
reg.score(x_train, y_train )
feature_importance(model )<train_model>
output = pd.DataFrame()
output['Id'] = submit['Id']
y = reg.predict(x_test)
 y[y<0]=0
output['winPlacePerc'] = y
output.to_csv('output.csv', index=False )