A small Flask application for B2B trust scoring that loads a trained classification model and exposes a prediction UI and API.
app.py— Flask web service and prediction APIrandfor.py— Random Forest training pipeline and feature selection scriptmain.py— XGBoost training script with feature selectiontemplates/ui.html— front-end dashboard for uploading CSV files and viewing predictionsdata/— dataset files used for training and testingmodels/— serialized model artifacts and encoder metadatadocs/— supporting documentation and project notes
- Create and activate a virtual environment:
python -m venv .venv
.\.venv\Scripts\Activate.ps1- Install dependencies:
pip install -r requirements.txt- Ensure the dataset is available at
data/b2b_credit_scoring_dataset.csv.
Start the Flask server:
python app.pyOpen http://localhost:5000 to use the prediction UI.
- Endpoint:
POST /api/predict - Supported input:
- multipart form file upload named
file - JSON body with
datacontaining a list of row objects
- multipart form file upload named
Example JSON payload:
{
"data": [
{
"customer_id": "123",
"company_name": "Example Inc.",
"external_credit_rating": 5,
"company_size": "Small"
}
]
}randfor.pytrains a Random Forest model and saves the artifacts undermodels/.main.pytrains an XGBoost model and saves separate artifacts undermodels/.
Update the dataset path in data/b2b_credit_scoring_dataset.csv if necessary.
- Do not commit local environment files or generated binaries.
models/anddata/are included in the project structure, but model artifacts and raw CSV files should be managed outside version control when possible.