Skip to content

Commit 4b4f5d2

Browse files
committed
Updated README adding how to run the API locally
1 parent bf8c912 commit 4b4f5d2

File tree

1 file changed

+18
-3
lines changed

1 file changed

+18
-3
lines changed

README.md

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -118,9 +118,24 @@ Once the environment is set up and dependencies are installed (using either `uv`
118118
pytest -v
119119
```
120120
121+
2. **Train the Machine Learning Pipeline:**
122+
This step will load `data/data.csv`, preprocess it, train the Random Forest classifier within a `scikit-learn` pipeline, evaluate it, and then save the complete trained pipeline to `models/model.joblib`. Ensure your virtual environment is activated and `data/data.csv` is present, then run:
123+
```powershell
124+
python -m src.model.model_training
125+
```
126+
This will train the pipeline and save it as `models/model.joblib`.
127+
128+
3. **Run the Flask API locally:**
129+
Ensure your virtual environment is activated and the model pipeline is trained (`models/model.joblib` exists), then run:
130+
```bash
131+
python -m src.app
132+
```
133+
The API will be accessible at `http://127.0.0.1:5000/`. Keep this running in one terminal.
134+
135+
121136
## API usage examples
122137
123-
With the Flask API running locally (as described in step 6 under "Setup and Run"), you can test its endpoints:
138+
With the Flask API running locally (as described in the 'Run the Flask API locally' step under 'Running tests'), you can test its endpoints:
124139
125140
### 1. Health check (`GET /`)
126141
@@ -159,7 +174,7 @@ With the Flask API running locally (as described in step 6 under "Setup and Run"
159174
& ".\tests\integration\powershell_test.ps1"
160175
```
161176
162-
(Ensure the Flask API is running locally as described in step 6 under "Setup and Run" before running these scripts.)
177+
(Ensure the Flask API is running locally as described in the 'Run the Flask API locally' step under 'Running tests' before running these scripts.)
163178
164179
**Expected Output:**
165180
```json
@@ -176,7 +191,7 @@ With the Flask API running locally (as described in step 6 under "Setup and Run"
176191
The Streamlit application (`src/streamlit_app.py`) provides an interactive web interface for making predictions using the Flask API.
177192

178193
1. **Run the Streamlit application locally:**
179-
Ensure your virtual environment is activated and the Flask API is running (as described in step 6 under "Setup and Run"), then run:
194+
Ensure your virtual environment is activated and the Flask API is running (as described in the 'Run the Flask API locally' step under 'Running tests'), then run:
180195
```bash
181196
streamlit run src/streamlit_app.py
182197
```

0 commit comments

Comments
 (0)