Sensitivity
Introduction to Sensitivity
Sensitivity in the context of APIs refers to the ability to evaluate and quantify the impact of changes in input data on the output results. This is crucial in scenarios where understanding the influence of different variables can guide decision-making processes, optimize performance, and ensure robustness. The FastAPI platform provides endpoints to calculate sensitivity scores, helping developers and analysts assess how sensitive their models or systems are to changes in input data.
Key Concepts
Sensitivity Score
A Sensitivity Score is a numerical representation of how responsive a system or model is to changes in its inputs. It helps identify which inputs have the most significant impact on the output, allowing for better prioritization and tuning of these inputs.
Batch Sensitivity Scores
Batch Sensitivity Scores extend the concept of individual sensitivity by allowing multiple inputs to be evaluated simultaneously. This is particularly useful for processing large datasets where understanding the collective sensitivity is necessary.
Common Workflows
Single Sensitivity Score Calculation
To calculate a single sensitivity score, you can use the /v1/sensitivity endpoint. This is typically used when you need to assess the sensitivity of a specific input or scenario.
- Prepare your input data in JSON format.
- Make a POST request to
/v1/sensitivitywith the input data. - Optionally include the
X-API-Keyin the header for authentication. - Receive the sensitivity score in the response.
Batch Sensitivity Score Calculation
For evaluating multiple inputs at once, the /v1/sensitivity/batch endpoint is used. This is ideal for batch processing and analyzing the sensitivity across a dataset.
- Prepare your batch input data in JSON format.
- Make a POST request to
/v1/sensitivity/batchwith the batch data. - Optionally include the
X-API-Keyin the header for authentication. - Receive the batch sensitivity scores in the response.
Practical Examples
Example: Single Sensitivity Score
curl -X POST "https://api.example.com/v1/sensitivity" \
-H "Content-Type: application/json" \
-H "X-API-Key: YOUR_API_KEY" \
-d '{
"input_data": {
"variable1": 10,
"variable2": 20
}
}'Example: Batch Sensitivity Scores
curl -X POST "https://api.example.com/v1/sensitivity/batch" \
-H "Content-Type: application/json" \
-H "X-API-Key: YOUR_API_KEY" \
-d '{
"batch_data": [
{"variable1": 10, "variable2": 20},
{"variable1": 15, "variable2": 25}
]
}'Important Considerations
Authentication
While the X-API-Key is optional, using it is recommended to authenticate your requests and ensure access to the API. This helps maintain security and track usage.
Error Handling
Ensure your application handles potential errors, such as network issues or invalid input data. The API will return standard HTTP error codes, which should be checked and handled appropriately.
Pagination
For batch requests, consider implementing pagination if the dataset is large. This will help manage the load and improve performance by processing data in smaller chunks.
By understanding and utilizing these endpoints, developers can effectively measure and analyze the sensitivity of their systems, leading to more informed decision-making and optimized performance.