Multiple Linear Regression

0.0(0)
Studied by 0 people
call kaiCall Kai
learnLearn
examPractice Test
spaced repetitionSpaced Repetition
heart puzzleMatch
flashcardsFlashcards
GameKnowt Play
Card Sorting

1/24

encourage image

There's no tags or description

Looks like no tags are added yet.

Last updated 7:51 AM on 3/16/26
Name
Mastery
Learn
Test
Matching
Spaced
Call with Kai

No analytics yet

Send a link to your students to track their progress

25 Terms

1
New cards

Question 1:
The code used to import the pandas library with its standard alias 'pd'

import pandas as pd

2
New cards

Question 2:
The code used to import the numpy library with its standard alias 'np'

import numpy as np

3
New cards

Question 3:
The code used to import matplotlib's pyplot module with its standard alias 'plt'

import matplotlib.pyplot as plt

4
New cards

Question 4:
The import statement for the traintestsplit function from scikit-learn

from sklearn.modelselection import traintest_split

5
New cards

Question 5:
The import statement for the LinearRegression class from scikit-learn

from sklearn.linear_model import LinearRegression

6
New cards

Question 6:
The import statement for both r2score and meansquared_error metrics from scikit-learn

from sklearn.metrics import r2score, meansquared_error

7
New cards

Question 7:
The function used to read a CSV file into a pandas DataFrame

pd.read_csv("filename.csv")

8
New cards

Question 8:
The method used to display the first few rows of a pandas DataFrame

df.head()

9
New cards

Question 9:
The method used to drop specific columns from a pandas DataFrame

df.drop(columns=['col1', 'col2'])

10
New cards

Question 10:
The method used to calculate the correlation matrix of a pandas DataFrame

df.corr()

11
New cards

Question 11:
The syntax for selecting multiple columns from a DataFrame to create a feature matrix X

X = df[['col1', 'col2']]

12
New cards

Question 12:
The syntax for selecting a single column from a DataFrame to create a target variable y

y = df['target_column']

13
New cards

Question 13:
The complete function call to split data into training and testing sets with 20% test size and random_state=42

Xtrain, Xtest, ytrain, ytest = traintestsplit(X, y, testsize=0.2, randomstate=42)

14
New cards

Question 14:
The code to create and instantiate a LinearRegression model

model = LinearRegression()

15
New cards

Question 15:
The method used to train/fit the LinearRegression model on data

model.fit(X, y)

16
New cards

Question 16:
The attribute that stores the regression coefficients (slopes) after fitting

model.coef_

17
New cards

Question 17:
The attribute that stores the y-intercept value after fitting

model.intercept_

18
New cards

Question 18:
The method used to make predictions with a trained LinearRegression model

model.predict(X_test)

19
New cards

Question 19:
The function to calculate the R² score given true values and predicted values

r2score(ytest, y_pred)

20
New cards

Question 20:
The function to calculate the Mean Squared Error given true values and predicted values

meansquarederror(ytest, ypred)

21
New cards

Question 21:
The code to predict CO2 emission for a single car with volume 3000 and weight 1500

model.predict([[3000, 1500]])

22
New cards

Question 22:
The complete code to load the CO2_CarEmission.csv file

df = pd.readcsv("CO2CarEmission.csv")

23
New cards

Question 23:
The complete code to drop the 'Car' and 'Model' columns from df

df = df.drop(columns=['Car', 'Model'])

24
New cards

Question 24:
The complete code to assign Volume and Weight as features X, and CO2 as target y

X = df[['Volume', 'Weight']]
y = df['CO2']

25
New cards

Question 25:
The complete code to train the model on the entire dataset and then predict on the test set

model = LinearRegression()
model.fit(X, y)
ypred = model.predict(Xtest)

Explore top notes

note
4. Cams and Followers
Updated 1111d ago
0.0(0)
note
Chapter 15: The Bureaucracy
Updated 1043d ago
0.0(0)
note
Creative Destruction
Updated 1221d ago
0.0(0)
note
Chapter 4: Writing Email Replies
Updated 1073d ago
0.0(0)
note
romeo & juliet final - notes
Updated 739d ago
0.0(0)
note
Chapter 14: Advertising
Updated 1329d ago
0.0(0)
note
4. Cams and Followers
Updated 1111d ago
0.0(0)
note
Chapter 15: The Bureaucracy
Updated 1043d ago
0.0(0)
note
Creative Destruction
Updated 1221d ago
0.0(0)
note
Chapter 4: Writing Email Replies
Updated 1073d ago
0.0(0)
note
romeo & juliet final - notes
Updated 739d ago
0.0(0)
note
Chapter 14: Advertising
Updated 1329d ago
0.0(0)

Explore top flashcards

flashcards
6.1.1 Earth, Moon, & Sun System
30
Updated 928d ago
0.0(0)
flashcards
Ap Hug Unit 4
36
Updated 1182d ago
0.0(0)
flashcards
Roots List 13
25
Updated 143d ago
0.0(0)
flashcards
Tejido linfático
44
Updated 1017d ago
0.0(0)
flashcards
ACRE Prep
57
Updated 739d ago
0.0(0)
flashcards
6.1.1 Earth, Moon, & Sun System
30
Updated 928d ago
0.0(0)
flashcards
Ap Hug Unit 4
36
Updated 1182d ago
0.0(0)
flashcards
Roots List 13
25
Updated 143d ago
0.0(0)
flashcards
Tejido linfático
44
Updated 1017d ago
0.0(0)
flashcards
ACRE Prep
57
Updated 739d ago
0.0(0)