Kaggle competition: SIIM-ISIC Melanoma Classification
<SOS> metric: MCAUC Kaggle data source: siim-isic-melanoma-classification<create_dataframe>
!pip install xgboost
test_pred = pd.DataFrame(test_pred_2, columns=['SalePrice'] )<save_to_csv>
train= pd.read_csv('.. /input/siim-isic-melanoma-classification/train.csv')
 test= pd.read_csv('.. /input/siim-isic-melanoma-classification/test.csv')
 sub = pd.read_csv('.. /input/siim-isic-melanoma-classification/sample_submission.csv')
 train.head()
train.target.value_counts()
out = pd.DataFrame({'Id': hot_two['Id'], 'SalePrice': test_pred_2})
 out.to_csv('submission.csv', index=False,header=True )<set_options>
train['sex'] = train['sex'].fillna('na')
 train['age_approx'] = train['age_approx'].fillna(0)
 train['anatom_site_general_challenge'] = train['anatom_site_general_challenge'].fillna('na')
 test['sex'] = test['sex'].fillna('na')
 test['age_approx'] = test['age_approx'].fillna(0)
 test['anatom_site_general_challenge'] = test['anatom_site_general_challenge'].fillna('na' )
%matplotlib inline
warnings.filterwarnings('ignore' )<load_from_csv>
train['sex'] = train['sex'].astype("category" ).cat.codes +1
train['anatom_site_general_challenge'] = train['anatom_site_general_challenge'].astype("category" ).cat.codes +1
train.head()
print(os.listdir(".. /input"))
train= pd.read_csv('.. /input/train.csv')
 train_init= pd.read_csv('.. /input/train.csv')
 test= pd.read_csv('.. /input/test.csv')
 test_init= pd.read_csv('.. /input/test.csv')
 train.head()<prepare_output>
test['sex'] = test['sex'].astype("category" ).cat.codes +1
test['anatom_site_general_challenge'] = test['anatom_site_general_challenge'].astype("category" ).cat.codes +1
test.head()
train.set_index('PassengerId', inplace=True)
 test.set_index('PassengerId', inplace=True)
 train.head()<count_missing_values>
x_train = train[['sex', 'age_approx','anatom_site_general_challenge']]
y_train = train['target']
x_test = test[['sex', 'age_approx','anatom_site_general_challenge']]
train_DMatrix = xgb.DMatrix(x_train, label= y_train)
 test_DMatrix = xgb.DMatrix(x_test )
print("Missing Values: ",train.Name.isna().sum())
 train.Name.head(5 )<feature_engineering>
param = {
'booster':'gbtree',
'eta': 0.3,
'num_class': 2,
'max_depth':
}
epochs = 100
train['title'] = train.Name.map(lambda x: x.split(',')[1].split('.')[0].strip())
 train['title'] = train['title'].replace('Mlle', 'Miss')
 train['title'] = train['title'].replace(['Mme','Lady','Ms','the Countess'], 'Mrs')
 train.title.loc[(train.title != 'Master')&(train.title != 'Mr')&(train.title != 'Miss')&(train.title != 'Mrs')]
train.title.loc[(train.title != 'Master')&(train.title != 'Mr')&(train.title != 'Miss')&(train.title != 'Mrs')] = 'Others'
print("For train data, title count is:
",train['title'].value_counts())
 test['title'] = test.Name.map(lambda x: x.split(',')[1].split('.')[0].strip())
 test['title'] = test['title'].replace('Mlle', 'Miss')
 test['title'] = test['title'].replace(['Mme','Lady','Ms'], 'Mrs')
 test.title.loc[(test.title != 'Master')&(test.title != 'Mr')&(test.title != 'Miss')&(test.title != 'Mrs')] = 'Others'
test=test.drop(['Name'], axis=1)
 train=train.drop(['Name'], axis=1)
<drop_column>
clf = xgb.XGBClassifier(n_estimators=2000,
max_depth=8,
objective='multi:softprob',
seed=0,
nthread=-1,
learning_rate=0.15,
num_class = 2,
scale_pos_weight =(32542/584))
train['family'] = train.SibSp + train.Parch
test['family'] = test.SibSp + test.Parch
test=test.drop(['SibSp','Parch'], axis=1)
 train=train.drop(['SibSp','Parch'], axis=1 )<feature_engineering>
clf.fit(x_train, y_train )
print("Fare Values(first 20)
 ",train.Fare.unique() [:20])
 train['fare_value']=round(train.Fare/10)*10
test['fare_value']=round(test.Fare/10)*10
col=train['fare_value']
print("
Fare values after rounding off for Simplification
",col.unique())
<filter>
clf.predict_proba(x_test)[:,1]
sub.target = clf.predict_proba(x_test)[:,1]
sub_tabular = sub.copy()
test[test.Fare.isna() ]<filter>
sub_public_merge = pd.read_csv('/kaggle/input/submission-9/submission_935.csv')
 sub_mean = pd.read_csv('/kaggle/input/siim-isic-multiple-model-training-stacking-923/submission_mean.csv' )
test[test.Ticket=="3"][test.title=="Mr"][test.Embarked=="S"][test.Pclass==3]<feature_engineering>
sub.target = sub_mean.target *0.1 + sub_public_merge.target *0.7 + sub_tabular.target *0.2
<count_missing_values><EOS> 
sub.head()
sub.to_csv('submission.csv', index = False )