0
0
NumPydata~5 mins

Linear regression with np.polyfit() in NumPy - Cheat Sheet & Quick Revision

Choose your learning style9 modes available
Recall & Review
beginner
What does np.polyfit() do in simple terms?

np.polyfit() finds the best straight line (or curve) that fits your data points. It helps you understand the relationship between two sets of numbers.

Click to reveal answer
beginner
What are the main inputs to np.polyfit()?

You give it two lists or arrays: one for the x-values (input) and one for the y-values (output). You also tell it the degree of the polynomial (1 for a straight line).

Click to reveal answer
beginner
What does the output of np.polyfit(x, y, 1) represent?

It returns two numbers: the slope (how steep the line is) and the intercept (where the line crosses the y-axis).

Click to reveal answer
beginner
How can you use the result of np.polyfit() to predict new values?

Use the slope and intercept to make a formula: y = slope * x + intercept. Plug in new x-values to get predicted y-values.

Click to reveal answer
beginner
Why is linear regression useful in real life?

It helps you find trends and make predictions, like estimating house prices based on size or predicting sales from advertising spend.

Click to reveal answer
What degree should you use in np.polyfit() for a straight line?
A1
B2
C0
D3
What does the first number returned by np.polyfit(x, y, 1) represent?
AIntercept
BSlope
CCorrelation
DResidual
If you want to predict y for a new x, what formula do you use after np.polyfit()?
Ay = slope * x + intercept
By = intercept * x + slope
Cy = x / slope + intercept
Dy = slope + intercept * x
Which Python library provides polyfit()?
Apandas
Bmatplotlib
Cscikit-learn
Dnumpy
What kind of relationship does linear regression model?
ANon-linear
BRandom
CLinear
DCategorical
Explain how to perform a simple linear regression using np.polyfit() with example data.
Think about giving x and y data, calling polyfit, then using the results.
You got /4 concepts.
    Describe why linear regression is useful and how np.polyfit() helps in data analysis.
    Consider real-life examples like predicting prices or sales.
    You got /4 concepts.