Kaggle competition: Mercedes-Benz Greener Manufacturing
model.fit(x_train,y_train )<predict_on_test>
df_train = pd.read_csv(".. /input/train.csv")
 df_test = pd.read_csv(".. /input/test.csv")
 print("Train shape : ", df_train.shape)
 print("Test shape : ", df_test.shape)
 df_train.head()
y_pred = model.predict(x_test )<load_from_csv>
df_train.nunique()
s = pd.read_csv(".. /input/titanic/gender_submission.csv" )<create_dataframe>
alldata = pd.concat([df_train, df_test], sort=False )
f = {"PassengerId":s["PassengerId"],"Survived":y_pred}
f = pd.DataFrame(f )<save_to_csv>
from sklearn.preprocessing import LabelEncoder
f.to_csv('output.csv',index=False )<install_modules>
le = LabelEncoder()
!pip install pyspark<set_options>
cata_cols = ['X0', 'X1', 'X2', 'X3', 'X4', 'X5', 'X6', 'X8']
alldata[cata_cols] = alldata[cata_cols].apply(le.fit_transform )
spark = SparkSession.builder.appName('classification' ).getOrCreate()<import_modules>
df_train = alldata[:len(df_train)]
df_test = alldata[len(df_train):]
from itertools import chain
from pyspark.sql.functions import count, mean, when, lit, create_map, regexp_extract<load_from_csv>
y = df_train['y']
df_train.drop(['y'], axis=1, inplace=True)
 df_test.drop(['y'], axis=1, inplace=True )
df1 = spark.read.csv('.. /input/titanic/train.csv',\
header=True, inferSchema=True)
 df2 = spark.read.csv('.. /input/titanic/test.csv', \
header=True, inferSchema=True )<data_type_conversions>
df_train = pd.read_csv(".. /input/train.csv")
 df_test = pd.read_csv(".. /input/test.csv")
 print("Train shape : ", df_train.shape)
 print("Test shape : ", df_test.shape)
 alldata = pd.concat([df_train, df_test], sort=False)
 le = LabelEncoder()
cata_cols = ['X0', 'X1', 'X2', 'X3', 'X4', 'X5', 'X6', 'X8']
alldata[cata_cols] = alldata[cata_cols].apply(le.fit_transform)
 df_train = alldata.iloc[:len(df_train), :]
df_test = alldata.iloc[len(df_train):, :]
y = df_train['y']
df_train.drop(['y'], axis=1, inplace=True)
 df_test.drop(['y'], axis=1, inplace=True )
df1.limit(5 ).toPandas()<count_values>
from catboost import CatBoostRegressor
print('Number of rows: \t', df1.count())
 print('Number of columns: \t', len(df1.columns))<count_missing_values>
model = CatBoostRegressor(random_seed=42, depth = 4 )
for col in df1.columns:
print(col.ljust(20), df1.filter(df1[col].isNull() ).count() )<data_type_conversions>
model.fit(df_train, y, cat_features=[1,2,3,4,5,6,7,8] )
df1 = df1.fillna({'Embarked': 'S', 'Fare':14.45} )<categorify>
preds = model.predict(df_test )
<drop_column><EOS> 
submmision = pd.read_csv(".. /input/sample_submission.csv")
 submmision["y"] = preds
submmision.to_csv("benz_catboost.csv", index=False )