0% found this document useful (0 votes)
50 views12 pages

Presentation 37

The document discusses bivariate analysis which analyzes the relationship between two variables. It covers the importance of bivariate analysis, different ways to perform it including scatter plots, correlation coefficients and simple linear regression. Examples of using pandas and matplotlib to create scatter plots and line plots for bivariate data are also provided.

Uploaded by

60 Vibha Shree.S
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
50 views12 pages

Presentation 37

The document discusses bivariate analysis which analyzes the relationship between two variables. It covers the importance of bivariate analysis, different ways to perform it including scatter plots, correlation coefficients and simple linear regression. Examples of using pandas and matplotlib to create scatter plots and line plots for bivariate data are also provided.

Uploaded by

60 Vibha Shree.S
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 12

BIVARIATE ANALYSIS

What is Bivariate Analysis ?


Importance of Bivariate Analysis
Agenda Bivariate Plotting
Ways to perform Bivariate analysis
What is bivariate analysis ?

The bivariate analysis aims to


The term bivariate
determine if there is a
analysis refers to the analysis
statistical link between the
of two variables.
two variables.
Bivariate Analysis helps in identifying trends and patterns

Importance of Bivariate Analysis is used to find the relationship between


cause and effect
bivariate
It helps researchers make prediction
analysis
It helps in decision making
Bivariate plotting
with pandas
▪ BAR PLOT
import matplotlib.pyplot as plt
plt.figure(figsize=(15, 5))
sns.barplot(x=data['department_name'],
y=data['length_of_service'])
plt.xticks(rotation='90')
Bivariate plotting
with pandas
▪ LINE PLOT
The relationship between two numerical
variables is shown in a line.
import matplotlib.pyplot as plt
plt.figure(figsize=(15, 5))
sns.lineplot(df['petal length'],df['petal
width'],color='darkorange')
Ways to perform bivariate analysis

There are three common ways to perform bivariate analysis:


▪ Scatterplots
▪Correlation Coefficient
▪Simple Linear Regression
Scatter plot
• Data Frame that contains information about two variables: (1) Hours spent studying
and (2) Exam score received by 20 different students:
import pandas as pd
df = pd.DataFrame({'hours': [1, 1, 1, 2, 2, 2, 3, 3, 3, 3,3, 4, 4, 5, 5, 6, 6, 6, 7, 8],

'score': [75, 66, 68, 74, 78, 72, 85, 82, 90, 82,80, 88, 85, 90, 92, 94, 94, 88, 91, 96]})
#view first five rows of DataFrame
df.head()
hours score

0 1 75
1 1 66

2 1 68
3 2 74
4 2 78
Scatter plots
import matplotlib.pyplot as plt
#create scatterplot of hours vs score
plt.scatter(df.hours, df.score)
plt.title('Hours Studied vs. Exam Score')
plt.xlabel('Hours Studied')
plt.ylabel('Exam Score')
A linear regression analysis produces estimates for the slope and intercept of
Simple linear the linear equation predicting an outcome variable, y, based on values of a
regression predictor variable, x. A general form of this equation is shown below:
Y = b2 + b1 * X , Y = b2 – b1 * X
import matplotlib.pyplot as plt

Correlation #create scatterplot of length vs weight


plt.scatter(df.length, df.weight)

coefficient
plt.title('Scatter plot of viper length
and weight')
plt.xlabel('viper length(cm)')
plt.ylabel('viper weight(g)')
Thank you

You might also like