Deployed model¶
Prevision.io’s SDK allows to make a prediction from a model deployed with the Prevision.io’s platform.
import previsionio as pio
# Initialize the deployed model object from the url of the model, your client id and client secret for this model, and your credentials
model = pio.DeployedModel(prevision_app_url, client_id, client_secret)
# Make a prediction
prediction, confidance, explain = model.predict(
predict_data={'feature1': 1, 'feature2': 2},
use_confidence=True,
explain=True,
)
-
class
previsionio.deployed_model.
DeployedModel
(prevision_app_url: str, client_id: str, client_secret: str, prevision_token_url: str = None)¶ DeployedModel class to interact with a deployed model.
Parameters: - prevision_app_url (str) – URL of the App. Can be retrieved on your app dashbord.
- client_id (str) – Your app client id. Can be retrieved on your app dashbord.
- client_secret (str) – Your app client secret. Can be retrieved on your app dashbord.
- prevision_token_url (str) – URL to get the OAuth2 token of the deployed model. Required only if working on-premise (custom IP address) otherwise it is retrieved automatically.
-
predict
(predict_data: Dict = None, use_confidence: bool = False, explain: bool = False, top_k: int = None, image_path: str = None, threshold: float = None) → Dict¶ Get a prediction on a single instance using the best model of the experiment.
Parameters: - predict_data (dict, optional) – input data for prediction
- confidence (bool, optional) – Whether to predict with confidence values
(default:
False
) - explain (bool, optional) – Whether to explain prediction (default:
False
) - top_k (int, optional) – Number of closest items to return for text-similarity
- image_path (str, optional) – Image path for object detection
- threshold (float, optional) – prediction threshold for object detection
Returns: prediction result
Return type:
-
request
(endpoint: str, method, files: Dict = None, data: Dict = None, allow_redirects: bool = True, content_type: str = None, check_response: bool = True, message_prefix: str = None, **requests_kwargs)¶ Make a request on the desired endpoint with the specified method & data.
Requires initialization.
Parameters: Returns: request response
Raises: Exception
– Error if url/token not configured