Input Schemas
CreditRiskInput
Defines the structure of input data for credit risk prediction. Field names match the original dataset columns.Age of the applicant in years. Must be greater than 0.
Sex of the applicant. Valid values:
male, femaleHousing type of the applicant. Valid values:
own, rent, freeStatus of the applicant’s savings account. See SavingAccountsEnum for valid values.
Status of the applicant’s checking account. See CheckingAccountEnum for valid values.
Amount of credit requested. Must be greater than 0.
Duration of the credit in months. Must be greater than 0.
Purpose of the credit. See PurposeEnum for valid values.
The schema uses field aliases to support spaces in field names (e.g., “Saving accounts”, “Checking account”, “Credit amount”). Both the aliased and underscore versions are accepted.
Output Schemas
CreditRiskOutput
Defines the structure of the API response for credit risk prediction.Credit risk prediction: either “good” or “bad”
Probability that the risk is “good” (range: 0.0 to 1.0)
Enums
SexEnum
Defines valid values for the applicant’s sex.| Value | Description |
|---|---|
male | Male applicant |
female | Female applicant |
JobEnum
Defines valid job skill levels for the applicant.| Value | Description |
|---|---|
unskilled and non-resident | Level 0 - Unskilled and non-resident |
unskilled and resident | Level 1 - Unskilled and resident |
skilled | Level 2 - Skilled worker |
highly skilled | Level 3 - Highly skilled worker |
The
Job field has a custom validator that converts JobEnum values to their numeric level (0-3) when processing.HousingEnum
Defines valid housing types for the applicant.| Value | Description |
|---|---|
own | Owns housing |
rent | Rents housing |
free | Free housing |
SavingAccountsEnum
Defines valid savings account statuses.| Value | Description |
|---|---|
NA | No savings account information |
little | Little savings |
moderate | Moderate savings |
quite rich | Quite rich savings |
rich | Rich savings |
CheckingAccountEnum
Defines valid checking account statuses.| Value | Description |
|---|---|
NA | No checking account information |
little | Little balance |
moderate | Moderate balance |
rich | Rich balance |
PurposeEnum
Defines valid purposes for the credit request.| Value | Description |
|---|---|
car | Purchase a car |
furniture/equipment | Purchase furniture or equipment |
radio/TV | Purchase radio or TV |
domestic appliances | Purchase domestic appliances |
repairs | Home or property repairs |
education | Education expenses |
business | Business purposes |
vacation/others | Vacation or other purposes |
Validation
All schemas include Pydantic validation:- Type validation: Ensures all fields match their declared types
- Range validation: Age, Credit amount, and Duration must be greater than 0
- Enum validation: Categorical fields must use valid enum values
- Probability validation: Output probability must be between 0.0 and 1.0
Source Code Reference
View the complete implementation atserver/schemas.py:1-109