Predicts the class of a given set of features. Args: data (dict): A dictionary containing the features to predict. e.g. {"features": [1, 2, 3, 4]} Returns: dict: A dictionary containing the predicted class.
(data: dict)
| 14 | |
| 15 | @app.post('/predict') |
| 16 | def predict(data: dict): |
| 17 | """ |
| 18 | Predicts the class of a given set of features. |
| 19 | |
| 20 | Args: |
| 21 | data (dict): A dictionary containing the features to predict. |
| 22 | e.g. {"features": [1, 2, 3, 4]} |
| 23 | |
| 24 | Returns: |
| 25 | dict: A dictionary containing the predicted class. |
| 26 | """ |
| 27 | features = np.array(data['features']).reshape(1, -1) |
| 28 | prediction = model.predict(features) |
| 29 | class_name = class_names[prediction][0] |
| 30 | return {'predicted_class': class_name} |
| 31 |
nothing calls this directly
no outgoing calls
no test coverage detected