1. Learn
  2. /
  3. Courses
  4. /
  5. Introduction to Linear Modeling in Python

Connected

Exercise

Model Components

Previously, you have been given a pre-defined model to work with. In this exercise, you will implement a model function that returns model values for y, computed from input x data, and any input coefficients for the "zero-th" order term a0, the "first-order" term a1, and a quadratic term a2 of a model (see below).

\(y = a_0 + a_1 x + a_2 x^2\)

Recall that "first order" is linear, so we'll set the defaults for this general linear model with a2=0, but later, we will change this for comparison.

Instructions

100 XP
  • Complete the function definition model() so it takes x, and default inputs a0=3, a1=2, a2=0 as input, and returns y.
  • Create an array of values x using the numpy method np.linspace().
  • Pass x into your model() without specifying a0, a1, a2, to get default predicted y values.
  • Use the pre-defined plot_prediction() to see a plot of the resulting data x and y.