This guide shows a person how to run all commands without confusion. Just copy-paste the commands into your terminal.
After running predictions, all outputs are saved to:
fuzzy_logic/
├── outputs/ # All prediction & comparison results
│ ├── anfis/ # ANFIS model outputs
│ ├── random_forest/ # Random Forest model outputs
│ └── comparison/ # Combined model comparisons & metrics
├── randomforest/ # Random Forest module (do not edit)
├── results/ # Trained models & encoders (do not edit)
└── [data files]
cd c:\Users\USER\my_desktop\neuro_fuzzy\fuzzy_logic
python predict_fault.py --file test_model.csv --method allpython predict_fault.py --file test_model.csv --method duvalpython predict_fault.py --single "{\"H2\":100, \"CH4\":50, \"C2H6\":30, \"C2H4\":20, \"C2H2\":5, \"CO\":15}"Output location: outputs/anfis/
python randomforest/rf_predict.py --file test_model.csv --method allpython randomforest/rf_predict.py --file test_model.csv --method rogerspython randomforest/rf_predict.py --single "{\"H2\":100, \"CH4\":50, \"C2H6\":30, \"C2H4\":20, \"C2H2\":5, \"CO\":15}"Output location: outputs/random_forest/
python compare_models.py --file test_model.csv --method all --output compare_results.csvpython compare_models.py --file labeled_test.csv --method all --label-column FAULT --output results.csvpython compare_models.py --single "{\"H2\":100, \"CH4\":50, \"C2H6\":30, \"C2H4\":20, \"C2H2\":5, \"CO\":15}" --method duvalOutput location: outputs/comparison/
results.csv— merged predictions from both modelsresults_metrics.txt— accuracy, precision, recall, F1-scorescm_*.png— confusion matrix plotsagreement_report.txt— how often ANFIS & RF agree
| Command | Input | Output | When to Use |
|---|---|---|---|
predict_fault.py --file X.csv |
CSV with gas readings | ANFIS predictions | Quick ANFIS-only predictions |
randomforest/rf_predict.py --file X.csv |
CSV with gas readings | RF predictions | Quick RF-only predictions |
compare_models.py --file X.csv |
CSV with gas readings | Both models' predictions + metrics | Compare ANFIS vs RF |
compare_models.py --file X.csv --label-column FAULT |
CSV with gas readings + ground truth | Full evaluation report + confusion matrices | Full evaluation & analysis |
cd c:\Users\USER\my_desktop\neuro_fuzzy\fuzzy_logic
python predict_fault.py --file your_data.csv --method duval
# Check outputs/anfis/ for resultscd c:\Users\USER\my_desktop\neuro_fuzzy\fuzzy_logic
python randomforest/rf_predict.py --file your_data.csv --method duval
# Check outputs/random_forest/ for resultscd c:\Users\USER\my_desktop\neuro_fuzzy\fuzzy_logic
python compare_models.py --file your_labeled_data.csv --label-column TrueLabel --method all
# Check outputs/comparison/ for:
# - results.csv (merged predictions)
# - results_metrics.txt (accuracy, precision, recall, F1)
# - cm_*.png (confusion matrix plots)Your CSV file should contain these columns (in any order):
H2— Hydrogen concentration (ppm)CH4— Methane concentration (ppm)C2H6— Ethane concentration (ppm)C2H4— Ethylene concentration (ppm)C2H2— Acetylene concentration (ppm)CO— Carbon Monoxide concentration (ppm)
Optional: If comparing with ground truth, add a label column:
FAULTorTrueLabelorground_truth(name doesn't matter, just specify it with--label-column)
Example labeled file:
H2,CH4,C2H6,C2H4,C2H2,CO,FAULT
100,50,30,20,5,15,Normal
500,200,100,80,10,50,T2
1000,800,300,200,50,100,T3# Run only Duval method (ANFIS)
python predict_fault.py --file test.csv --method duval
# Run only Rogers method (Random Forest)
python randomforest/rf_predict.py --file test.csv --method rogers# For Duval method (4 features: H2, CH4, C2H6, C2H4)
python predict_fault.py --single "{\"H2\":100, \"CH4\":50, \"C2H6\":30, \"C2H4\":20}"
# For Rogers method (6 features: all)
python compare_models.py --single "{\"H2\":100, \"CH4\":50, \"C2H6\":30, \"C2H4\":20, \"C2H2\":5, \"CO\":15}" --method rogersAfter running predictions, you'll see:
outputs/
├── anfis/
│ ├── duval_predictions.csv
│ ├── rogers_predictions.csv
│ ├── drm_predictions.csv
│ └── anfis_summary.txt
├── random_forest/
│ ├── duval_rf_predictions.csv
│ ├── rogers_rf_predictions.csv
│ ├── drm_rf_predictions.csv
│ └── rf_summary.txt
└── comparison/
├── results.csv
├── results_metrics.txt
├── cm_duval_anfis.png
├── cm_duval_rf.png
├── cm_rogers_anfis.png
├── cm_rogers_rf.png
├── cm_drm_anfis.png
├── cm_drm_rf.png
└── agreement_report.txt
- Make sure your CSV file is in the
fuzzy_logic/directory, or provide the full path:python predict_fault.py --file "C:\path\to\your\file.csv"
- Your CSV must have the required gas concentration columns:
H2,CH4,C2H6,C2H4,C2H2,CO - Check that column names match exactly (case-sensitive)
- Make sure you provided
--label-columnwith the correct column name - Example:
--label-column FAULT(if your CSV has a column named "FAULT")
- These are non-fatal warnings — predictions are still correct
- Warnings go away in updated version (auto-fixed by refactoring)
| Goal | Command |
|---|---|
| Quick test of ANFIS | python predict_fault.py --file test_model.csv --method all |
| Quick test of RF | python randomforest/rf_predict.py --file test_model.csv --method all |
| Compare both models | python compare_models.py --file test_model.csv --method all |
| Full evaluation (with labels) | python compare_models.py --file labeled.csv --label-column FAULT --method all |
| Test single sample | python compare_models.py --single "{...}" --method duval |
All outputs go to outputs/ directory. No messy files scattered around!
For questions or issues, check the command syntax above or see individual module READMEs.


