Titanic
| Python source code | Jupyter Notebook | Task |
|---|---|---|
| titanic.py | titanic.ipynb | Machine Learning ๐ |
Titanic is a famous playground competition hosted by Kaggle (here), so I'll simply copy-paste its brief description here:
This is the legendary Titanic ML competition โ the best, first challenge for you to dive into ML competitions and familiarize yourself with how the Kaggle platform works.
The competition is simple: use machine learning to create a model that predicts which passengers survived the Titanic shipwreck.
Here are the frist few rows of the train.csv of Titanic:
And the first few rows of the test.csv:
What we need to do is to predict the Survived column in test.csv.
Configurations
Since the target column is not the last column (which is the default setting of carefree-learn), we need to manually configure it:
And you're all set! Notice that only the label_name needs to be provided, and carefree-learn will find out the corresponding target column for you๐
Build Your Model
For instance, we'll use the famous Wide & Deep model. Unlike other libraries, carefree-learn supports file-in:
Evaluate Your Model
After building the model, we can directly evaluate our model with a file (file-out):
Then you will see something like this:
Our model achieved an accuracy of 0.857463, not bad!
info
Note that this performance may vary and is not exactly the training performance, because carefree-learn will automatically split out the cross validation dataset for you.
Making Predictions
Again, we can directly make predictions with a file (file-out):
Submit Your Results
If you reached here, we have actually already completed this Titanic task! All we need to do is to convert the predictions into a submission file:
After running these codes, a submissions.csv will be generated and you can submit it to Kaggle directly. In my personal experience, it could achieve 0.77272.
Conclusions
Since Titanic is just a small toy dataset, using Neural Network to solve it might actually 'over-killed' (or, overfit) it, and that's why we decided to conclude here instead of introducing more fancy techniques (e.g. ensemble, AutoML, etc.). We hope that this small example can help you quickly walk through some basic concepts in carefre-learn, as well as help you leverage carefree-learn in your own tasks!