Learn practical skills, build real-world projects, and advance your career
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
import os
It looks like we are given quite a few sets as an input! Let's take a look at each one, starting with train and test.
df_train = pd.read_csv('../input/grupo-bimbo-inventory-demand/train.csv.zip', nrows=500000)
df_test = pd.read_csv('../input/grupo-bimbo-inventory-demand/test.csv.zip', nrows=500000)


print('Size of training set: ' + str(df_train.shape))
print('Size of testing set: ' + str(df_test.shape))


print('Columns in train: ' + str(df_train.columns.tolist()))
print('Columns in test: ' + str(df_test.columns.tolist()))


print(df_train.describe())

Demanda_uni_equil is the target value that we are trying to predict.

Let's take a look at the distribution:

target = df_train['Demanda_uni_equil'].tolist()

def label_plot(title, x, y):
    plt.title(title)
    plt.xlabel(x)
    plt.ylabel(y)

plt.hist(target, bins=200, color='blue')
label_plot('Distribution of target values', 'Demanda_uni_equil', 'Count')
plt.show()

print("Looks like we have some pretty big outliers, let's zoom in and try again")

print('Data with target values under 50: ' + str(round(len(df_train.loc[df_train['Demanda_uni_equil'] <= 50]) / 5000, 2)) + '%')

plt.hist(target, bins=50, color='blue', range=(0, 50))
label_plot('Distribution of target values under 50', 'Demanda_uni_equil', 'Count')
plt.show()