I'm taking my first steps in data science and machine learning. I'm experimenting with a project where I have no idea even what approaches I might start with, so I'd appreciate any leads:
I have a dataset (for explanation's sake) of student graduations. The data set is complete in that it contains the entire population; all records should have a graduation date.
However, due to a record keeping failure, older records have the graduation date missing.
It has the following features:
- For graduations since 2014, we have a graduation_date
- For graduations prior to 2014, the graduation date is missing
- For all students, we have a date of birth
- For many students, graduation will be correlated to date of birth. For example, it may often that they graduate 21 years after they were born. However, some will be mature students so that they could graduate many years after the age of 21.
- The certificate IDs are more or less sequential and numeric. It can be assumed that certificate IDs close to each other therefore represent students graduating at roughly the same time
- The metaphor is somewhat flawed; assume that students can graduate on any day
My challenge is to create an approach that can infer a graduation date for all students, based on the date of birth.
The approach I have been thinking about goes something like this:
- For all students where both dates are available, take a mode (graduation_age)
- Group the students into bins of (say) 1000, according to the sequential certificate ID
- Find the most common month and year of birth for the students in each bin
- Add the mode (graduation_age) to the most common month/year for a particular bin and assign that as the graduation_date for all students in the bin
A sample in pandas might look like:
graduations = [
# Old data with missing graduation dates
{'certificate_id': '090029, 'birth_date': '01/01/1983', 'graduation_date': NaT},
{'certificate_id': '090048, 'birth_date': '04/01/1983', 'graduation_date': NaT},
...
# This is 'normal' students graduating roughly 21 years after
# their birth date
{'certificate_id': '120015, 'birth_date': '01/01/1993', 'graduation_date': 01/03/2014},
{'certificate_id': '120019, 'birth_date': '01/04/1993', 'graduation_date': 04/03/2014},
# However there are many exceptions, mature students or those
# graduating early
{'certificate_id': '120150, 'birth_date': '01/01/1966', 'graduation_date': 05/03/2014},
{'certificate_id': '120155, 'birth_date': '01/04/1996', 'graduation_date': 06/03/2014},
]
df = pd.DataFrame(graduations)
Any help would be appreciated, even if you are able to tell me what this sort of problem is called so that I can research further, or to let me know it is not possible with this dataset. I'm currently not even sure what the correct tags are!
NaN
forNULL
. See: pandas.pydata.org/pandas-docs/stable/missing_data.html. However, reading that again I discovered that technically I should haveNaT
(not a time) - I have edited this. $\endgroup$