Documentation Index
Fetch the complete documentation index at: https://mintlify.com/jonatan-leal/ia-proyecto-sustituto/llms.txt
Use this file to discover all available pages before exploring further.
Endpoint
Request
Headers
Body
The request body must contain a valid Patient object with all required fields.Patient’s gender. Must be one of:
FemaleMaleOther
Patient’s age in years (e.g., 45)
Whether the patient has hypertension:
0: No hypertension1: Has hypertension
Whether the patient has heart disease:
0: No heart disease1: Has heart disease
Patient’s smoking history. Must be one of:
never: Never smokedformer: Former smokercurrent: Current smokernot current: Not currently smokingever: Has smoked at some pointNo Info: No information available
Body Mass Index (BMI) of the patient (e.g., 27.5)
Hemoglobin A1c level, a measure of average blood sugar over 2-3 months (e.g., 5.7)Normal range: 4.0 - 5.6%Prediabetes: 5.7 - 6.4%Diabetes: 6.5% or higher
Blood glucose level in mg/dL (e.g., 140)Normal (fasting): 70 - 100 mg/dLPrediabetes: 100 - 125 mg/dLDiabetes: 126 mg/dL or higher
Response
Prediction result. Possible values:
"Tiene diabetes": Patient is predicted to have diabetes"No tiene diabetes": Patient is predicted not to have diabetes"Something went wrong": An error occurred during prediction
Examples
Response Examples
Success - No Diabetes
Status Code:200 OK
Success - Has Diabetes
Status Code:200 OK
Error Response
Status Code:200 OK
Validation Error
Status Code:422 Unprocessable Entity
When required fields are missing or have invalid values:
Prediction Process
The prediction endpoint performs the following steps:Validate Input
Validates that all required Patient fields are present and correctly typed using Pydantic validation.
Load Model
Checks if
model.pkl exists and loads the trained model. Returns an error if the model hasn’t been trained yet.Encode Data
Converts categorical variables to numeric codes:
- Gender: Female (0), Male (1), Other (2)
- Smoking History: No Info (0), current (1), ever (2), former (3), never (4), not current (5)
Common Issues
Model not trained
Model not trained
Error: Prediction fails because
model.pkl doesn’t exist.Solution: Train the model first using POST /train before making predictions.Invalid gender value
Invalid gender value
Error: 422 validation error for gender field.Solution: Ensure gender is exactly one of:
Female, Male, or Other (case-sensitive).Invalid smoking_history value
Invalid smoking_history value
Error: 422 validation error for smoking_history field.Solution: Use one of the valid values:
never, former, current, not current, ever, or No Info.Missing required fields
Missing required fields
Error: 422 validation error with “field required” message.Solution: Include all 8 required fields in the request body. See the Patient Model for details.
Wrong data types
Wrong data types
Error: 422 validation error with “value is not a valid” message.Solution: Ensure correct data types:
- Strings: gender, smoking_history
- Integers: age, hypertension, heart_disease, blood_glucose_level
- Floats: bmi, HbA1c_level
Understanding Results
The prediction is based on machine learning and should be used as a screening tool only. Always consult healthcare professionals for medical diagnosis.
Risk Factors
The model considers multiple risk factors when making predictions:- Age: Diabetes risk increases with age
- BMI: Higher BMI correlates with increased diabetes risk
- HbA1c Level: Direct indicator of blood sugar control
- Blood Glucose Level: Key diagnostic marker
- Hypertension: Often co-occurs with diabetes
- Heart Disease: Shares risk factors with diabetes
- Smoking History: Increases diabetes risk
- Gender: May influence risk patterns
Interpreting Predictions
No tiene diabetes
The model predicts the patient does not have diabetes based on their health metrics.Note: This is a screening prediction, not a medical diagnosis.
Tiene diabetes
The model predicts the patient may have diabetes based on their health metrics.Recommendation: Consult a healthcare provider for proper testing and diagnosis.
Best Practices
Validate data before sending
Ensure all patient data is accurate and in the correct format before making API calls.
Handle errors gracefully
Implement proper error handling in your application to manage validation errors and API failures.
Don't rely solely on predictions
Use predictions as a screening tool alongside clinical judgment and proper medical testing.
Related Resources
Patient Model Schema
Complete reference for the Patient data model
Train Endpoint
Learn how to train the prediction model