ModelQuery
ModelQuery
A class which allows for querying a model serving endpoint on databricks.
This class is used to query a model serving endpoint on databricks with a dataset.
Example:
url = "https://example.com/model_endpoint"
token = "your_auth_token"
# Create an instance of ModelQuery
model_query = ModelQuery(url, token)
# Example dataset
dataset = pd.DataFrame({'feature1': [1, 2, 3], 'feature2': [4, 5, 6]})
try:
# Score the model using the dataset
response = model_query.score_model(dataset)
print(response)
except requests.exceptions.HTTPError as e:
print(f"Error: {str(e)}")
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
url
|
str
|
The URL of the model serving endpoint. |
required |
token
|
str
|
The authorization token for the model serving endpoint. |
required |
Source code in src/fleming/discovery/model_query.py
create_tf_serving_json(data)
Creates a JSON object for TensorFlow serving.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
data
|
Union[dict, DataFrame, ndarray]
|
The input data. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
dict |
The JSON object for TensorFlow serving. |
Source code in src/fleming/discovery/model_query.py
score_model(dataset)
Scores the model using the provided dataset.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
dataset
|
Union[DataFrame, ndarray]
|
The dataset to be scored. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
dict |
The response JSON from the model serving endpoint. |
Raises:
| Type | Description |
|---|---|
HTTPError
|
If the request to the model serving endpoint fails. |