Paul's Python CoursePPC

Project 2 of 10, for Paul

Exam Score Model

Predict a student's final maths grade from what's known after the first term: five columns scaled, five weights learnt by gradient descent, then a curve for absences chosen on validation and tested once, honestly, on 357 real students.

About 3 hours, in 20 steps.

Sign up free to open itLog in

Act 6 needs a free account, so your work is saved as you go. Act 1 is open to everyone.

The brief

  • PaulI mark your tests, and I'd like to know by Christmas who needs a hand, before the marks tell me.
  • PaulDon't worry, not on you lot. We'll use 357 real students from two schools in Portugal, and it's all public.
  • RiyaI've already done one, actually, and it's perfect on every student I gave it.
  • PaulPerfect on the ones you gave it, okay, but what about the rest?

students.csv holds 357 real maths students from two schools in Portugal: their first-term grade, weekly study time (1 to 4), past failures, how often they go out (1 to 5) and absences, and their final grade, all grades out of 20.

In exam_scores.py, guess the final grade from those five columns:

  1. Put the five columns on the same scale, learn one weight for each by walking downhill, and check the weights against the exact answer.
  2. Lock a fifth of the students away for testing. Split the rest into students to learn from and students to choose with.
  3. Ask whether absences need a curve: try absences up to the power 8, score each on the students you choose with, and pick one.
  4. Open the locked-away students once, and compare with guessing the average. Then guess for a new student.
What it prints
Learning from 214 students, choosing with 72, testing with 71
first_term   +2.71
study_time   -0.11
failures     -0.02
going_out    -0.08
absences     -0.32
Least squares agrees: True
degree  training  validation
     1     2.124       1.973
     2     2.119       1.947
     3     2.118       1.958
     4     2.117       1.970
     5     2.117       1.969
     6     2.093       2.663
     7     2.066       5.016
     8     2.036      32.619
Chosen degree: 2
Test error: 1.29 marks
Guessing the average: 3.32 marks
A new student, 12 after the first term: about 12.2 out of 20

What you learn

What's in it

  1. One dial per column
  2. Two students, two weights
  3. Every column the same size
  4. Next Saturday, scaled
  5. Every slope at once
  6. The exact answer, for checking
  7. No column of ones
  8. How Paul would scale it
  9. Fix Riya's version
  10. Five columns, five weights
  11. Lock some away
  12. A fifth for testing
  13. Curves from extra columns
  14. Learning by heart
  15. By heart
  16. A third pile, for choosing
  17. Reading a validation curve
  18. Tested honestly
  19. Ship it