Apttus has been working with Wave Analytics since it was launched at Dreamforce 14 - collecting customer requirements, building and piloting prototypes, and reworking apps based on customer feedback. Join us as we showcase the Wave apps we built with some of the world's largest companies. More importantly, we'll share how we got there and the lessons we learned along the way. We will discuss business requirements definition for predictive business intelligence, advanced analytics, visualization, data management and ETL processes, external integrations, and APIs. Learn how to drive business results with machine learning.
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Wave Analytics: Developing Predictive Business Intelligence Apps
1. Wave
Analy*cs:
Developing
Predic*ve
Business
Intelligence
Apps
2. Built
on
the
Salesforce1™
Pla?orm
Quote
Contract
Revenue
Opportunity
ERP
CONTRACT
LIFECYCLE
MANAGEMENT
ORDER
MANAGEMENT
CONFIGURE
PRICE
QUOTE
BILLING
REBATE
MANAGEMENT
DEAL
MANAGEMENT
E-‐COMMERCE
QUOTE-‐TO-‐CASH
INTELLIGENCE
X-‐AUTHOR
ApQus
Quote-‐to-‐Cash
Footprint
3. Why
Predic*ve
is
Important…
• IoT
and
the
Age
of
Data
• New
Tools
are
needed
• Descrip7ve
• Predic7ve
• Prescrip7ve
Analy7cs
• Ac7on
from
Insight
4. The
Ways
Wave
helps…
• Visualizing
descrip7ve
and
predic7ve
analysis
• Delivering
insights
to
Salesforce
users
5. If
you
have
one
of
these…..
Then
you
might
like
these…
6. Story:
Growing
Revenue
and
Margin
• Business
wants
to
grow
revenue
with
cross-‐sell
and
up-‐sell
recommenda7ons
based
on
data
analysis
• Marke7ng
uses
Wave
to
es7mate
the
poten7al
opportunity
• Sales
rep
receives
a
recommenda7on
for
her
customer
from
ApHus
that
will
increase
the
size
of
the
deal
• Wave
provides
the
Sales
rep
with
addi7onal
insight
into
the
recommenda7on
for
the
customer
which
helps
her
be
more
consulta7ve
• Marke7ng
uses
Wave
to
track
the
business
impact
of
the
recommenda7ons
which
convert
into
sales
8. Add
Products
to
Cart
Browse
Recommended
Products
Adds
Recommended
Products
to
Cart
Analyze
Purchase
History
of
Similar
Customers
Predict
Recommended
Products
ApQus
Use
Case
Display
chart
depic7ng
Recommended
Products
by
Customer
cluster
Display
chart
depic7ng
$
from
Recommenda7ons
added
to
cart
Salesforce
Database
Frequency
Similarity
Predic7on
Marke7ng
Sales
Wave
Database
Explain
Product
Recommenda7ons
Wave
API
Recommender
API
ApHus
CPQ
ApHus
Cross-‐Sell
Recommender
Wave
9. Machine-‐Learning
Algorithm
Algorithm
– ML uses statistics to analyze and predict patterns in data
– Item-based Collaborative Filtering
– Initial model developed in “R” uses KNN (K Nearest Neighbor)
– 3 main components of the algorithm
▪ Frequency
▪ Similarity
▪ Prediction
– Capable of unsupervised learning
Frequency Table
– Count number of Products (items) purchased by each Account
11. Recommenda*on
• Select products (items) which are similar to the product added to the Cart
• Given an account, choose top-N products among the similar products based on
the estimated rates
• Products 15 & 20 are recommended to the user
Added Product 1
to the Cart
Similar Products
Product 3
Product 8
Product 10
Product 15
Product 20
User
Prediction Rate
0.5
1
0.3
2
3
User
12. The
Code
public void callWaveAPI() {
Http http = new Http();
HttpRequest req = new HttpRequest();
HttpResponse res = new HttpResponse();
// Wave REST API calls
String WAVE_BASE = 'https://gs0.salesforce.com/services/data/v34.0/wave';
String WAVE_DATASETS = WAVE_BASE + '/datasets';
String WAVE_QUERY = WAVE_BASE + '/query';
try {
// send Wave API request to query dataset
req = new HttpRequest();
// set request endpoint
req.setEndpoint(WAVE_QUERY);
req.setMethod('POST');
// set request headers
req.setHeader(HEADER_AUTHORIZATION, HEADER_AUTHORIZATION_PREFIX + ' ' + oAuthAccessToken);
req.setHeader(HEADER_CONTENT_TYPE, HEADER_CONTENT_TYPE_JSON);
// set request body
body = '{"query":"q = load "0FbB00000005ZQPKA2/0FcB00000006PlCKAU"; q = foreach q generate 'Prediction_Rate' as 'Prediction_Rate',
'Recommended_Product_Name' as 'Recommended_Product_Name', 'Related_Product_1_Name' as 'Related_Product_1_Name', 'Related_Product_2_Name' as 'Related_Product_2_Name'; q
= order q by 'Prediction_Rate' desc; q = limit q 100;"}';
req.setBody(body);
// send request
res = http.send(req);
// parse JSON response using JSON2ApexQueryResult2 class
queryResult = JSON2ApexQueryResponse2.parse(res.getBody());
List<JSON2ApexQueryResponse2.Records> records = queryResult1.Results.records;
for (JSON2ApexQueryResponse2.Records r : records) {
debugStr2 += 'Recommended = ' + r.Recommended_Product + '; Related 1 = ' + r.Related_Product1 + ', Related 2 = ' + r.Related_Product2 + 'n';
}
} catch(System.CalloutException ex) {
system.debug(LoggingLevel.INFO,'Callout error: '+ex);
system.debug(LoggingLevel.INFO,res.toString());
}
}
13. The
Code
// set request body
body = '{"query":"q = load
"0FbB00000005ZQPKA2/0FcB00000006PlCKAU"; q =
foreach q generate 'Prediction_Rate' as
'Prediction_Rate', 'Recommended_Product_Name' as
'Recommended_Product_Name', 'Related_Product_1_Name
' as 'Related_Product_1_Name',
'Related_Product_2_Name' as 'Related_Product_2_Name
'; q = order q by 'Prediction_Rate' desc; q = limit
q 100;"}';
14. The
Code
/**
* compute prediction score for a given product and account
* @param accountId the id of the account to get a prediction score for
* @param productId the id of the product to get a prediction score for
* @return the prediction score for the given account and product
*/
private Decimal computePredictionScore(ID productId, ID accountId) {
Decimal score = 0.00000;
Decimal sumOfSim = 0.00000;
Decimal sumOfRateSim = 0.00000;
// get product similarity map for the given product
Map<ID,Decimal> simMap = productSimMap.get(productId);
if (!productSimMap.containsKey(productId)) {
return score;
}
// iterate over products in product similarity map
for (ID prodIdKey : simMap.keySet()) {
// get the product similarity
Decimal productSim = simMap.get(prodIdKey);
// keep track of the sum of similarties
sumOfSim += Math.abs(productSim);
// keep track of the sum of zrate similarities
if (productZRateMap.containsKey(prodIdKey)) {
Map<ID,Decimal> productZRate = productZRateMap.get(prodIdKey);
if (productZRate.containsKey(accountId)) {
Decimal accountSim = productZRate.get(accountId);
sumOfRateSim += productSim * accountSim;
}
}
}
// calculate the prediction score
if (sumOfSim != 0.00000) {
// get product average and std deviation
Map<String,Decimal> productStats = productStatsMap.get(productId);
Decimal productAvg = productStats.get(KEY_AVG);
Decimal productStd = productStats.get(KEY_STD);
// calculate the score
score = productAvg + (productStd * (sumOfRateSim / sumOfSim));
}
// return the prediction score
return score;
}
15. Lessons
Learned
• Leveraging
Wave
• Use
Salesforce
to
Wave
data
flows
to
store
historical
data
and
trends
• Use
Wave
API
to
query
for
recommended
products
• Use
Wave
dashboards
for
visualiza7on
of
recommenda7ons
• Implemen7ng
Machine
Learning
on
Salesforce
• With
Apex-‐
breakup
into
batch
process
to
stay
within
governor
limits
• With
Heroku
–
fewer
restric7ons
but
introduces
data
security
challenges
• Changes
to
the
model
once
coded
are
difficult
and
present
design
considera7ons
for
produc7za7on