0
0
ML Pythonprogramming~5 mins

Linear regression with scikit-learn in ML Python - Cheat Sheet & Quick Revision

Choose your learning style9 modes available
Recall & Review
beginner
What is the main goal of linear regression?
The main goal of linear regression is to find a straight line that best fits the relationship between input features and a continuous output, so it can predict new values.
Click to reveal answer
beginner
Which scikit-learn class is used to perform linear regression?
The class LinearRegression from sklearn.linear_model is used to create and train a linear regression model.
Click to reveal answer
beginner
What does the fit() method do in scikit-learn's LinearRegression?
The fit() method trains the model by finding the best line that fits the input data and output values.
Click to reveal answer
intermediate
How do you evaluate the performance of a linear regression model in scikit-learn?
You can use the score() method to get the R² score, which shows how well the model explains the data (1 is perfect, 0 means no explanation).
Click to reveal answer
beginner
What is the difference between predict() and fit() methods?
fit() trains the model using data, while predict() uses the trained model to estimate outputs for new input data.
Click to reveal answer
Which method in scikit-learn LinearRegression is used to train the model?
Afit()
Bpredict()
Cscore()
Dtransform()
What does the R² score represent in linear regression?
AThe percentage of data points correctly classified
BHow well the model explains the variance in the data
CThe number of features used in the model
DThe speed of model training
Which scikit-learn module contains the LinearRegression class?
Asklearn.linear_model
Bsklearn.cluster
Csklearn.preprocessing
Dsklearn.metrics
What type of problem is linear regression used for?
AClassification
BClustering
CRegression
DDimensionality reduction
After training a linear regression model, which method predicts new outputs?
Afit_predict()
Bfit()
Cscore()
Dpredict()
Explain the steps to train and evaluate a linear regression model using scikit-learn.
Describe what the R² score tells you about a linear regression model's performance.