Giter Club home page Giter Club logo

pjitai-python's Introduction

mDOT pJITAI (Just-In-Time Adaptive Intervention) interface library

Example

import pJITAI

# Create a new session to an existing API service
session = pJITAI.Client(server='http://localhost/api', service_id='028fa04c-943d-4ae3-9885-55b4bdf4337e',
service_token='e6e74d36-a3e4-4631-b077-4fdd703636f2')

# Upload some data
data = {
    'decision': 1,
    'decision_timestamp': '2022-06-01T08:30:00-05:00',
    'proximal_outcome': 45,
    'proximal_outcome_timestamp': '2022-06-01T09:00:00-05:00',
    'timestamp': '2022-06-01T09:05:00-05:00',
    'user_id': 'user_0',
    'values': [{
        'name': 'step_count',
        'value': 229
    }]
}
try:
    data_to_upload = pJITAI.DataVector.from_dict(data)
    session.upload(data_to_upload)
    print(data_to_upload)
except Exception as e:
    print(f'Upload Exception: {e}')

# Ask the server to generated a decision
data = {
    'timestamp': '2022-06-01T08:30:00-05:00',
    'user_id': 'user_0',
    'values': [{
        'name': 'step_count',
        'value': 24
    }]
}
try:
    decision = pJITAI.DecisionVector.from_dict(data)
    session.decision(decision)
    print(decision)
except Exception as e:
    print(f'Upload Exception: {e}')

# Have the server update the model parameters based on already uploaded data
try:
    session.update()
except Exception as e:
    print(f'Upload Exception: {e}')

Build and release

bumpver update -p

python3 -m build

twine check dist/*
twine upload dist/*

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.