Linear Model in Anthropology
If you found part of a skeleton, from an adult human that lived thousands of years ago, how could you estimate the height of the person that it came from? This exercise is in part inspired by the work of forensic anthropologist Mildred Trotter, who built a regression model for the calculation of stature estimates from human "long bones" or femurs that is commonly used today.
In this exercise, you'll use data from many living people, and the python library scikit-learn
, to build a linear model relating the length of the femur (thigh bone) to the "stature" (overall height) of the person. Then, you'll apply your model to make a prediction about the height of your ancient ancestor.
This exercise is part of the course
Introduction to Linear Modeling in Python
Exercise instructions
- import
LinearRegression
fromsklearn.linear_model
and initialize the model withfit_intercept=False
. - Reshape the pre-loaded data arrays
legs
andheights
, from "1-by-N" to "N-by-1" arrays. - Pass the reshaped arrays
legs
andheights
intomodel.fit()
. - use
model.predict()
to predict the valuefossil_height
for the newly found fossilfossil_leg = 50.7
.
Hands-on interactive exercise
Have a go at this exercise by completing this sample code.
# import the sklearn class LinearRegression and initialize the model
from sklearn.____ import ____
model = LinearRegression(fit_intercept=False)
# Prepare the measured data arrays and fit the model to them
legs = legs.reshape(len(____),1)
heights = heights.reshape(len(____),1)
model.fit(____, heights)
# Use the fitted model to make a prediction for the found femur
fossil_leg = np.array(50.7).reshape(1, -1)
fossil_height = model.predict(____)
print("Predicted fossil height = {:0.2f} cm".format(fossil_height[0,0]))