Business AI for SMB’s: A Management Take On The Challenges of Leveraging Data and AI for Sales Growth and Enhancing the Customer Experience (CX)

4 Common Reasons Why Data Science and Analytics Initiatives Are Slow To Gain Momentum

What are some quick-win strategies to address these common problems?

Can you provide specifics? How can SMB’s and startups tap into this?

Example of Amazon’s “Frequently Bought Together” Algorithm
Online Retail Data Set from a UK eCommerce Company | Source: UCI Machine Learning Repository
Sample Output from RemixAutoML’s AutoMarketBasketModel
library(data.table)
library(dplyr)
library(magrittr)
library(RemixAutoML)

# IMPORT ONLINE RETAIL DATA SET THEN CLEAN DATA SET-------

# Original Source: UCI Machine Learning Repository - https://archive.ics.uci.edu/ml/datasets/online+retail
# download file from Remix Insitute Box account
online_retail_data = data.table::fread("https://remixinstitute.box.com/shared/static/v2c7mkkqm9eswyqbzkg5tbqqzfa1885v.csv", header = T, stringsAsFactors = FALSE)


# create a flag for cancelled invoices
online_retail_data$CancelledInvoiceFlag = ifelse(substring(online_retail_data$InvoiceNo, 1, 1) == 'C', 1, 0)
# create a flag for negative quantities
online_retail_data$NegativeQuantityFlag = ifelse(online_retail_data$Quantity < 0, 1, 0)

# remove cancelled invoices and negative quantitites
online_retail_data_clean = online_retail_data %>% dplyr::filter(., CancelledInvoiceFlag != 1) %>%
dplyr::filter(., NegativeQuantityFlag != 1)


# PREP DATA SET FOR MODELING -------------

# for market basket analysis models, you'll need data grouped by invoice (InvoiceNo) and item number (StockCode). Then you can sum up the units sold.
online_retail_data_for_model = online_retail_data_clean %>% dplyr::group_by(., InvoiceNo, StockCode) %>%
dplyr::summarise(., Quantity = sum(Quantity, na.rm = TRUE) )


# RUN AUTOMATED MARKET BASKET ANALYSIS (PRODUCT RECOMMENDER) IN RemixAutoML -----------

# the AutoMarketBasketModel from RemixAutoML automatically converts your data,
# runs the market basket model algorithm, and adds Chi-Square statistics for significance
market_basket_model = RemixAutoML::AutoMarketBasketModel(
data = online_retail_data_for_model,
OrderIDColumnName = "InvoiceNo",
ItemIDColumnName = "StockCode"
)

# add product Description
# left-hand side products
StockCode_LHS_description = online_retail_data_clean %>% dplyr::select(., StockCode, Description) %>%
dplyr::rename(., StockCode_LHS = StockCode,
Description_LHS = Description
) %>%
dplyr::distinct(., StockCode_LHS, .keep_all = TRUE)
# right-hand side products
StockCode_RHS_description = online_retail_data_clean %>% dplyr::select(., StockCode, Description) %>%
dplyr::rename(., StockCode_RHS = StockCode,
Description_RHS = Description
)%>%
dplyr::distinct(., StockCode_RHS, .keep_all = TRUE)
# merge
market_basket_model_final = merge(market_basket_model, StockCode_RHS_description, by = 'StockCode_RHS', all.x = TRUE)
market_basket_model_final = merge(market_basket_model_final, StockCode_LHS_description, by = 'StockCode_LHS', all.x = TRUE)

# re-sort by StockCode_LHS and RuleRank
market_basket_model_final = market_basket_model_final[order(StockCode_LHS, RuleRank),]

# view results
View(market_basket_model_final)

Nick Gausling is a strategic business leader, author, speaker, and investor currently residing in Texas. He can be reached via NickGausling.com

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store