0% found this document useful (0 votes)
9 views

Supervised_Learning_Regression_Analysis (1)

oo

Uploaded by

saratabassum043
Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
9 views

Supervised_Learning_Regression_Analysis (1)

oo

Uploaded by

saratabassum043
Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 14

Supervised Learning - Regression

Analysis
Structured Explanation and
Presentation Pattern (SEPP)
Introduction to Supervised
Learning
• Supervised learning uses labeled data for
training.
• Regression is a supervised learning technique
for continuous variable prediction.
Linear Regression
• Predicting continuous values with a single
independent variable.
Linear Regression Formula

• Formula: Y = β0 + β1X + ε
• Y: Dependent variable (target).
• X: Independent variable (predictor).
• β0: Intercept, β1: Coefficient, ε: Error term.
Python Example: Linear Regression

• from sklearn.linear_model import


LinearRegression
model = LinearRegression()
model.fit(X_train, y_train)
predictions = model.predict(X_test)
Multiple Linear Regression
• Extends linear regression to multiple
predictors.
Multiple Linear Regression Formula

• Formula: Y = β0 + β1X1 + β2X2 + ... + βnXn + ε


• Y: Dependent variable.
• Xi: Independent variables.
• βi: Coefficients for each independent variable.
Python Example: Multiple Linear
Regression

• X = data[['Feature1', 'Feature2']]
y = data['Target']
model = LinearRegression()
model.fit(X, y)
Understanding Multicollinearity
• Multicollinearity occurs when predictors are
highly correlated.
Detecting Multicollinearity

• 1. Correlation Matrix: Identify highly


correlated predictors.
• 2. Variance Inflation Factor (VIF): VIF > 5
indicates multicollinearity.
Python Code: Detecting
Multicollinearity

• from statsmodels.stats.outliers_influence
import variance_inflation_factor
vif_data = pd.DataFrame()
vif_data['VIF'] =
[variance_inflation_factor(X.values, i) for i in
range(X.shape[1])]
vif_data['Feature'] = X.columns
Evaluating Regression Models
• Metrics to evaluate regression models include
R-squared, MSE, MAE, and RMSE.
Evaluation Metrics Formulas

• R-squared: Proportion of variance explained


by the model.
• MSE: Mean of squared differences between
actual and predicted values.
• MAE: Mean of absolute differences.
• RMSE: Square root of MSE.
Python Code: Model Evaluation

• from sklearn.metrics import


mean_squared_error, mean_absolute_error,
r2_score
mse = mean_squared_error(y_test,
predictions)
mae = mean_absolute_error(y_test,
predictions)
r2 = r2_score(y_test, predictions)

You might also like