From the course: Python Data Analysis
Unlock this course with a free trial
Join today to access over 25,300 courses taught by industry experts.
Fitting models to data - Python Tutorial
From the course: Python Data Analysis
Fitting models to data
- [Instructor] To demonstrate model fitting, we return to our gapminder data. We will take the year 1985 and study the relation of child survival rates and number of babies per woman. We tell Pandas explicitly that the region is a categorical variable. Let's make a quick scatter plot as we learn to do in chapter eight. We map the continents to colors and populations to areas of markers, and since we'll use this plot repeatedly, let's make it into a function. We immediately observe that the numbers of babies per woman decreases with the probability of their survival. This makes sense in a sad, pragmatic way. We will fit models using the extensive Python package stats models where we'll only sketch the surface of what stat models can do, and we will default to its OLS method, which is found in the formula.api module. OLS stands for Ordinary Least Squares. Least squares means that models are fit by minimizing the sum of square differences between model predictions and observations…
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.