Metadata-Version: 2.1
Name: pJITAI
Version: 1.0.3
Summary: The mHealth Center for Discovery, Optimization & Translation of Temporally-Precise Intervention tookbox for personalized Just-In-Time Adaptive Interventions
Author-email: mDOT Center <dev@md2k.org>
License: Copyright (c) 2022. University of Memphis, mDOT Center
        
        Redistribution and use in source and binary forms, with or without modification, are permitted
        provided that the following conditions are met:
        
        1. Redistributions of source code must retain the above copyright notice, this list of conditions
        and the following disclaimer.
        2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions
        and the following disclaimer in the documentation and/or other materials provided with the distribution.
        3. Neither the name of the copyright holder nor the names of its contributors may be used to
        endorse or promote products derived from this software without specific prior written permission.
        
        THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
        ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
        WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
        IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
        INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
        NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
        PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
        WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
        ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
        OF SUCH DAMAGE.
Project-URL: Homepage, https://github.com/mDOT-Center/pJITAI-python
Keywords: mHealth,mDOT,JITAI,Reinforcement Learning
Classifier: License :: OSI Approved :: BSD License
Classifier: Programming Language :: Python
Classifier: Programming Language :: Python :: 3
Requires-Python: >=3.9
Description-Content-Type: text/markdown
Provides-Extra: dev
License-File: LICENSE.md

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

## Example

```python

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}')
```
