Walmet Sales Prediction(updating)

参考kaggle notebook:
keras

一、题目

1.项目题目:沃尔玛销量预测

预测沃尔玛未来28天的销量

2.评分标准:RMSSE

RMSSE.png

n为40341训练样本量,h为28天,Yt为实际销量值,Yt^为预测销量值

3.数据描述

数据有3049种产品,共3大类,7个部门,在3个洲的10个商场里销售

sales_train.csv:这是主要的训练集,含有每个从2011-1-29到2016-5-22的1941天每天的(不包括到2016-6-19的28天)销量,含商品的ID,部门,分类,商店,洲.
sell_prices.csv:商店的商品每周均价
calendar.csv:日期的星期、月份、年和该洲是否允许用食品券(food stamp,低收入家庭的补助)购买

二、正文

1.导入数据

#导入库
import pandas as pd
import seaborn as sns
import lightgbm as lgb
import numpy as np
#导入数据 import data
calendar = pd.read_csv('calendar.csv')
sample_submission = pd.read_csv('sample_submission.csv')
sales_train_validation = pd.read_csv('sales_train_validation.csv')
sell_prices = pd.read_csv('sell_prices.csv')
#减小内存占用 reduce the memory usage
def reduce_mem_usage(df, verbose=True):
    numerics = ["int16", "int32", "int64", "float16", "float32", "float64"]
    start_mem = df.memory_usage().sum() / 1024 ** 2
    for col in df.columns:
        col_type = df[col].dtypes
        if col_type in numerics:
            c_min = df[col].min()
            c_max = df[col].max()
            if str(col_type)[:3] == "int":
                if c_min > np.iinfo(np.int8).min and c_max < np.iinfo(np.int8).max:
                    df[col] = df[col].astype(np.int8)
                elif c_min > np.iinfo(np.int16).min and c_max < np.iinfo(np.int16).max:
                    df[col] = df[col].astype(np.int16)
                elif c_min > np.iinfo(np.int32).min and c_max < np.iinfo(np.int32).max:
                    df[col] = df[col].astype(np.int32)
                elif c_min > np.iinfo(np.int64).min and c_max < np.iinfo(np.int64).max:
                    df[col] = df[col].astype(np.int64)
            else:
                if (
                    c_min > np.finfo(np.float16).min
                    and c_max < np.finfo(np.float16).max
                ):
                    df[col] = df[col].astype(np.float16)
                elif (
                    c_min > np.finfo(np.float32).min
                    and c_max < np.finfo(np.float32).max
                ):
                    df[col] = df[col].astype(np.float32)
                else:
                    df[col] = df[col].astype(np.float64)
    end_mem = df.memory_usage().sum() / 1024 ** 2
    if verbose:
        print(
            "Mem. usage decreased to {:5.2f} Mb ({:.1f}% reduction)".format(
                end_mem, 100 * (start_mem - end_mem) / start_mem
            )
        )
    return df
#减小dataframe占用内存
print("缩小前占用内存为:",sell_prices.memory_usage().sum() / (1024 ** 2), "MB")
calendar = reduce_mem_usage(calendar)
sample_submission = reduce_mem_usage(sample_submission)
sales_train_validation = reduce_mem_usage(sales_train_validation)
sell_prices = reduce_mem_usage(sell_prices)
print("缩小后占用内存为:",sell_prices.memory_usage().sum() / (1024 ** 2), "MB")
sales_train_validation.head()
calendar.head()
image.png
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容

  • 沃尔顿对整个零售行业的改造和重塑,是沃尔玛成功的关键因素。 沃尔玛是全球知名的零售巨头,连续多年占据美国《财富》杂...
    哈鹿同学阅读 2,658评论 0 3
  • 《大学生为什么要拥有梦想?》 《大学生如何拥有自己梦想?》 《大学生拥有梦想的意义是?》 ...
    黄嘉波阅读 5,430评论 0 1
  • A在合资公司做白领,觉得自己满腔抱负没有得到上级的赏识,经常想:如果有一天能见到老总,有机会展示一下自己的才干就好...
    咖啡与浓茶阅读 123评论 0 0
  • 01 偶然间翻开了尘封已久的QQ号码, 时间停留在几年前的某月某日。 翻看着以前稚嫩随笔, 才发现一直以来都是没心...
    愫说成长阅读 324评论 2 7
  • 概述 org.springframework.context.ApplicationContext接口是Sprin...
    0d1b415a365b阅读 5,536评论 1 3