Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

kinesis feature not printing any output #13

Open
eliquinox opened this issue Sep 21, 2023 · 3 comments
Open

kinesis feature not printing any output #13

eliquinox opened this issue Sep 21, 2023 · 3 comments

Comments

@eliquinox
Copy link

I have trained a kinesis leftArm via dev console and wanted to access it via the python API. My script:

from neurosity import NeurositySDK
from dotenv import load_dotenv
import os
import time

load_dotenv("my.env")

device_id = os.getenv("NEUROSITY_DEVICE_ID")
neurosity = NeurositySDK({
    "device_id": device_id
})

neurosity.login({
    "email": os.getenv("NEUROSITY_EMAIL"),
    "password": os.getenv("NEUROSITY_PASSWORD")
})

info = neurosity.get_info()

def callback(data):
    print(data)

unsubscribe = neurosity.kinesis("leftArm", callback)

time.sleep(20)
unsubscribe()
print("Done with example.py")

When I run the script, however, I get no output. Not sure where the problem is.

@AshishSardana
Copy link

Does your kinesis model work in the developer console?
image

@AdonaiVera
Copy link
Contributor

Hi @eliquinox 👋 ,

To obtain the prediction, please use the kinesis_predictions function. Below is the example code:

from neurosity import NeurositySDK
from dotenv import load_dotenv
import os
import time

# Load environment variables from a .env file
load_dotenv("my.env")

# Initialize Neurosity SDK with device ID
device_id = os.getenv("NEUROSITY_DEVICE_ID")
neurosity = NeurositySDK({"device_id": device_id})

# Log in to Neurosity
neurosity.login({
    "email": os.getenv("NEUROSITY_EMAIL"),
    "password": os.getenv("NEUROSITY_PASSWORD")
})

# Fetch device information
info = neurosity.get_info()

# Callback function to process the data
def callback(data):
    print(data)

# Subscribe to kinesis events for the left arm
unsubscribe = neurosity.kinesis("leftArm", callback)

# Wait for 20 seconds to collect data
time.sleep(20)

# Unsubscribe and clean up
unsubscribe()
print("Finished execution of example.py")

Here are the results from running the above script:

{"label": "push", "metric": "kinesis", "probability": 0.01727728877348198, "timestamp": 1713891598118, "type": "training"}
{"label": "push", "metric": "kinesis", "probability": 0.013549573655196736, "timestamp": 1713891598243, "type": "training"}
{"label": "push", "metric": "kinesis", "probability": 0.01411070240397368, "timestamp": 1713891598368, "type": "training"}
{"label": "push", "metric": "kinesis", "probability": 0.01187809103675398, "timestamp": 1713891598493, "type": "training"}

Please let me know if this works for you!

PDT: If there is no response, it could be due to an incorrect naming of the trained action.

@uzaymacar
Copy link

In case someone else is also confused, exactly like @AdonaiVera said:

unsubscribe = neurosity.kinesis_predictions("leftArm", callback)

instead of

unsubscribe = neurosity.kinesis("leftArm", callback)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants