Project 9 of 10, for Neil
Model Evaluation Clinic
Before a model gives away anyone's place at Neil's stargazing nights, a clinic: the column that knows the answer, preprocessing kept inside the folds, four models compared by cross-validation and a grid search, one look in the bottom drawer, and who the model is wrong about.
Act 6 needs a free account, so your work is saved as you go. Act 1 is open to everyone.
The brief
- NeilWe do stargazing nights on the roof terrace with twelve telescope slots, and they're always booked, but there's always a no-show.
- NeilThen the space station goes over and someone on the waiting list misses it, which is why Yahya's built a model.
- YahyaIt gets ninety-eight per cent, go on, beat that!
- PaulBefore anyone loses a place, let's see what it's using, which model deserves the job and who it's wrong about.
Two seasons of stargazing bookings are in bookings.csv. This season's are locked in the bottom drawer, drawer.csv. Each booking says how many days ahead it was made, the size of the party, the cloud forecast on the day, whether it was a first visit, whether the visitor lives outside the city, whether they signed the visitors' book on the night, and whether they came.
In clinic.py, examine the model before it gives anyone's slot away:
- Find any column that knows the answer by scoring each one alone, and drop it.
- On what's left, find the best number of neighbours for k-NN by grid search, then cross-validate logistic regression, k-NN, a decision tree and a random forest, with the scaling inside a pipeline wherever there is scaling. Choose the best.
- Fit it on every booking, open the drawer once, and score it beside always guessing the commonest answer.
- Report the accuracy for city visitors and those from outside separately, with the share of those who came who would have lost their slot.
Each column alone: days_ahead 0.68 party 0.60 cloud 0.67 first_visit 0.60 signed_book 0.98 Dropped: signed_book Best number of neighbours: 5 logistic 0.736 neighbours 0.764 tree 0.750 forest 0.778 Chosen: forest Bottom drawer accuracy: 0.77 Always guessing the commonest: 0.71 city accuracy 0.85, slot given away 0.09 outside accuracy 0.35, slot given away 0.64
What you learn
What's in it
- Five turns at validation
- A column that knows the answer
- The morning after
- Steps that travel together
- Fix Riya's version
- Trying every setting
- How many fittings
- How Paul would choose
- Who is it wrong about?
- How Paul would check it
- What it can't know
- Run the clinic
- Ship it