-
Notifications
You must be signed in to change notification settings - Fork 1
/
Big Mart Sales EDA _ LIVE.py
192 lines (79 loc) · 2.52 KB
/
Big Mart Sales EDA _ LIVE.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
#!/usr/bin/env python
# coding: utf-8
# In[2]:
import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
import seaborn as sns
get_ipython().run_line_magic('matplotlib', 'inline')
from matplotlib import style
style.use('ggplot')
import warnings
warnings.filterwarnings('ignore')
# In[3]:
df = pd.read_csv('BigMart Sales Data.csv')
df.head()
# In[5]:
df.shape
# In[6]:
df.info()
# In[7]:
df.isnull().sum()
# In[8]:
categorical_data = df.select_dtypes(include=[object])
print("count of categiorical features in the dataset: ",categorical_data.shape[1])
numerical_data = df.select_dtypes(include=[np.float64,np.int64])
print("count of numerical features in the dataset: ",numerical_data.shape[1])
# In[9]:
categorical_data.head()
# In[10]:
sns.countplot(x='Outlet_Size', data=categorical_data)
# In[11]:
categorical_data['Outlet_Size'].value_counts()
# In[12]:
categorical_data['Outlet_Size'] = categorical_data['Outlet_Size'].fillna(categorical_data['Outlet_Size'].mode()[0])
# In[13]:
categorical_data.isnull().sum()
# In[14]:
sns.countplot(x='Item_Fat_Content', data = categorical_data)
# In[15]:
categorical_data.replace({'Item_Fat_Content':{'low fat':'Low Fat', 'LF':'Low Fat','reg':'Regular'}}, inplace=True)
# In[16]:
sns.countplot(x='Item_Fat_Content', data = categorical_data)
# In[18]:
sns.countplot(y='Outlet_Identifier', data = categorical_data)
# In[19]:
categorical_data['Outlet_Identifier'].value_counts()
# In[20]:
plt.figure(figsize=(12,8))
sns.countplot(y='Item_Type', data= categorical_data)
# In[22]:
fig, axes = plt.subplots(1,2, figsize=(12,5))
sns.countplot(y='Outlet_Type', data = categorical_data, ax= axes[0])
sns.countplot(y='Outlet_Location_Type', data = categorical_data, ax= axes[1])
# In[23]:
numerical_data.describe()
# In[24]:
numerical_data['Item_Weight'].hist(bins=100)
# In[25]:
numerical_data['Item_Visibility'].hist(bins=100)
# In[26]:
numerical_data['Item_MRP'].hist(bins=100)
# In[27]:
sns.countplot(x='Outlet_Establishment_Year', data=numerical_data)
# In[29]:
plt.figure(figsize=(12,8))
sns.barplot(y='Item_Type', x='Item_Outlet_Sales', data=df)
# In[30]:
plt.figure(figsize=(7,7))
sns.barplot(x='Outlet_Size', y='Item_Outlet_Sales', data= df)
# In[31]:
plt.figure(figsize=(10,5))
sns.barplot('Outlet_Location_Type','Item_Outlet_Sales', hue='Outlet_Type', data=df)
plt.legend()
# In[32]:
plt.figure(figsize=(10,7))
sns.heatmap(df.corr(), annot=True)
plt.title('Correlation between the columns')
plt.show()
# In[ ]: