Integrate Spavik into your application
Install the Python or JavaScript SDK, or call the REST API from your application.
Install an SDK
Python
$
pip install spavik JavaScript
$
npm install spavik The SDK reads your key from the SPAVIK_API_KEY variable.
Installation and code examples
Python library
Evaluate your history, create a model and make predictions in Python. The SDK supports synchronous and asynchronous calls.
$
pip install spavik app.py
from spavik import Spavik
spavik = Spavik() # reads SPAVIK_API_KEY
# 1. check whether the data can predict churn
report = spavik.evaluate("churn.csv", target="churn")
report["assessment"]["status"] # 'better_than_baseline', ...
# 2. create the model
model = spavik.train("churn.csv", target="churn")
# 3. predict churn for a new customer
r = model.predict({"plan": "pro", "seats": 12, "tickets_90d": 3})
r.lignes[0] # {'request_id': 'req_...', 'prediction': 0, ...}Report observed outcomes
Send each observed value with the features of the original row, and the prediction’s request_id when you have it. Review performance before updating the model.
request_idsubmit_outcomes()refresh()
loop.py
model.submit_outcomes([
{"request_id": "req_...",
"features": {"plan": "pro", "seats": 12, "tickets_90d": 3}, "actual": 1},
{"features": {"plan": "free", "seats": 2, "tickets_90d": 10}, "actual": 0},
])
report = model.performance(days=30)
report.get("observed") # None until outcomes include their prediction
model.refresh() # new version with the pending outcomesAccess the API
Create an API key in your workspace to authenticate requests.