This content originally appeared on DEV Community and was authored by AnuoluwapoDS
This Exploratory Data Analysis is my own personal learning practice in this practice i did analysis from datasets i downloaded from kaggle.com
Plotly For Visualization
Seaborn For Visualization
Import Necessary Libraries
# Libraries for data manipulation
import pandas as pd
import numpy as np
# Libraries for visualization
import seaborn as sns
import matplotlib.pyplot as plt
# Libraries for operatingsystem
import warnings
import os
warnings.filterwarnings('ignore')
Importing Datasets
# Reading the dataset
df = pd.read_csv(r'C:\Users\user\dl-course-data\abalone.csv')
df.head()
Checking data information
# Shape of dataset
df.shape
# Checking the null value in the dataset
df.isnull().sum()
# Infromation about dataset
df.info()
# Statistical description of dataset
df.describe().T
# Extracting a unique values of type column
a = df['Type'].unique()
print(a)
# Finding thee counts of Type
b = df['Type'].value_counts()
print(b)
# Computing Rings by Type
df.groupby(["Type"])["Rings"].count().reset_index(name="count")
Adding ID Column to dataset
df['id'] = range(1, len(df)+1)
df.head()
Correlation
# finding the correlation of datasets
correlation = df.corr()
# Longest Shell has the highest positive correlation value
fig = px.imshow(correlation,text_auto=True,aspect="auto")
fig.show()
# Type M has the highest number of percentage
import plotly.express as px
import pandas as pd
fig = px.pie(df, values='id', names='Type', title='Abalone Type By Height')
fig.update_traces(hoverinfo='label+percent', textinfo='label+percent', textfont_size=20, pull=[0.1,0.1,0.1],
marker=dict(colors=colors, line=dict(color='#000000', width=2)))
fig.show()
#Type M has the highest number of counts
import plotly.express as px
fig = px.bar(df, x='Type', y='id', color='id')
fig.show()
# Include nbins= number_of_bins to specify histogram shape
px.histogram(df, x="id", color="Type")
# Cross tb for Type and Rings for easy understanding
cross_tab = pd.crosstab(df["Type"],df["Rings"],margins=True)
cross_tab
# The F type is the factor determinant for the whole parameters
sns.factorplot(df["Type"],df["Rings"],data=df)
import numpy as np
import pandas as pd
from scipy.stats import chi2_contingency
alpha = 0.05
stats,p_value,degrees_of_freedom,expected = chi2_contingency(cross_tab)
if p_value > alpha:
print(f'Accept Null Hypothesis\n p_value is {p_value}\n Ringss are independent of Types')
else:
print(f'Reject Null Hypothesis\n p_value is {p_value}\n Rings are not independent of Types')
References
This content originally appeared on DEV Community and was authored by AnuoluwapoDS
Print
Share
Comment
Cite
Upload
Translate
Updates
There are no updates yet.
Click the Upload button above to add an update.
APA
MLA
AnuoluwapoDS | Sciencx (2022-03-22T21:36:30+00:00) Exploratory Data Analysis With Chi Square Contingency. Retrieved from https://www.scien.cx/2022/03/22/exploratory-data-analysis-with-chi-square-contingency/
" » Exploratory Data Analysis With Chi Square Contingency." AnuoluwapoDS | Sciencx - Tuesday March 22, 2022, https://www.scien.cx/2022/03/22/exploratory-data-analysis-with-chi-square-contingency/
HARVARDAnuoluwapoDS | Sciencx Tuesday March 22, 2022 » Exploratory Data Analysis With Chi Square Contingency., viewed ,<https://www.scien.cx/2022/03/22/exploratory-data-analysis-with-chi-square-contingency/>
VANCOUVERAnuoluwapoDS | Sciencx - » Exploratory Data Analysis With Chi Square Contingency. [Internet]. [Accessed ]. Available from: https://www.scien.cx/2022/03/22/exploratory-data-analysis-with-chi-square-contingency/
CHICAGO" » Exploratory Data Analysis With Chi Square Contingency." AnuoluwapoDS | Sciencx - Accessed . https://www.scien.cx/2022/03/22/exploratory-data-analysis-with-chi-square-contingency/
IEEE" » Exploratory Data Analysis With Chi Square Contingency." AnuoluwapoDS | Sciencx [Online]. Available: https://www.scien.cx/2022/03/22/exploratory-data-analysis-with-chi-square-contingency/. [Accessed: ]
rf:citation » Exploratory Data Analysis With Chi Square Contingency | AnuoluwapoDS | Sciencx | https://www.scien.cx/2022/03/22/exploratory-data-analysis-with-chi-square-contingency/ |
Please log in to upload a file.
There are no updates yet.
Click the Upload button above to add an update.