1/24
Looks like no tags are added yet.
Name | Mastery | Learn | Test | Matching | Spaced | Call with Kai |
|---|
No analytics yet
Send a link to your students to track their progress
Question 1:
The code used to import the pandas library with its standard alias 'pd'
import pandas as pd
Question 2:
The code used to import the numpy library with its standard alias 'np'
import numpy as np
Question 3:
The code used to import matplotlib's pyplot module with its standard alias 'plt'
import matplotlib.pyplot as plt
Question 4:
The import statement for the traintestsplit function from scikit-learn
from sklearn.modelselection import traintest_split
Question 5:
The import statement for the LinearRegression class from scikit-learn
from sklearn.linear_model import LinearRegression
Question 6:
The import statement for both r2score and meansquared_error metrics from scikit-learn
from sklearn.metrics import r2score, meansquared_error
Question 7:
The function used to read a CSV file into a pandas DataFrame
pd.read_csv("filename.csv")
Question 8:
The method used to display the first few rows of a pandas DataFrame
df.head()
Question 9:
The method used to drop specific columns from a pandas DataFrame
df.drop(columns=['col1', 'col2'])
Question 10:
The method used to calculate the correlation matrix of a pandas DataFrame
df.corr()
Question 11:
The syntax for selecting multiple columns from a DataFrame to create a feature matrix X
X = df[['col1', 'col2']]
Question 12:
The syntax for selecting a single column from a DataFrame to create a target variable y
y = df['target_column']
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)
Question 14:
The code to create and instantiate a LinearRegression model
model = LinearRegression()
Question 15:
The method used to train/fit the LinearRegression model on data
model.fit(X, y)
Question 16:
The attribute that stores the regression coefficients (slopes) after fitting
model.coef_
Question 17:
The attribute that stores the y-intercept value after fitting
model.intercept_
Question 18:
The method used to make predictions with a trained LinearRegression model
model.predict(X_test)
Question 19:
The function to calculate the R² score given true values and predicted values
r2score(ytest, y_pred)
Question 20:
The function to calculate the Mean Squared Error given true values and predicted values
meansquarederror(ytest, ypred)
Question 21:
The code to predict CO2 emission for a single car with volume 3000 and weight 1500
model.predict([[3000, 1500]])
Question 22:
The complete code to load the CO2_CarEmission.csv file
df = pd.readcsv("CO2CarEmission.csv")
Question 23:
The complete code to drop the 'Car' and 'Model' columns from df
df = df.drop(columns=['Car', 'Model'])
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']
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)