Coder Social home page Coder Social logo

ai_project_3's Introduction

AI_Project_3

Sales Unit Forecasting

Purpose: the purpose of this project is to nalyze historical unit sales and identify modeling technique that optimizes forecast

    Step 1: Pull hisotrical item level unit sales data from exisiting company database
    Step 2: Preprocess the Data
     * Change datatypes where necessary
     * Remove 2017 data as it did not contain all metrics
   Step 3: Graph the unit sales history for each brand to show the complexity of the data and show seasonality changes where relevant
   Step 4: Filter data to a single UPC
   Step 5: Calculate the .diff of unit sales to use for modeling, add to the dataframe
   Step 6: Set up, train, tune pytorch based LSTM model
     * Used 90% of chosed UPC data for training since the full 6 years of history was available
     * 1 layer nueral network with 2000 epochs produced the best results (tested with 1-6 layers, and from 500-3000 epochs)
     * printed test results
     * processed test results in excel and compared them to existing model performance
   Step 7: Set up, train, tune persistence Long Short-term model
     * training set was based on all weeks up to the selected forecasted period of 16 weeks
     * 4 layer nueral network with 3000 epochs produced the best results (tested with 1-6 layers, and from 500-3500 epochs)
     * printed test results
     * processed test results in excel and compared them to existing model performance
   Step 8: Set up, train, Linear Regression model
     * Additional pre-processing data for Linear, Random Forest, and XG Boost models
     * training set was based on all weeks up to the selected forecasted period of 16 weeks
     * printed test results
     * processed test results in excel and compared them to existing model performance
   Step 9: Set up, train, Random Forest model
     * training set was based on all weeks up to the selected forecasted period of 16 weeks
     * printed test results
     * processed test results in excel and compared them to existing model performance
   Step 10: Set up, train, XG Boost model
     * training set was based on all weeks up to the selected forecasted period of 16 weeks
     * printed test results
     * processed test results in excel and compared them to existing model performance

   Conclusion: Random Forest Model performed the best

Intalls: A number of installations are needed (and provided) to run the code necessary to complete this project

from datetime import datetime
import os

import pandas as pd
from pandas import concat

import numpy as np
from numpy import array

import sklearn as skl
from sklearn.ensemble import RandomForestRegressor
from sklearn.linear_model import LinearRegression
from sklearn.preprocessing import MinMaxScaler
from sklearn.metrics import mean_absolute_error, mean_squared_error, r2_score
from sklearn.model_selection import train_test_split

from xgboost import XGBRegressor

import matplotlib as mpl
import matplotlib.pyplot as plt
from matplotlib import pyplot

import tensorflow as tf
from tensorflow.keras import layers, models, Model
from tensorflow.keras.models import Sequential
from tensorflow.keras.layers import LSTM, Dense
from tensorflow import keras
from tensorflow.keras.layers import LSTM
from tensorflow.keras.callbacks import EarlyStopping, ModelCheckpoint

import seaborn as sns

import keras_tuner as kt
from keras.models import Sequential
from keras.layers import Dense

import torch
import torch.nn as nn
import torch.optim as optim
import torch.utils.data as data

from math import sqrt

[Python Documentation] (https://docs.python.org/)
[Jupyter Notebook Documentation] (https://jupyter-notebook.readthedocs.io/)
[sklearn Documentation] (https://scikit-learn.org/0.21/documentation.html)
[tensorflow Documentation] (https://devdocs.io/tensorflow~2.4/)
[Pytoch Documentation] (https://pytorch.org/docs/stable/index.html)
[Matplot Documentation] (https://matplotlib.org/stable/users/index.html)
[XG Boost Documentation] (https://xgboost.readthedocs.io/en/stable/)

Resources:
[Xpert Learning Assistance]
Change string to date
Int to object
Object to Float
Updated Date to year-week format Advantages and disadvantages of different tensorflow optimizers
Pytorch code example
Mutli-step LSTM
Running LSTM in Keras
[README.md formatting] (https://medium.com/analytics-vidhya/writing-github-readme-e593f278a796)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.