Skip to content

petchat/senz.analyzer.user.behavior

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

72 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

FORMAT: 1A Host: https://leancloud.cn/1.1/functions/

Senz Core Algo Service

senz core algo service provide a restful API for :

  • training an event model

  • and predicting the event type of a behavior sequence

Train a event model with specific observations [/trainWithSpecificObs/]

You can specify which model need training by tag. And you should give observations as a training sample. The format of training sample is following.

  • Hint If you need store the result of training, you need add a key, named "description". The value of "description" is a memo of this train. And when you get the same tag model next time, you will get a whole new model params.
[
    [{"motion": "walking", "location": "residence", "sound": "tree"}, ...],
    [{"motion": "walking", "location": "residence", "sound": "tree"}, ...],
    ...
]

Train with specific observations [POST]

  • Request (application/json)

    • Header

        X-AVOSCloud-Application-Id  : dkc5xdbwprsrh9809kqwopja5ckfbsrpd7dz9a30yugm9tut,
        X-AVOSCloud-Application-Key : 3sy9w8uwlr35xl54lja3rawyf8xjrhofxtvcwzng3blg7q31
      
    • Body

        {
        "algoType": "GMMHMM",
        "tag": "random_generated_base_model",
        "eventLabel": "dining.chineseRestaurant",
        "obs": [
            [
                {"motion": "sitting", "sound": "talking", "location": "chinese_restaurant"},
                {"motion": "sitting", "sound": "talking", "location": "chinese_restaurant"},
                {"motion": "sitting", "sound": "talking", "location": "chinese_restaurant"},
                {"motion": "sitting", "sound": "talking", "location": "chinese_restaurant"},
                {"motion": "walking", "sound": "others", "location": "chinese_restaurant"},
                {"motion": "walking", "sound": "tableware", "location": "chinese_restaurant"}
            ],
            [
                {"motion": "sitting", "sound": "talking", "location": "chinese_restaurant"},
                {"motion": "sitting", "sound": "talking", "location": "chinese_restaurant"},
                {"motion": "sitting", "sound": "talking", "location": "chinese_restaurant"},
                {"motion": "sitting", "sound": "talking", "location": "chinese_restaurant"},
                {"motion": "walking", "sound": "others", "location": "chinese_restaurant"},
                {"motion": "walking", "sound": "tableware", "location": "chinese_restaurant"}
            ]
        ],
        "description": "test for api." (optional)
        }
      
  • Response 201 (application/json)

      {
      "result":{
          "code":0,
          "model":{
              "nMix":4,
              "nComponent":4,
              "hmmParams":{
                  "transMat":[
                      [0.9937524708135964,2.6823758143694116e-18,0.00624752918640371,2.6823758143694116e-18],[0.25,0.25,0.25,0.25],[3.5716227445160065e-17,3.5716227445160065e-17,0.9999999999999999,3.5716227445160065e-17],[0.25,0.25,0.25,0.25]
                  ],
                  "startProb":[1,2.2205460492503137e-17,2.2205460492503137e-17,2.2205460492503137e-17]
              },
              "gmmParams":{
                  "nMix":4,
                  "covarianceType":"full",
                  "params":[
                      {"covars":[[[0.20272925448170726,-0.21372410825705002,0.6640076953697146],[-0.21372410825704996,44.41361612877133,-3.8315142667592568],[0.6640076953697147,-3.831514266759256,29.058072351569287]],[[0.19961779798118065,-0.20567068761490478,0.6180902066504756],[-0.2056706876149048,24.5623976379672,-1.8862253825381476],[0.6180902066504755,-1.886225382538147,28.57872805315829]],[[0.21297430879173704,-0.12933325429515627,0.6502230892315992],[-0.12933325429515624,25.319590716568648,-1.135216161881697],[0.6502230892315992,-1.135216161881697,28.002589075295308]],[[0.20772196929306083,-0.16035047001514102,0.6106797655515614],[-0.16035047001514105,26.54555785898669,-1.643554371696736],[0.6106797655515614,-1.643554371696736,28.157741030750508]]],"weights":[0.24391800630360175,0.2623161644960391,0.2516074177870681,0.242158411413291],"means":[[0.3093785189118171,98.50767974689373,12.04201267494459],[0.2957223232822461,100.29260369087528,11.368513289910661],[0.32869103266615624,100.24202740519003,12.299965535058508],[0.31513728410310543,100.08656506960568,12.162225242103984]]},{"covars":[[[0.20272925448170726,-0.21372410825705002,0.6640076953697146],[-0.21372410825704996,44.41361612877133,-3.8315142667592568],[0.6640076953697147,-3.831514266759256,29.058072351569287]],[[0.19961779798118065,-0.20567068761490478,0.6180902066504756],[-0.2056706876149048,24.5623976379672,-1.8862253825381476],[0.6180902066504755,-1.886225382538147,28.57872805315829]],[[0.21297430879173704,-0.12933325429515627,0.6502230892315992],[-0.12933325429515624,25.319590716568648,-1.135216161881697],[0.6502230892315992,-1.135216161881697,28.002589075295308]],[[0.20772196929306083,-0.16035047001514102,0.6106797655515614],[-0.16035047001514105,26.54555785898669,-1.643554371696736],[0.6106797655515614,-1.643554371696736,28.157741030750508]]],"weights":[0.24391800630360175,0.2623161644960391,0.2516074177870681,0.242158411413291],"means":[[0.3093785189118171,98.50767974689373,12.04201267494459],[0.2957223232822461,100.29260369087528,11.368513289910661],[0.32869103266615624,100.24202740519003,12.299965535058508],[0.31513728410310543,100.08656506960568,12.162225242103984]]},{"covars":[[[0.20272925448170726,-0.21372410825705002,0.6640076953697146],[-0.21372410825704996,44.41361612877133,-3.8315142667592568],[0.6640076953697147,-3.831514266759256,29.058072351569287]],[[0.19961779798118065,-0.20567068761490478,0.6180902066504756],[-0.2056706876149048,24.5623976379672,-1.8862253825381476],[0.6180902066504755,-1.886225382538147,28.57872805315829]],[[0.21297430879173704,-0.12933325429515627,0.6502230892315992],[-0.12933325429515624,25.319590716568648,-1.135216161881697],[0.6502230892315992,-1.135216161881697,28.002589075295308]],[[0.20772196929306083,-0.16035047001514102,0.6106797655515614],[-0.16035047001514105,26.54555785898669,-1.643554371696736],[0.6106797655515614,-1.643554371696736,28.157741030750508]]],"weights":[0.24391800630360175,0.2623161644960391,0.2516074177870681,0.242158411413291],"means":[[0.3093785189118171,98.50767974689373,12.04201267494459],[0.2957223232822461,100.29260369087528,11.368513289910661],[0.32869103266615624,100.24202740519003,12.299965535058508],[0.31513728410310543,100.08656506960568,12.162225242103984]]},{"covars":[[[0.20272925448170726,-0.21372410825705002,0.6640076953697146],[-0.21372410825704996,44.41361612877133,-3.8315142667592568],[0.6640076953697147,-3.831514266759256,29.058072351569287]],[[0.19961779798118065,-0.20567068761490478,0.6180902066504756],[-0.2056706876149048,24.5623976379672,-1.8862253825381476],[0.6180902066504755,-1.886225382538147,28.57872805315829]],[[0.21297430879173704,-0.12933325429515627,0.6502230892315992],[-0.12933325429515624,25.319590716568648,-1.135216161881697],[0.6502230892315992,-1.135216161881697,28.002589075295308]],[[0.20772196929306083,-0.16035047001514102,0.6106797655515614],[-0.16035047001514105,26.54555785898669,-1.643554371696736],[0.6106797655515614,-1.643554371696736,28.157741030750508]]],"weights":[0.24391800630360175,0.2623161644960391,0.2516074177870681,0.242158411413291],"means":[[0.3093785189118171,98.50767974689373,12.04201267494459],[0.2957223232822461,100.29260369087528,11.368513289910661],[0.32869103266615624,100.24202740519003,12.299965535058508],[0.31513728410310543,100.08656506960568,12.162225242103984]]}]},
              "covarianceType":"full"
          },
      "message":"Training successfully! at Tue May 19 2015 15:42:52 GMT+0800 (CST)"}
      }
    

Train a event model randomly [/trainWithRandomObs/]

You can specify which model need training by tag. And all you need is giving the length of one observation and the count of observations, it will generate observations randomly and automaticly. The format of generated training sample is as same as above.

  • Hint If you need store the result of training, you need add a key, named "description". The value of "description" is a memo of this train. And when you get the same tag model next time, you will get a whole new model params.

Train randomly or without observations [POST]

  • Request (application/json)

    • Header

        X-AVOSCloud-Application-Id  : dkc5xdbwprsrh9809kqwopja5ckfbsrpd7dz9a30yugm9tut,
        X-AVOSCloud-Application-Key : 3sy9w8uwlr35xl54lja3rawyf8xjrhofxtvcwzng3blg7q31
      
    • Body

        {
        "algoType": "GMMHMM",
        "tag": "random_generated_base_model",
        "eventLabel": "dining.chineseRestaurant",
        "obsLength": 10,
        "obsCount": 500,
        "desciption": "test for api" (optional)
        }
      
  • Response 201 (application/json)

      {
      "result":{
          "code":0,
          "model":{
              "nMix":4,
              "nComponent":4,
              "hmmParams":{
                  "transMat":[
                      [0.9937524708135964,2.6823758143694116e-18,0.00624752918640371,2.6823758143694116e-18],[0.25,0.25,0.25,0.25],[3.5716227445160065e-17,3.5716227445160065e-17,0.9999999999999999,3.5716227445160065e-17],[0.25,0.25,0.25,0.25]
                  ],
                  "startProb":[1,2.2205460492503137e-17,2.2205460492503137e-17,2.2205460492503137e-17]
              },
              "gmmParams":{
                  "nMix":4,
                  "covarianceType":"full",
                  "params":[
                      {"covars":[[[0.20272925448170726,-0.21372410825705002,0.6640076953697146],[-0.21372410825704996,44.41361612877133,-3.8315142667592568],[0.6640076953697147,-3.831514266759256,29.058072351569287]],[[0.19961779798118065,-0.20567068761490478,0.6180902066504756],[-0.2056706876149048,24.5623976379672,-1.8862253825381476],[0.6180902066504755,-1.886225382538147,28.57872805315829]],[[0.21297430879173704,-0.12933325429515627,0.6502230892315992],[-0.12933325429515624,25.319590716568648,-1.135216161881697],[0.6502230892315992,-1.135216161881697,28.002589075295308]],[[0.20772196929306083,-0.16035047001514102,0.6106797655515614],[-0.16035047001514105,26.54555785898669,-1.643554371696736],[0.6106797655515614,-1.643554371696736,28.157741030750508]]],"weights":[0.24391800630360175,0.2623161644960391,0.2516074177870681,0.242158411413291],"means":[[0.3093785189118171,98.50767974689373,12.04201267494459],[0.2957223232822461,100.29260369087528,11.368513289910661],[0.32869103266615624,100.24202740519003,12.299965535058508],[0.31513728410310543,100.08656506960568,12.162225242103984]]},{"covars":[[[0.20272925448170726,-0.21372410825705002,0.6640076953697146],[-0.21372410825704996,44.41361612877133,-3.8315142667592568],[0.6640076953697147,-3.831514266759256,29.058072351569287]],[[0.19961779798118065,-0.20567068761490478,0.6180902066504756],[-0.2056706876149048,24.5623976379672,-1.8862253825381476],[0.6180902066504755,-1.886225382538147,28.57872805315829]],[[0.21297430879173704,-0.12933325429515627,0.6502230892315992],[-0.12933325429515624,25.319590716568648,-1.135216161881697],[0.6502230892315992,-1.135216161881697,28.002589075295308]],[[0.20772196929306083,-0.16035047001514102,0.6106797655515614],[-0.16035047001514105,26.54555785898669,-1.643554371696736],[0.6106797655515614,-1.643554371696736,28.157741030750508]]],"weights":[0.24391800630360175,0.2623161644960391,0.2516074177870681,0.242158411413291],"means":[[0.3093785189118171,98.50767974689373,12.04201267494459],[0.2957223232822461,100.29260369087528,11.368513289910661],[0.32869103266615624,100.24202740519003,12.299965535058508],[0.31513728410310543,100.08656506960568,12.162225242103984]]},{"covars":[[[0.20272925448170726,-0.21372410825705002,0.6640076953697146],[-0.21372410825704996,44.41361612877133,-3.8315142667592568],[0.6640076953697147,-3.831514266759256,29.058072351569287]],[[0.19961779798118065,-0.20567068761490478,0.6180902066504756],[-0.2056706876149048,24.5623976379672,-1.8862253825381476],[0.6180902066504755,-1.886225382538147,28.57872805315829]],[[0.21297430879173704,-0.12933325429515627,0.6502230892315992],[-0.12933325429515624,25.319590716568648,-1.135216161881697],[0.6502230892315992,-1.135216161881697,28.002589075295308]],[[0.20772196929306083,-0.16035047001514102,0.6106797655515614],[-0.16035047001514105,26.54555785898669,-1.643554371696736],[0.6106797655515614,-1.643554371696736,28.157741030750508]]],"weights":[0.24391800630360175,0.2623161644960391,0.2516074177870681,0.242158411413291],"means":[[0.3093785189118171,98.50767974689373,12.04201267494459],[0.2957223232822461,100.29260369087528,11.368513289910661],[0.32869103266615624,100.24202740519003,12.299965535058508],[0.31513728410310543,100.08656506960568,12.162225242103984]]},{"covars":[[[0.20272925448170726,-0.21372410825705002,0.6640076953697146],[-0.21372410825704996,44.41361612877133,-3.8315142667592568],[0.6640076953697147,-3.831514266759256,29.058072351569287]],[[0.19961779798118065,-0.20567068761490478,0.6180902066504756],[-0.2056706876149048,24.5623976379672,-1.8862253825381476],[0.6180902066504755,-1.886225382538147,28.57872805315829]],[[0.21297430879173704,-0.12933325429515627,0.6502230892315992],[-0.12933325429515624,25.319590716568648,-1.135216161881697],[0.6502230892315992,-1.135216161881697,28.002589075295308]],[[0.20772196929306083,-0.16035047001514102,0.6106797655515614],[-0.16035047001514105,26.54555785898669,-1.643554371696736],[0.6106797655515614,-1.643554371696736,28.157741030750508]]],"weights":[0.24391800630360175,0.2623161644960391,0.2516074177870681,0.242158411413291],"means":[[0.3093785189118171,98.50767974689373,12.04201267494459],[0.2957223232822461,100.29260369087528,11.368513289910661],[0.32869103266615624,100.24202740519003,12.299965535058508],[0.31513728410310543,100.08656506960568,12.162225242103984]]}]},
              "covarianceType":"full"
          },
          "message":"Training successfully! at Tue May 19 2015 15:42:52 GMT+0800 (CST)"
      }
      }
    

Predict the event's type of a given behavior sequence [/classifySingleSeq/]

You can specify which serial of models used to predict by tag. It will return the scores of every possible event type.

Predict event's type of sequence [POST]

  • Request (application/json)

    • Header

        X-AVOSCloud-Application-Id  : dkc5xdbwprsrh9809kqwopja5ckfbsrpd7dz9a30yugm9tut,
        X-AVOSCloud-Application-Key : 3sy9w8uwlr35xl54lja3rawyf8xjrhofxtvcwzng3blg7q31
      
    • Body

        {
        "algoType":"GMMHMM",
        "tag":"random_generated_base_model",
        "seq":[
            {"motion": "sitting", "sound": "talking", "location": "chinese_restaurant"},
            {"motion": "sitting", "sound": "talking", "location": "chinese_restaurant"},
            {"motion": "sitting", "sound": "talking", "location": "chinese_restaurant"},
            {"motion": "sitting", "sound": "talking", "location": "chinese_restaurant"},
            {"motion": "walking", "sound": "others", "location": "chinese_restaurant"},
            {"motion": "walking", "sound": "tableware", "location": "chinese_restaurant"},
            {"motion": "sitting", "sound": "laugh", "location": "chinese_restaurant"},
            {"motion": "sitting", "sound": "talking", "location": "chinese_restaurant"},
            {"motion": "sitting", "sound": "tableware", "location": "residence"},
            {"motion": "sitting", "sound": "others", "location": "glass_store"}]
        }
      
  • Response 201 (application/json)

      {
      "result":{
          "code":0,
          "scores":{
              "dining.chineseRestaurant":-67.08776698008978
          },
          "message":"Classifying successfully! at Tue May 19 2015 16:33:48 GMT+0800 (CST)"
      }
      }
    

Init a Model for a event [/initModelParams/]

You can init a model params with tag, event label and algo type.

Init Model [POST]

  • Request (application/json)

    • Header

        X-AVOSCloud-Application-Id  : dkc5xdbwprsrh9809kqwopja5ckfbsrpd7dz9a30yugm9tut,
        X-AVOSCloud-Application-Key : 3sy9w8uwlr35xl54lja3rawyf8xjrhofxtvcwzng3blg7q31
      
    • Body

        {
        "algoType": "GMMHMM",
        "tag": "random_generated_base_model",
        "eventLabel": "dining.chineseRestaurant"
        }
      
  • Response 201 (application/json)

      {
      "result":{
          "code":0,
          "modelId":"555c8fe2e4b044c3499f2d2d",
          "message":"Model init successfully! at Wed May 20 2015 21:45:06 GMT+0800 (CST)"
          }
      }
    

About

A manager of manipulating hidden markov model parameters

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages