wave analytics: developing predictive business intelligence apps

17
Wave Analy*cs: Developing Predic*ve Business Intelligence Apps

Upload: salesforce-developers

Post on 15-Feb-2017

583 views

Category:

Technology


3 download

TRANSCRIPT

Page 1: Wave Analytics: Developing Predictive Business Intelligence Apps

Wave  Analy*cs:    Developing  Predic*ve  Business  Intelligence  Apps  

Page 2: Wave Analytics: Developing Predictive Business Intelligence Apps

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  

Page 3: Wave Analytics: Developing Predictive Business Intelligence Apps

Why  Predic*ve  is  Important…  

•  IoT  and  the  Age  of  Data  • New  Tools  are  needed    

•  Descrip7ve  •  Predic7ve  •  Prescrip7ve  Analy7cs  

• Ac7on  from  Insight  

Page 4: Wave Analytics: Developing Predictive Business Intelligence Apps

The  Ways  Wave  helps…  

• Visualizing  descrip7ve  and  predic7ve  analysis  • Delivering  insights  to  Salesforce  users  

Page 5: Wave Analytics: Developing Predictive Business Intelligence Apps

If  you  have  one  of  these…..        Then  you  might  like  these…  

Page 6: Wave Analytics: Developing Predictive Business Intelligence Apps

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    

Page 7: Wave Analytics: Developing Predictive Business Intelligence Apps

Demonstra*on  

Page 8: Wave Analytics: Developing Predictive Business Intelligence Apps

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  

Page 9: Wave Analytics: Developing Predictive Business Intelligence Apps

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

Page 10: Wave Analytics: Developing Predictive Business Intelligence Apps

Compute  

   

   

   

Page 11: Wave Analytics: Developing Predictive Business Intelligence Apps

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

Page 12: Wave Analytics: Developing Predictive Business Intelligence Apps

The  Code  public void callWaveAPI() {

Http http = new Http();HttpRequest req = new HttpRequest();HttpResponse res = new HttpResponse();

// Wave REST API callsString 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 datasetreq = new HttpRequest();// set request endpointreq.setEndpoint(WAVE_QUERY);req.setMethod('POST');// set request headersreq.setHeader(HEADER_AUTHORIZATION, HEADER_AUTHORIZATION_PREFIX + ' ' + oAuthAccessToken);req.setHeader(HEADER_CONTENT_TYPE, HEADER_CONTENT_TYPE_JSON);// set request bodybody = '{\"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 requestres = http.send(req);

// parse JSON response using JSON2ApexQueryResult2 classqueryResult = 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());

}

}

Page 13: Wave Analytics: Developing Predictive Business Intelligence Apps

The  Code  

// set request bodybody = '{\"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;\"}';

Page 14: Wave Analytics: Developing Predictive Business Intelligence Apps

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 productMap<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; }

Page 15: Wave Analytics: Developing Predictive Business Intelligence Apps

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  

Page 16: Wave Analytics: Developing Predictive Business Intelligence Apps

Ques*ons?  

Page 17: Wave Analytics: Developing Predictive Business Intelligence Apps

Thank  You