Git Product home page Git Product logo

unomi-dummy-score-prediction's Introduction

unomi-dummy-score-prediction

This repository contains a prototype integration of Apache Unomi with a dummy score prediction. This project was created to educate myself on how to implement a Apache Unomi Plugin which can possibly integrate with other (AI) backends in a custom action plugin, inspired by https://github.com/Jahia/unomi-predictionio-plugin.

How to build

mvn clean verify

The Apache Karaf KAR bundle file is created in karaf-kar/target/ folder.

How to deploy

Before deploying the bundle, you can tail logs in the Apache Karaf console:

karaf@root()> log:tail

Copy the Apache Karaf KAR bundle file in karaf-kar/target/ folder, unomi-dummy-score-prediction-kar-x.y.z*.kar, to $UNOMI_HOME/deploy/ folder.

You may see deployment logs like the following:

08:43:34.505 INFO [fileinstall-C:\Users\dev1\testspace\unomi\unomi-1.6.0/deploy] Found a .kar file to deploy.
08:43:34.520 WARN [fileinstall-C:\Users\dev1\testspace\unomi\unomi-1.6.0/deploy] Karaf archive C:\Users\dev1\testspace\unomi\unomi-1.6.0\deploy\unomi-dummy-score-prediction-kar-0.1.1-SNAPSHOT.kar' has been updated; redeploying.
08:43:34.532 INFO [fileinstall-C:\Users\dev1\testspace\unomi\unomi-1.6.0/deploy] Removing features: unomi-dummy-score-prediction-kar/[0.1.1.SNAPSHOT,0.1.1.SNAPSHOT]
08:43:36.130 INFO [features-3-thread-1] Changes to perform:
08:43:36.132 INFO [features-3-thread-1]   Region: root
08:43:36.133 INFO [features-3-thread-1]     Bundles to uninstall:
08:43:36.136 INFO [features-3-thread-1]       com.github.woonsan.unomi-dummy-score-prediction-core/0.1.1.SNAPSHOT
08:43:36.145 INFO [features-3-thread-1]     Bundles to install:
08:43:36.147 INFO [features-3-thread-1]       mvn:org.apache.unomi/unomi-groovy-actions-services/1.6.0
08:43:36.151 INFO [features-3-thread-1] Stopping bundles:
08:43:36.153 INFO [features-3-thread-1]   com.github.woonsan.unomi-dummy-score-prediction-core/0.1.1.SNAPSHOT
08:43:36.163 INFO [features-3-thread-1] Destroying container for blueprint bundle com.github.woonsan.unomi-dummy-score-prediction-core/0.1.1.SNAPSHOT
08:43:36.178 INFO [features-3-thread-1] Uninstalling bundles:
08:43:36.180 INFO [features-3-thread-1]   com.github.woonsan.unomi-dummy-score-prediction-core/0.1.1.SNAPSHOT
08:43:36.203 INFO [features-3-thread-1] Installing bundles:
08:43:36.204 INFO [features-3-thread-1]   mvn:org.apache.unomi/unomi-groovy-actions-services/1.6.0
08:43:36.217 INFO [features-3-thread-1] Refreshing bundles:
08:43:36.218 INFO [features-3-thread-1]     com.github.woonsan.unomi-dummy-score-prediction-core/0.1.1.SNAPSHOT (Bundle will be uninstalled)
08:43:36.226 INFO [features-3-thread-1] Done.

How to test

  • Query the profile first like the following example (in Visual Studio Code RestClient format):
# Environment variables
@baseUrl = http://localhost:8181
@credentials = karaf:karaf

### Read profile

POST {{baseUrl}}/cxs/context.json?sessionId=1234
Accept: */*
Authorization: Basic {{credentials}}
Content-Type: application/json

{
  "source": {
    "itemId":"homepage",
    "itemType":"page",
    "scope":"example"
  },
  "requiredProfileProperties":["*"],
  "requiredSessionProperties":["*"],
  "requireSegments":true,
  "requireScores":true
}
  • Now, post a page view event like the following:
### Submit an event

POST {{baseUrl}}/cxs/eventcollector
Accept: */*
Authorization: Basic {{credentials}}
Content-Type: application/json

{
  "sessionId" : "1234",
  "events": [
    {
      "eventType": "view",
      "scope": "example",
      "source": {
        "itemType": "site", 
        "scope":"example", 
        "itemId": "mysite" 
      },
      "target": {
        "itemType": "page",
        "scope": "example",
        "itemId": "buy_kia_morning",
        "properties": {
          "pageInfo": {
            "destinationURL": "http://localhost:8080/sites/example/buy_kia_morning.html",
            "pageID": "f20836ab-608f-4551-a930-9796ec991340",
            "pagePath": "/sites/example/home",
            "pageName": "Home",
            "referringURL": "https://www.google.com/search?q=kia+morning",
            "isContentTemplate": false
          }
        }
      }
    }
  ]
}
  • Query the profile again and you will see the dummyLeadScoringProbability property set to the profileProperties of the profile object, like the following example:
{
  "profileId": "90639cf8-f1cc-48ed-964b-077c0f70f787",
  "sessionId": "1234",
  "profileProperties": {
    "firstName": "John",
    "lastName": "Doe",
    "nbOfVisits": 2,
    "lastVisit": "2022-05-10T05:54:14Z",
    "dummyLeadScoringProbability": 4,
    "firstVisit": "2022-05-09T02:28:08Z",
    "email": "[email protected]",
    "previousVisit": "2022-05-09T02:28:08Z"
  },
  //...
}
  • Also, try to change the refereringURL and destinationURL properties in the event input and see how it affects the dummy score calculation. For a simple demonstration, the dummy score calculation is hard-coded very simply in DummyPredictiveLeadScoringAction.java.

unomi-dummy-score-prediction's People

Contributors

woonsan avatar

Stargazers

Masoud Aghaei avatar

Watchers

 avatar

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.