Calculate Risk Scores
This endpoint calculates the risk scores for each uploaded file in a mission. It uses the trained model to evaluate potential issues or anomalies in the data.
Request Parameters
robot_name(string, required)mission_name(string, required)file_paths- data paths of files to analyze risk (list of strings, required)
Example Request
try:
result = calculator.calculate_risk_scores(
robot_name=robot_name,
mission_name=mission_name,
file_paths=inference_files,
)
print("Risk Scores calculated started successfully:")
except Exception as e:
print(f"Risk score calculation failed: {e}")
Reading the risk scores
When the risk score calculation is completed after sometime, you can view the scores by calling the list_files function.
files = calculator.list_files(robot_name, mission_name)
for file in files:
print(f"Filename: {file['original_filename']}, Risk Score: {file['risk_score']}")
Example Output
training_01.bag: 64.7
training_02.bag: 70.1Want aggregated results for robots and missions?
You can use the list_robots and list_missions functions to get aggregated results for all robots and missions.
List Robots
robots = calculator.list_robots()
for robot in robots:
print(f"Robot: {robot['name']}, Mission Count: {robot['mission_count']}, Risk Score: {robot['avg_risk_score']}")
List Missions
missions = calculator.list_missions()
for mission in missions:
print(f"Mission: {mission['name']}, File Count: {mission['file_count']}, Risk Score: {mission['avg_risk_score']}")