feat: Enhance NER pipeline with robust imports and interpretability - #14
Merged
Conversation
This commit addresses the 'No module named utils' import error and significantly
improves the pipeline's stability, error handling, and introduces model
interpretability features.
Key changes include:
- **NER Models (src/models/ner_trainer.py, src/models/model_evaluator.py):**
- Corrected module import paths (e.g., from `conll_parser` to `src.utils.conll_parser`)
to resolve `ImportError: No module named 'utils'`.
- Improved `sys.path` handling within modules for consistent discovery.
- Integrated SHAP and LIME interpretability analysis into `model_evaluator.py`
to provide insights into model predictions and behavior.
- Enhanced data handling in `ner_trainer.py` for robustness with empty
datasets and edge cases in metric computation.
- Added dummy data generation in `__main__` blocks for easier local testing
of individual model components.
- **Pipeline Orchestration (scripts/run_pipeline.py):**
- Streamlined `sys.path` setup to ensure the `src` directory is consistently
recognized as a top-level package.
- Integrated `asyncio.run` for proper execution of the asynchronous
Telegram scraper.
- Improved error handling with detailed tracebacks for better debugging.
- Added logic to automatically create a dummy `config/channels_to_crawl.txt`
if it's missing, simplifying initial setup.
- Ensured `DataFrame` column types and `NaN` values are handled robustly
across stages (e.g., `message_text`, `tokens`, `message_id`, `views`).
- **Data Ingestion (src/data_ingestion/telegram_scraper.py):**
- Updated the scraper to accept a `message_limit` parameter, replacing a hardcoded value.
- Modified to read channel configurations from `config/channels_to_crawl.txt`.
- **Configuration & Data Management:**
- Replaced the `.csv` extension for `channels_to_crawl` with a `.txt` file,
reflecting a simpler, line-delimited list of channels.
- Updated `.gitignore` to reflect new directory structures and ignored files,
including `data/predicted` and `data/analytics`.
These updates make the pipeline more reliable, easier to use and debug, and provide
valuable insights into the NER model's decision-making process for better
micro-lending assessments.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This commit addresses the 'No module named utils' import error and significantly improves the pipeline's stability, error handling, and introduces model interpretability features.
Key changes include:
NER Models (src/models/ner_trainer.py, src/models/model_evaluator.py):
conll_parsertosrc.utils.conll_parser) to resolveImportError: No module named 'utils'.sys.pathhandling within modules for consistent discovery.model_evaluator.pyto provide insights into model predictions and behavior.ner_trainer.pyfor robustness with empty datasets and edge cases in metric computation.__main__blocks for easier local testing of individual model components.Pipeline Orchestration (scripts/run_pipeline.py):
sys.pathsetup to ensure thesrcdirectory is consistently recognized as a top-level package.asyncio.runfor proper execution of the asynchronous Telegram scraper.config/channels_to_crawl.txtif it's missing, simplifying initial setup.DataFramecolumn types andNaNvalues are handled robustly across stages (e.g.,message_text,tokens,message_id,views).Data Ingestion (src/data_ingestion/telegram_scraper.py):
message_limitparameter, replacing a hardcoded value.config/channels_to_crawl.txt.Configuration & Data Management:
.csvextension forchannels_to_crawlwith a.txtfile, reflecting a simpler, line-delimited list of channels..gitignoreto reflect new directory structures and ignored files, includingdata/predictedanddata/analytics.These updates make the pipeline more reliable, easier to use and debug, and provide valuable insights into the NER model's decision-making process for better micro-lending assessments.