…
…
Compare a decision tree and a linear model against a baseline, examine the errors and their cost, weigh readability, write Elena a reasoned model recommendation, and make the same decision on a loan application table.
The unit on other models is over. You have seen the decision tree, the linear model, and the intuition behind a neural network. Now a decision is needed for the help desk's new job, a support program. Elena asks: "Which model should we use? What do we say if a student who is called, or not called, asks 'why?'"
In this task you will compare the two models from lesson 14 on the same 200 fictional student records:
| Step | What you will do |
|---|---|
| 1–2 | Work out the training and test results and weigh the difference |
| 3–4 | Separate the errors by type and probe the sharp rule |
| 5–6 | Compare the cost of the error and the reason sentences of the two models |
| 7 | Write Elena a reasoned model recommendation |
| 8–9 | Make the same decision on the applications of a fictional credit union |
Lessons used: accuracy and the confusion table (9), the cost of the error (10), training and test sets (11), the decision tree (13), the linear model and model choice (14), the neural network and readability (15–16).
You will not write code. You will take numbers from tables and enter them, and write your decisions in your own sentences. There is no single right model: the checklist checks your reasoning, not the model you chose. The student records and loan applications are fictional sample data.
What you'll do
Code cells are for members
You can read the steps. Sign up free to run the code, complete the steps and save your progress.
The unit on other models is over. Elena wants to decide for the support program: "Which model should we use? What do we tell a student who is called, or not called, and asks 'why?'"
You have the two models from lesson 14 and the same split: the 200 fictional student records in grades.csv were shuffled, and 160 became the training set and 40 the test set.
The confusion table of the three models on both sets (lesson 9):
| Model | Set | Said "pass", passed | Said "pass", failed | Said "fail", passed | Said "fail", failed |
|---|---|---|---|---|---|
| Baseline (everyone "pass") | training (160) | 90 | 70 | 0 | 0 |
| Baseline (everyone "pass") |
Code cells are for members
You can read the steps. Sign up free to run the code, complete the steps and save your progress.
| 21 |
| 19 |
| 0 |
| 0 |
| Decision tree | training (160) | 83 | 13 | 7 | 57 |
| Decision tree | test (40) | 18 | 6 | 3 | 13 |
| Linear model | training (160) | 80 | 5 | 10 | 65 |
| Linear model | test (40) | 17 | 0 | 4 | 19 |
This step's code cell is for members.Sign up free
The linear model scored 90 percent on test and the tree 77.5 percent. Before saying "the model with the highest test accuracy is the best model", weigh this difference. In a test of 40 students, one student is worth 2.5 points. In lesson 14 the same measurement was repeated with 21 different shuffles: the average test accuracy came out as 83 percent for the tree and 89 percent for the linear model.
This step's code cell is for members.Sign up free
The 11 test students where the two models disagree or both are wrong (the score is the linear model's score, threshold 286):
| id | Hours | Attendance | Homework | Actual | Tree | Linear | Score |
|---|---|---|---|---|---|---|---|
| 18 | 7 | 84 | 54 | failed | pass | fail | 278 |
| 193 | 7 | 78 | 57 | failed | pass | fail | 269 |
| 144 | 9 | 63 | 83 | passed | pass | fail | 281 |
| 39 | 10 | 61 | 54 | failed | pass | fail | 256 |
| 108 | 8 | 69 | 63 | failed | pass | fail | 265 |
| 99 | 6 | 83 | 56 | passed | fail | fail | 270 |
| 29 | 9 | 84 | 42 | passed | pass | fail | 282 |
| 139 | 3 | 100 | 79 | passed | fail | pass | 303 |
| 194 | 5 | 79 | 63 | passed | fail | fail | 261 |
| 45 | 8 | 60 | 34 | failed | pass | fail | 218 |
| 94 | 8 | 71 | 62 | failed | pass | fail | 268 |
Both models were right on the remaining 29 test students. Among these 11 students, count each model's mistakes by type.
This step's code cell is for members.Sign up free
Look at the 11 students in step 3 again: is there a common pattern in each model's mistakes?
Then probe the sharp rule from lesson 14: a student with attendance below 60 percent fails this course, no matter how much they study. There are three students with attendance below 60 in the test set: (9, 51, 72), (4, 58, 38), (0, 52, 80); all three failed, and both models say "fail". Among all 200 records, 12 students have attendance below 60 and all of them failed. The tree never says "pass" to any of them; the linear model says "pass" to two of them: (16, 59, 96) and (14, 49, 85).
Work out the score the linear model gives these two students yourself, and explain why it says "pass".
This step's code cell is for members.Sign up free
In the support program, the two errors do not carry the same cost (lesson 10). If the model says "pass" and the student is not called, a student who gets no support may fail the course. If the model says "fail" and the student is called, a student who would have passed anyway comes to an extra support session. Which one is expensive? How many times does each model make that mistake?
This step's code cell is for members.Sign up free
Elena's second question: what do we say if a student asks "why?" Write the reason sentence of each model for two test students (lessons 13 and 14).
| id | Hours | Attendance | Homework | Actual | Tree | Linear (score) |
|---|---|---|---|---|---|---|
| 45 | 8 | 60 | 34 | failed | pass | fail (218) |
| 139 | 3 | 100 | 79 | passed | fail | pass (303) |
The tree's sentence states the conditions of the path; the linear model's sentence states the score and the threshold. In at least one sentence, also write what the student would have to change to get a different result.
This step's code cell is for members.Sign up free
Now write Elena a reasoned recommendation of 5–7 sentences. There is no single right answer: you can recommend the linear model, the tree, or a combination of the two; what matters is the reasoning. Your note should include: the model or combination you chose, the test results and how many students the difference is, the expensive error, the sharp rule, readability, the limit (40 test students, a single split), and why you do not recommend the neural network (lessons 15–16: more flexible, but the reason for its decision cannot be read, and this data is small).
This step's code cell is for members.Sign up free
Make the same choice somewhere else. A fictional credit union is trying two models on 10 past applications. Income and debt are in thousands of dollars, and late payments is the number of late payments in the last year:
| # | Income ($ thousand) | Debt ($ thousand) | Late payments | Repaid |
|---|---|---|---|---|
| 1 | 30 | 10 | 0 | yes |
| 2 | 18 | 5 | 1 | yes |
| 3 | 12 | 2 | 0 | no |
| 4 | 40 | 8 | 3 | no |
| 5 | 25 | 20 | 0 | yes |
| 6 | 16 | 4 | 0 | yes |
| 7 | 35 | 5 | 2 | no |
| 8 | 14 | 1 | 1 | no |
| 9 | 22 | 6 | 0 | yes |
| 10 | 28 | 12 | 1 | no |
A model counts as right when it approves an application that was repaid and rejects one that was not repaid. Run each application through the two models and enter the numbers.
This step's code cell is for members.Sign up free
Which model would you recommend to the credit union? Write your reasoning, and write the sentence to be said to a rejected applicant, using a fictional example. Compare it with the decision in the support program: which lesson carries over here too?
This step's code cell is for members.Sign up free