Kaggle competition: Cloud Faculty Institute Workshop
<SOS> metric: meanfscore Kaggle data source: cloud-faculty-institute-workshop<count_unique_values>
%matplotlib inline
cats = []
for col in X_train.columns:
if X_train[col].dtype == 'object':
cats.append(col)
 print(col, X_train[col].nunique() )<categorify>
train = pd.read_csv('.. /input/train.csv')
 test = pd.read_csv('.. /input/test.csv' )
col = 'purpose'
encoder = OneHotEncoder()
enc_train = encoder.fit_transform(pd.DataFrame(X_train[col].values))
enc_test = encoder.transform(pd.DataFrame(X_test[col].values))<prepare_x_and_y>
train = pd.read_csv('.. /input/train.csv')
 test = pd.read_csv('.. /input/test.csv' )
X_train.fillna(X_train.median() , inplace=True)
 X_test.fillna(X_train.median() , inplace=True )<categorify>
train.isnull().sum()
oelist = cats
for c in oelist:
oe=OrdinalEncoder()
oe.fit(pd.DataFrame(X_train[c]))
X_train[c]=oe.fit_transform(pd.DataFrame(X_train[c]))
X_test[c]=oe.transform(pd.DataFrame(X_test[c]))<split>
test.isnull().sum()
X_temp = pd.concat([X_train, y_train], axis=1)
 summary = X_temp.groupby(['emp_title'])['loan_condition'].mean()
X_test['emp_title'] = X_test['emp_title'].map(summary)
 skf = StratifiedKFold(n_splits=5, random_state=71, shuffle=True)
 enc_train = Series(np.zeros(len(X_train)) , index=X_train.index)
 for i,(train_ix, val_ix)in enumerate(( skf.split(X_train, y_train))):
X_train_, _ = X_temp.iloc[train_ix], y_train.iloc[train_ix]
X_val, _ = X_temp.iloc[val_ix], y_train.iloc[val_ix]
summary = X_train_.groupby(['emp_title'])['loan_condition'].mean()
enc_train.iloc[val_ix] = X_val['emp_title'].map(summary)
 X_train['emp_title'] = enc_train<prepare_x_and_y>
test.isnull().sum()
X_train.fillna(X_train.mean() , axis=0, inplace=True)
 X_test.fillna(X_train.mean() , axis=0, inplace=True )<define_variables>
train.Outcome.value_counts()
X_temp = X_train
y_target = y_train
X_train_bin = X_temp
X_test_bin = X_test<split>
X = train.drop(['Outcome'], axis = 1)
 y = train.Outcome
X_train_, X_val, y_train_, y_val= train_test_split(X_train_bin, y_target, test_size=0.05, random_state=71 )<choose_model_class>
clf = GradientBoostingClassifier(n_estimators = 105)
 clf.fit(X,y )
clf = LGBMClassifier(boosting_type='gbdt', class_weight=None, colsample_bytree=0.9,
importance_type='split', learning_rate=0.05, max_depth=-1,
min_child_samples=20, min_child_weight=0.001, min_split_gain=0.0,
n_estimators=9999, n_jobs=-1, num_leaves=15, objective=None,
random_state=71, reg_alpha=0.0, reg_lambda=0.0, silent=True,
subsample=1.0, subsample_for_bin=200000, subsample_freq=0 )<train_model>
predicted = clf.predict(test )
<create_dataframe><EOS> 
output = pd.DataFrame(predicted,columns = ['Outcome'])
 test = pd.read_csv('.. /input/test.csv')
 output['Id'] = test['Id']
output[['Id','Outcome']].to_csv('submission_cloudy10.csv', index = False)
 output.head()