matplotlib Flashcards
How to produce a scatter graph and label the axis
import matplotlib.pyplot as plt
plt. scatter(x, y)
plt. xlabel(‘label name’, fontsize = 20)
plt. ylabel(‘label name’, fontsize = 20)
plt. show()
Adding a regression line and seeing its summary (regression table)
import statsmodels.api
x1 = sm.add_constant(x)
result = sm.OLS(y, x1).fit()
result.summary()
Seaborn
This is a library based off matplotlib that can produce better data visualisations - they look a lot better
import seaborn as sns
sns.set()
Analysing the regression table - coefficient table
Constant represents the y intercept
The number below this represents the gradient
These can be used to determine the equation of the regression line so it can be plotted
R - squared
A measure of how close the data is fitted to the regression line
It is a value between 0 and 1 and the closer to one the better