{"id":26811239,"url":"https://github.com/exios66/cwt-learning_model","last_synced_at":"2026-02-14T02:37:12.704Z","repository":{"id":282811881,"uuid":"949731081","full_name":"Exios66/CWT-Learning_Model","owner":"Exios66","description":null,"archived":false,"fork":false,"pushed_at":"2025-03-29T05:14:17.000Z","size":661,"stargazers_count":1,"open_issues_count":2,"forks_count":1,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-04-23T16:48:21.670Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Exios66.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":"SECURITY.md","support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2025-03-17T03:36:01.000Z","updated_at":"2025-03-29T05:14:20.000Z","dependencies_parsed_at":null,"dependency_job_id":"697c5cf2-6e06-4b25-b51a-d26599c68fa5","html_url":"https://github.com/Exios66/CWT-Learning_Model","commit_stats":null,"previous_names":["exios66/cwt-learning_model"],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/Exios66/CWT-Learning_Model","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Exios66%2FCWT-Learning_Model","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Exios66%2FCWT-Learning_Model/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Exios66%2FCWT-Learning_Model/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Exios66%2FCWT-Learning_Model/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Exios66","download_url":"https://codeload.github.com/Exios66/CWT-Learning_Model/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Exios66%2FCWT-Learning_Model/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29432388,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-14T02:20:56.896Z","status":"ssl_error","status_checked_at":"2026-02-14T02:11:29.478Z","response_time":53,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2025-03-30T01:38:04.658Z","updated_at":"2026-02-14T02:37:12.672Z","avatar_url":"https://github.com/Exios66.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Cognitive Workload Training (CWT) Tool\n\nA comprehensive tool for training machine learning models to detect and classify cognitive workload levels based on physiological and behavioral metrics.\n\n## Features\n\n- Multi-modal data integration (physiological, EEG, and gaze tracking)\n- Support for multiple machine learning algorithms:\n  - Random Forest\n  - Support Vector Machine\n  - Gradient Boosting\n  - Neural Network (MLP)\n  - K-Nearest Neighbors\n  - Logistic Regression\n- Automatic data preprocessing and feature standardization\n- Model persistence and metadata tracking\n- Visualization of model performance\n- Pre-trained sample models for immediate use\n\n## Recent Enhancements\n\nThe CWT Tool has been enhanced with the following new features:\n\n1. **Unified Training Command**: A new `train-all` command allows training all model types in a single operation.\n   - Options to train in parallel for faster execution\n   - Ability to skip specific model types\n   - Shared scaler to ensure consistent scaling across models\n\n2. **Feature Inference Capabilities**: The system can now handle missing features by inferring them from available data.\n   - Specialized inference for pupil metrics, EEG signals, and workload intensity\n   - Uses physiological correlations from reference data\n   - Falls back to synthetic reference data generation when needed\n\n3. **Confidence Thresholds**: Prediction functions now support confidence thresholds to improve reliability.\n   - Predictions below the specified threshold are marked as uncertain\n   - Enhances the quality of workload predictions\n\n4. **Enhanced Batch Processing**: Improved capabilities for processing files with multiple data points.\n   - Better support for CSV files with missing features\n   - Time series analysis with sliding window approach\n   - Visualization options for time series predictions\n\n5. **New Utilities**:\n   - **Command Dictionary**: Interactive help system with detailed information on all commands\n   - **Automated Start Script**: One-command setup of the entire environment with model training and analysis preparation\n\n## Quick Start\n\nTo get up and running quickly with the CWT Tool, simply run:\n\n```bash\n./start.py\n```\n\nThis will:\n\n1. Set up the CWT environment\n2. Train all available model types (with parallel processing)\n3. Prepare sample predictions and analyses\n4. Generate an overview of model performance\n\nAfter completion, you'll have trained models ready for use and examples of predictions in the `results` directory.\n\n## Command Reference\n\nFor a complete list of available commands and their options, run:\n\n```bash\n./commands.py\n```\n\nFor detailed help on a specific command:\n\n```bash\n./commands.py [command]\n```\n\nFor example: `./commands.py train-all` will show all options for training all models at once.\n\n## Working with Missing Features\n\nThe CWT Tool can now handle data with missing features by using the `--infer-missing` flag:\n\n```bash\npython cwt.py predict --input-json data/incomplete_sample.json --infer-missing\n```\n\nThis works by:\n\n1. Detecting which features are missing\n2. Loading reference data to understand feature correlations\n3. Using specialized algorithms to infer the missing values\n4. Applying the standard prediction pipeline with the complete dataset\n\n## Command Reference\n\n### setup\n\n```bash\npython cwt.py setup\n```\n\n### train\n\n```bash\npython cwt.py train [--model-type TYPE] [--output-dir DIR]\n```\n\n- `--model-type`: Type of model to train (svm, random_forest, knn, mlp, gradient_boosting, decision_tree)\n- `--output-dir`: Directory to save the trained model\n\n### train-all\n\n```bash\npython cwt.py train-all [--output-dir DIR] [--parallel] [--skip-types TYPE1,TYPE2]\n```\n\n- `--output-dir`: Directory to save trained models (default: models/)\n- `--parallel`: Train models in parallel for faster execution\n- `--skip-types`: Comma-separated list of model types to skip (e.g., \"svm,knn\")\n\n### predict\n\n```bash\npython cwt.py predict [--input-json FILE] [--input-values KEY=VALUE...] [--model-type TYPE] [--threshold FLOAT] [--infer-missing] [--output-json FILE]\n```\n\n### batch-predict\n\n```bash\npython cwt.py batch-predict --input-file FILE [--output-file FILE] [--model-type TYPE] [--threshold FLOAT] [--infer-missing]\n```\n\n### time-series-predict\n\n```bash\npython cwt.py time-series-predict --input-file FILE [--output-file FILE] [--window-size INT] [--step-size INT] [--model-type TYPE] [--threshold FLOAT] [--infer-missing] [--visualize]\n```\n\n## Example Script\n\nAn example script `example.sh` is provided to demonstrate the key features:\n\n```bash\n# Make it executable\nchmod +x example.sh\n\n# Run the example\n./example.sh\n```\n\n## Reference Data\n\nTo improve feature inference accuracy, you can provide custom reference data:\n\n```\ndata/reference/cognitive_workload_reference.csv\n```\n\nThis file should contain representative samples with all the features used by the models.\n\n## Installation\n\n1. Clone this repository:\n\n```bash\ngit clone https://github.com/yourusername/CWT-Learning_Model.git\ncd CWT-Learning_Model\n```\n\n2. Create a virtual environment and activate it:\n\n```bash\npython -m venv .venv\nsource .venv/bin/activate  # On Windows: .venv\\Scripts\\activate\n```\n\n3. Install dependencies:\n\n```bash\npip install -r requirements.txt\n```\n\n4. Initialize the environment:\n\n```bash\npython cwt.py setup\n```\n\n## Usage\n\nThe CWT provides a command-line interface with several commands:\n\n### Getting Help\n\n```bash\npython cwt.py help\n# or\n./!help\n# or for complete command reference\n./commands.py\n```\n\n### Training a Model\n\nTrain a specific model type:\n\n```bash\npython cwt.py train --model-type svm\n```\n\nTrain all available model types:\n\n```bash\npython cwt.py train-all --output-dir models/ensemble --parallel\n```\n\n### Making Predictions\n\nPredict with explicit input values:\n\n```bash\npython cwt.py predict --input-values \"pulse_rate=75\" \"blood_pressure_sys=120\" \"resp_rate=16\"\n```\n\nPredict from JSON file:\n\n```bash\npython cwt.py predict --input-json data/sample_input.json --model-type mlp\n```\n\nBatch predict from CSV with feature inference:\n\n```bash\npython cwt.py batch-predict --input-file data/batch_samples.csv --output-file results.csv --infer-missing\n```\n\nTime series analysis:\n\n```bash\npython cwt.py time-series-predict --input-file data/time_series.csv --window-size 10 --step-size 5 --visualize\n```\n\n### Installing Sample Models\n\n```bash\npython cwt.py install-models\n```\n\n### Downloading Advanced Models\n\nTo improve prediction accuracy, you can download advanced pre-trained models:\n\n```bash\n# Download all advanced models\n./download-models --all\n\n# Download a specific model type\n./download-models --model-type gb\n```\n\nThese advanced models provide several benefits:\n\n- Higher accuracy (up to 0.92 compared to ~0.35 for sample models)\n- Trained on larger datasets (up to 35,000 samples)\n- More sophisticated feature engineering\n- More robustness to missing or noisy data\n\nUse the advanced models for prediction:\n\n```bash\npython cwt.py predict --input data/sample_input.json --model models/advanced/gb/Advanced_gb_model.joblib --scaler models/advanced/gb/Advanced_gb_scaler.joblib\n```\n\n### Listing Available Models\n\n```bash\npython cwt.py list-models\n```\n\n## Project Structure\n\nThe CWT project follows an organized directory structure:\n\n```bash\nCWT-Learning_Model/\n├── data/                        # Data files for training and prediction\n├── examples/                    # Example files and utilities\n│   └── json_samples/            # Example JSON files for testing\n├── logs/                        # Log files\n│   ├── general/                 # General logs\n│   ├── training/                # Training-specific logs\n│   ├── prediction/              # Prediction-specific logs\n│   └── installation/            # Installation logs\n├── models/                      # Trained models\n│   ├── sample/                  # Models trained on synthetic data\n│   │   ├── default/             # Default models\n│   │   ├── rf/                  # Random Forest models\n│   │   ├── svm/                 # Support Vector Machine models\n│   │   ├── gb/                  # Gradient Boosting models\n│   │   ├── mlp/                 # Neural Network models\n│   │   ├── knn/                 # K-Nearest Neighbors models\n│   │   └── lr/                  # Logistic Regression models\n│   ├── advanced/                # Advanced pre-trained models\n│   │   ├── rf/                  # Advanced Random Forest models\n│   │   ├── svm/                 # Advanced SVM models\n│   │   ├── gb/                  # Advanced Gradient Boosting models\n│   │   ├── mlp/                 # Advanced Neural Network models\n│   │   ├── knn/                 # Advanced KNN models\n│   │   └── lr/                  # Advanced Logistic Regression models\n│   └── visualizations/          # Model performance visualizations\n├── utilities/                   # Helper scripts and utilities\n│   ├── check_models.py          # Script to check model and scaler compatibility\n│   ├── download_advanced_models.py # Script to download advanced models\n│   ├── generate_sample_data.py  # Script to generate sample data\n│   ├── organize_outputs.py      # Script to organize models and logs\n│   └── test_imports.py          # Script to test Python imports\n├── cwt.py                       # Main script\n├── commands.py                  # Command dictionary and help system\n├── start.py                     # Automated setup and training script\n├── requirements.txt             # Python dependencies\n├── .env                         # Environment configuration\n└── README.md                    # This file\n```\n\n## Utility Shortcuts\n\nThe CWT comes with several utility scripts that can be executed directly from the root directory:\n\n| Shortcut | Description | Usage |\n|----------|-------------|-------|\n| `./check-models` | Check model and scaler compatibility | `./check-models` or `./check-models --fix` |\n| `./generate-data` | Generate sample data files | `./generate-data` |\n| `./organize` | Organize models and logs | `./organize` |\n| `./download-models` | Download advanced models | `./download-models --all` or `./download-models --model-type gb` |\n| `./!help` | Display help information | `./!help` or `./!help --topic model-types` |\n| `./commands.py` | Interactive command reference | `./commands.py` or `./commands.py [command]` |\n| `./start.py` | Automated environment setup and training | `./start.py` |\n\nTo set up these shortcuts (or recreate them if needed), run:\n\n```bash\npython utilities/setup_links.py\n```\n\n## Data Format\n\nThe tool expects data in the following format:\n\n1. Physiological data with heart rate, blood pressure, etc.\n2. EEG data with brain wave measurements\n3. Gaze tracking data with eye movement metrics\n\nEach data file should include a timestamp column for synchronization.\n\nSample data can be generated using:\n\n```bash\n./generate-data\n```\n\n## Configuration\n\nYou can customize the tool by modifying the `.env` file:\n\n```\n# Data files\nPHYSIO_DATA_PATH=data/Enhanced_Workload_Clinical_Data.csv\nEEG_DATA_PATH=data/000_EEG_Cluster_ANOVA_Results.csv\nGAZE_DATA_PATH=data/008_01.csv\n\n# Model configuration\nMODEL_OUTPUT_DIR=models/sample/default\nMODEL_NAME=Cognitive_State_Prediction_Model\n\n# Logging configuration\nLOG_LEVEL=INFO\nLOG_FILE=logs/general/cwt.log\n\n# Training parameters\nTEST_SIZE=0.2\nRANDOM_SEED=42\n\n# Default model type\nDEFAULT_MODEL_TYPE=rf\n```\n\n## Organizing Your Models and Logs\n\nIf you have existing models and logs that need to be reorganized to match the new directory structure, run:\n\n```bash\npython utilities/organize_outputs.py\n```\n\nThis script will:\n\n1. Organize model files by type (rf, svm, gb, mlp, knn, lr)\n2. Separate advanced models from sample models\n3. Organize logs by operation type\n\n## Troubleshooting\n\nIf you encounter issues with data paths:\n\n1. Ensure your data files are in the locations specified in `.env`\n2. Or run `python cwt.py install-models` to use sample data and models\n\n### Scaler File Issues\n\nIf you encounter errors related to scaler files not being found:\n\n1. Use explicit model and scaler paths when making predictions:\n\n   ```bash\n   python cwt.py predict --input data/sample_input.json --model models/sample/rf/your_model.joblib --scaler models/sample/rf/your_scaler.joblib\n   ```\n\n2. Verify the scaler file exists in the same directory as the model:\n\n   ```bash\n   # List models and their scalers\n   find models -name \"cognitive_state_predictor_*.joblib\" | sort\n   find models -name \"scaler_*.joblib\" | sort\n   ```\n\n3. Reinstall sample models to ensure consistent naming:\n\n   ```bash\n   python cwt.py install-models\n   ```\n\n4. Run the organize script to organize your models and scalers:\n\n   ```bash\n   ./organize\n   ```\n\n5. Use the check-models utility:\n\n   ```bash\n   # Check all models and their scalers\n   ./check-models\n   \n   # Automatically fix scaler issues\n   ./check-models --fix\n   ```\n\n   This tool will identify models missing scalers and create them automatically when run with the `--fix` flag.\n\n## License\n\nThis project is licensed under the MIT License - see the LICENSE file for details.\n\n## Citation\n\nIf you use this tool in your research, please cite it as:\n\n```\n@software{CognitiveWorkloadTool,\n  author = {Your Name},\n  title = {Cognitive Workload Assessment Tool},\n  year = {2025},\n  url = {https://github.com/yourusername/CWT-Learning_Model}\n}\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fexios66%2Fcwt-learning_model","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fexios66%2Fcwt-learning_model","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fexios66%2Fcwt-learning_model/lists"}