Kaggle competition: SIIM-ISIC Melanoma Classification
<SOS> metric: MCAUC Kaggle data source: siim-isic-melanoma-classification<train_on_grid>
import glob
import pandas as pd
lgbm = lgb.LGBMClassifier(silent=False)
 param_grid = {"max_depth": [8,10,15], "learning_rate" : [0.008,0.01,0.012],
"num_leaves": [80,100,120], "n_estimators": [200,250] }
lgbm_grid = GridSearchCV(lgbm, param_grid, cv=10, refit=True, verbose=1)
 lgbm_grid.fit(X_sc,y_sc, verbose=True)
 sc_lgbm = get_best_score(lgbm_grid)
 pred_all_lgbm = lgbm_grid.predict(X_test_sc )<save_to_csv>
FILES = glob.glob('.. /input/*/prediction_*.csv', recursive=True)
 FILES = [
'.. /input/mysample/tabular_6928.csv',
'.. /input/sub-blend/submission_945_15_folds.csv',
'.. /input/sub-blend/submission_945_5_folds.csv',
'.. /input/melanoma-sub-single-9516/submission_comb(1 ).csv',
'.. /input/train-cv-melanoma/submission.csv',
'.. /input/enet-cv-9430/submission.csv',
'.. /input/mel-9488/submission.csv',
'.. /input/mel-b6-9453/submission.csv'
]
sub_lgbm = pd.DataFrame()
sub_lgbm['PassengerId'] = df_test['PassengerId']
sub_lgbm['Survived'] = pred_all_lgbm
sub_lgbm.to_csv('lgbm.csv',index=False )<import_modules>
sub = pd.read_csv(".. /input/siim-isic-melanoma-classification/sample_submission.csv")
 del sub['target']
w = [0.05, 0.1, 0.1, 0.1, 0.15, 0.15, 0.15, 0.2]
from sklearn.ensemble import VotingClassifier<train_on_grid>
for counter, f in enumerate(FILES):
print(counter)
 print(f )
clf1 = LogisticRegression(random_state=1)
 clf2 = RandomForestClassifier(random_state=1)
 clf3 = GaussianNB()
eclf = VotingClassifier(estimators=[('lr', clf1),('rf', clf2),('gnb', clf3)], voting='soft')
 params = {'lr__C': [1.0, 100.0], 'rf__n_estimators': [20, 200],}
with ignore_warnings(category=DeprecationWarning):
votingclf_grid = GridSearchCV(estimator=eclf, param_grid=params, cv=10)
 votingclf_grid.fit(X_sc,y_sc)
 sc_vot1 = get_best_score(votingclf_grid )<choose_model_class>
df = pd.read_csv(f )
clf4 = GradientBoostingClassifier()
clf5 = SVC()
clf6 = RandomForestClassifier()
eclf_2 = VotingClassifier(estimators=[('gbdt', clf4), 
('svc', clf5), 
('rf', clf6)], voting='soft')
 params = {'gbdt__n_estimators': [50], 'gbdt__min_samples_split': [3],
'svc__C': [10, 100] , 'svc__gamma': [0.1,0.01,0.001] , 'svc__kernel': ['rbf'] , 'svc__probability': [True],
'rf__max_depth': [7], 'rf__max_features': [2,3], 'rf__min_samples_split': [3] }
with ignore_warnings(category=DeprecationWarning):
votingclf_grid_2 = GridSearchCV(estimator=eclf_2, param_grid=params, cv=10)
 votingclf_grid_2.fit(X_sc,y_sc)
 sc_vot2_cv = get_best_score(votingclf_grid_2 )<save_to_csv>
df.columns = ['image_name', str(counter)]
df[str(counter)] *= w[counter]
df.head()
with ignore_warnings(category=DeprecationWarning):
pred_all_vot2 = votingclf_grid_2.predict(X_test_sc)
 sub_vot2 = pd.DataFrame()
sub_vot2['PassengerId'] = df_test['PassengerId']
sub_vot2['Survived'] = pred_all_vot2
sub_vot2.to_csv('vot2.csv',index=False )<import_modules>
for counter, f in enumerate(FILES):
df = pd.read_csv(f)
 df.columns = ['image_name', str(counter)]
df[str(counter)] *= w[counter]
sub = sub.merge(df, on="image_name" )
from mlxtend.classifier import StackingClassifier<define_search_model>
image_name = sub.image_name
sub = sub.drop(columns = ["image_name"])
 target = sub.sum(axis = 1 )
<save_to_csv><EOS> 
pd.DataFrame({
'image_name' : image_name,
'target' : target
} ).to_csv('submission_b.csv', index=False )