human
I am working on the file "BirthweightRegression.ipynb".
The first task is:
We see that both the constant and the weight increase per week is lower for the smokers.
Higher order functions as models
At this point, we could do mx+b all over the place, or we could utilize higher order functions to capture the concept of a model.  Here is an example, building such a model directly from the data.  It takes the set of x and y values and returns a function
that evaluates the model built from that data at a particular x.
Can you write Python code for it?
 Can you provide a the Python code you requested?
assistant
#Here is the Python code you requested.

# Build a linear model from data and return it is a function
def make_lm(x, y):
    m,b = np.polyfit(x, y, 1)
    def lm(a):
        return m*a+b
    return lm 

# Create model of non-smokers that returns estimated weight a function of weeks gestation
nosmoker_weight = make_lm(nosmoke['Gest'], nosmoke['Wgt'])

# Evaluate it at normal gestations
nosmoker_weight(40)

smoker_weight = make_lm(smoke['Gest'], smoke['Wgt'])

smoker_weight(40)