Kaggle competition: SIIM-ISIC Melanoma Classification
<SOS> metric: MCAUC Kaggle data source: siim-isic-melanoma-classification<train_model>
!pip install xgboost
print("Scores for all Parameter Combination:
",p.cv_results_['mean_test_score'])
 print("
Optimal C and Gamma Combination: ",p.best_params_)
 print("
Maximum Accuracy acheieved on LeftOut Data: ",p.best_score_ )<find_best_params>
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')
clf_rf = RandomForestClassifier(
 random_state=42,
n_estimators=p.best_params_['n_estimators'],
warm_start=p.best_params_['warm_start'],
max_depth=p.best_params_['max_depth'],
min_samples_leaf=p.best_params_['min_samples_leaf'], 
)
<predict_on_test>
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' )
clf_rf = clf_rf.fit(train, train_labels)
 y_pred=clf_rf.predict(test)
 accuracy_score(test_labels, y_pred )<compute_train_metric>
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()
cv_value=5
scores=cross_val_score(clf_dt, X, y, cv=cv_value)
 print("Decision Trees Accuracy: %0.2f(+/- %0.2f)" %(scores.mean() , scores.std() * 2))
scores=cross_val_score(clf_rf, X, y, cv=cv_value)
 print("Random Forest Accuracy: %0.2f(+/- %0.2f)" %(scores.mean() , scores.std() * 2))<train_model>
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()
clf_rf = clf_rf.fit(X, y )<predict_on_test>
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 )
y_pred=clf_rf.predict(test_data )<save_to_csv>
param = {
'booster':'gbtree',
'eta': 0.3,
'num_class': 2,
'max_depth': 8
}
epochs = 100
my_submission = pd.DataFrame({'PassengerId': test_data.index.values, 'Survived': y_pred})
 my_submission.to_csv('submission.csv', index=False)
 my_submission<import_modules>
clf = xgb.XGBClassifier(n_estimators=1000,
max_depth=8,
objective='multi:softprob',
seed=0,
nthread=-1,
learning_rate=0.015,
num_class = 2,
scale_pos_weight =(32542/584))
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
import seaborn as sns<load_from_csv>
clf.fit(x_train, y_train)
data_train = pd.read_csv(".. /input/train.csv")
 data_test = pd.read_csv(".. /input/test.csv" )<prepare_x_and_y>
pred_train = clf.predict(x_train )
ntrain = data_train.shape[0]
ntest = data_test.shape[0]
train_label = data_train["SalePrice"]
data_train = data_train.drop(["SalePrice"], axis=1)
 all_data = pd.concat(( data_train, data_test)).reset_index(drop=True )<sort_values>
accuracy_score(pred_train, y_train )
total = all_data.isnull().sum().sort_values(ascending=False)
 percent =(all_data.isnull().sum() /all_data.isnull().count() ).sort_values(ascending=False)
 missing_data = pd.concat([total, percent], axis=1, keys=['Total', 'Percent'])
 missing_data.head(35 )<data_type_conversions>
sub.target = clf.predict_proba(x_test)[:,1]
sub_tabular = sub.copy()
for col in("PoolQC", "MiscFeature", "Alley", "Fence", "FireplaceQu"):
all_data["has_" + col] = all_data[col].apply(lambda x: 0 if pd.isnull(x)else 1)
 all_data[col] = all_data[col].fillna("None" )<groupby>
sub_public_merge = pd.read_csv('/kaggle/input/incredible-tpus-finetune-effnetb0-b6-at-once/submission_models_blended.csv' )
all_data["LotFrontage"] = all_data.groupby("Neighborhood")["LotFrontage"].transform(
 lambda x: x.fillna(x.mean()))<data_type_conversions>
sub.target = sub_public_merge.target *0.80 + sub_tabular.target *0.20
<data_type_conversions><EOS> 
sub.to_csv('submission.csv', index = False )