Professional Documents
Culture Documents
Multiple Regression
Multiple Regression
Multiple regression is a linear regression but it uses more than one independent variables.
Example: given Excel sheet has two independent variables (Study and Questions) and one dependent
variable (Marks) for 50 students.
Study: Number of hours the student studied
Questions: Number of past paper questions answered by the student
Marks: Marks got by the student at the examination
Example1- plot each independent variable and dependent variable to understand the relationship
import pandas as pd
import numpy as np
from scipy import stats
import matplotlib.pyplot as plt
Result=pd.read_excel('D:/Ruwan/Courses/Python/Handouts/DataAnalysis/Multiple
Regression/StudyResult.xlsx')
fig, (study,questions) = plt.subplots(nrows=1, ncols=2)
study.scatter(Result['Study'],Result['Marks'])
study.set_title('Relationship between Study hours and Marks')
study.set_xlabel('Study Hours')
study.set_ylabel('Marks')
questions.scatter(Result['Questions'],Result['Marks'])
questions.set_title('Relationship between Answered questions and Marks')
questions.set_xlabel('Number of questions')
questions.set_ylabel('Marks')
plt.show()