A machine-learning workflow is an ordered pipeline that turns prepared data into model predictions and measured performance. The practical risk is treating a generated notebook as a finished system: missing input preparation can stop execution, while a working model can still be unsuitable for production. section 4.5.4 section 4.5.6
A disciplined workflow makes each stage explicit:
- Load the preprocessed CSV; the pipeline depends on the earlier feature-engineering step having created it. section 4.5.4
- Clean and prepare the data by removing null Dosage_Value and Salt_Name entries and filtering prices above the 99th percentile. section 4.5.4
- Select and encode features, including categorical handling for Salt_Name, before fitting the model. section 4.5.4
- Fit a RandomForestRegressor and evaluate predictions with R², mean absolute error, and root mean square error. section 4.5.4
- Treat evaluation as a decision point rather than a victory condition: rough price estimation may be acceptable, but missing domain factors can block production use. section 4.5.6
Price prediction pipeline
A medicine-price workflow loads engineered features, removes incomplete rows and extreme prices, encodes categorical values, trains a regressor, and calculates R², MAE, and RMSE on predictions. The resulting model can support rough estimation while still exposing gaps in the features used by human experts. section 4.5.4 section 4.5.6
price_threshold = df['price'].quantile(0.99) df = df[df['price'] < price_threshold]
Inspect the explicit 99th-percentile price filter used to remove outliers or potentially broken values before training. section 4.5.4
Listing 4.5 Evaluating the model’s performance
Y_pred = model.predict(X_test) r2 = r2_score(Y_test, Y_pred) mae = mean_absolute_error(Y_test, Y_pred) rmse = np.sqrt(np.mean((Y_test - Y_pred)**2))
Inspect the evaluation calculation that compares predictions with held-out test values using R², MAE, and RMSE. section 4.5.4








