matplotlib Flashcards

You may prefer our related Brainscape-certified flashcards:
1
Q

How to produce a scatter graph and label the axis

A

import matplotlib.pyplot as plt

plt. scatter(x, y)
plt. xlabel(‘label name’, fontsize = 20)
plt. ylabel(‘label name’, fontsize = 20)
plt. show()

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

Adding a regression line and seeing its summary (regression table)

A

import statsmodels.api
x1 = sm.add_constant(x)
result = sm.OLS(y, x1).fit()
result.summary()

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

Seaborn

A

This is a library based off matplotlib that can produce better data visualisations - they look a lot better

import seaborn as sns
sns.set()

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

Analysing the regression table - coefficient table

A

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

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

R - squared

A

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

How well did you know this?
1
Not at all
2
3
4
5
Perfectly