Kaggle competition: Titanic - Machine Learning from Disaster
<SOS> metric: categorizationaccuracy Kaggle data source: titanic-machine-learning-from-disaster<compute_test_metric>
!/opt/conda/bin/python3.7 -m pip install --upgrade pip
!pip uninstall -y typing
!pip install carefree-learn
df["xgb_pred"] = np.argmax(y_oof, axis=1)
 f1_score(df["open_channels"], df["xgb_pred"], average="macro" )<compute_train_metric>

 file_folder = "/kaggle/input/titanic"
working_folder = "/kaggle/working"
f1_score(df.iloc[:5_000_000]["open_channels"], df.iloc[:5_000_000]["xgb_pred"], average="macro" )<feature_engineering>
def scoring(raw_metrics, mean, std):
return mean + std
def test() :
train_file = f"{file_folder}/train.csv"
test_file = f"{file_folder}/test.csv"
data_config = {"label_name": "Survived"}
hpo = cflearn.tune_with(
 train_file,
model="tree_dnn",
temp_folder=f"{working_folder}/__hpo__",
task_type=TaskTypes.CLASSIFICATION,
estimator_scoring_function=scoring,
data_config=data_config,
num_parallel=5 
)
 results = cflearn.repeat_with(
 train_file,
**hpo.best_param,
models="tree_dnn",
temp_folder=f"{working_folder}/__repeat__",
num_repeat=10, num_jobs=5,
data_config=data_config 
)
 ensemble = cflearn.EnsemblePattern(results.patterns["tree_dnn"])
 predictions = ensemble.predict(test_file ).ravel()
x_te, _ = results.transformer.data.read_file(test_file, contains_labels=False)
 id_list = DataTuple.with_transpose(x_te, None ).xT[0]
with open(f"{working_folder}/submissions.csv", "w")as f:
f.write("PassengerId,Survived
")
 for test_id, prediction in zip(id_list, predictions):
f.write(f"{test_id},{prediction}
")
 return results
if __name__ == '__main__':
results = test()
df["ensemble_pred"] = df[["wave_pred", "xgb_pred"]].max(axis=1)
 f1_score(df["open_channels"], df["ensemble_pred"], average="macro" )<compute_test_metric>
experiments = results.experiments
ms = {k: list(map(cflearn.load_task, v)) for k, v in experiments.tasks.items() }
print(ms )
f1_score(df.iloc[:5_000_000]["open_channels"], df.iloc[:5_000_000]["ensemble_pred"], average="macro" )<feature_engineering>
model = ms["tree_dnn"][0].model
data = model.tr_data
print("=== Raw ===")
 print(f"Feature dimension : {len(data.raw.x[0])}")
 print()
for line in data.raw.x[:3]:
print(line)
 print(data.raw.y[:3])
 print()
print("=== Converted ===")
 print(f"Feature dimension : {data.converted.x.shape[1]}")
 print(data.converted.x[:3])
 print(data.converted.y[:3])
 print()
print("=== Processed ===")
 print(f"Feature dimension : {data.processed.x.shape[1]}")
 print(data.processed.x[:3])
 print(data.processed.y[:3] )
<save_to_csv><EOS> 
print(model.encoders )