image_output_5.png text_plain_output_3.png image_output_4.png text_plain_output_2.png text_plain_output_1.png image_output_3.png image_output_2.png image_output_1.png
from matplotlib import style

from subprocess import check_output

import numpy as np # linear algebra

import pandas as pd # data processing, CSV file I/O (e.g. pd.read_csv)

import numpy as np
import pandas as pd
from matplotlib import pyplot as plt
from matplotlib import style
style.use('ggplot')
from sklearn.preprocessing import Imputer
from sklearn.linear_model import LinearRegression
from sklearn.preprocessing import scale
from collections import Counter
import seaborn as sns
from sklearn.preprocessing import LabelEncoder, OneHotEncoder
from subprocess import check_output
print(check_output(['ls', '../input']).decode('utf8'))
train = pd.read_csv('../input/training-set/Train_A102.csv')
test = pd.read_csv('../input/test-a102csv/Test_A102 (1).csv')
print(train.head())
print(test.head())
train.info()
print(train.dtypes)
print(train.describe(include='all'))
print(train.shape)
test.info()
print(test.dtypes)
print(test.describe(include='all'))
print(test.shape)
test['Item_Outlet_Sales'] = np.nan
print(test.head())
combined_set = train.append(test)
print(combined_set.head())
print(combined_set.describe(include='all'))
print(combined_set.shape)
print(combined_set.max())
print(combined_set.min())
combined_set.replace('', np.NaN)
combined_meanset = combined_set.copy(deep=True)
combined_meanset['Item_Weight'].fillna(value=12.792854, inplace=True)
print(combined_meanset.head(10))
combined_medianset = combined_set.copy(deep=True)
combined_medianset['Item_Weight'].fillna(value=12.6, inplace=True)
print(combined_medianset.head(10))
print(combined_set.head(10))
combined_meanset['Item_Weight'].hist(color='white', edgecolor='green')
plt.title('Mean Histogram')
plt.xlabel('X-axis')
plt.ylabel('Item_Weight')
plt.show()
combined_medianset['Item_Weight'].hist(color='white', edgecolor='green')
plt.title('Median Histogram')
plt.xlabel('X-axis')
plt.ylabel('Item_Weight')
plt.show()
combined_set['Item_Weight'].hist(color='white', edgecolor='green')
plt.title('Actual Value Histogram')
plt.xlabel('X-axis')
plt.ylabel('Item_Weight')
plt.show()
combined_set['Item_Weight'].fillna(value=12.6, inplace=True)
train.plot.density()
plt.show()
combined_set.boxplot()
plt.plot()
combined_set.boxplot('Item_Visibility', figsize=(20, 8))
plt.plot()
combined_set.boxplot('Outlet_Establishment_Year', figsize=(12, 8))
plt.plot()
print(combined_set.groupby('Item_Fat_Content').Outlet_Size.value_counts(dropna=False))
print(combined_set.groupby('Item_Type').Outlet_Size.value_counts(dropna=False))
print(combined_set.groupby('Outlet_Identifier').Outlet_Size.value_counts(dropna=False))
print(combined_set.groupby('Outlet_Type').Outlet_Size.value_counts(dropna=False))
print(combined_set.groupby('Outlet_Location_Type').Outlet_Size.value_counts(dropna=False))
combined_set['Outlet_Size'].fillna(value='Medium', inplace=True)
print(combined_set.head())
combined_set['Outlet_Size'].hist(color='white', edgecolor='blue')
plt.title('Histogram of Outlet_Size')
plt.xlabel('X-axis')
plt.ylabel('Outlet_Size')
plt.show()
combined_set['Item_Outlet_Sales'].fillna(value=-999, inplace=True)
print(combined_set.tail())
print(combined_set.shape[0])
X = train.iloc[:, 0:].values
item_outlet_sales = X[:, 11]
Outliers = item_outlet_sales > 6501
print(train[Outliers])
print(combined_set['Item_Fat_Content'].value_counts())
combined_set['Item_Fat_Content'] = combined_set['Item_Fat_Content'].replace({'low fat': 'LF', 'Low Fat': 'LF', 'Regular': 'reg'})
print(combined_set.head())