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

train_set = pd.read_csv('/kaggle/input/preprocessed-sales-data/train_set.csv')
validation_set = pd.read_csv('/kaggle/input/preprocessed-sales-data/validation_set.csv')
test_set = pd.read_csv('/kaggle/input/competitive-data-science-predict-future-sales/test.csv')

train_set.head().T

x_train = train_set.drop(['item_cnt_month', 'date_block_num'], axis=1)
y_train = train_set['item_cnt_month'].astype(int)
x_val = validation_set.drop(['item_cnt_month', 'date_block_num'], axis=1)
y_val = validation_set['item_cnt_month'].astype(int)

latest_records = pd.concat([train_set, validation_set]).drop_duplicates(subset=['shop_id', 'item_id'], keep='last')
x_test = pd.merge(test_set, latest_records, on=['shop_id', 'item_id'], how='left', suffixes=['', '_'])
x_test['year'] = 2015
x_test['month'] = 9
x_test.drop('item_cnt_month', axis=1, inplace=True)
x_test = x_test[x_train.columns]

train_predictions = {'LR': M1_train, 'KN': M2_train, 'RF': M3_train}
train_predictions = pd.DataFrame(train_predictions)
train_predictions.head(10).T