APS360 Project - Fake News Detection System
Veritas is a comprehensive fake news detection system that uses multiple machine learning approaches to classify news articles as real or fake. The project includes:
- Base Model: Traditional machine learning approach using TF-IDF and Logistic Regression
- RNN Model: Deep learning approach using Recurrent Neural Networks
- Dataset Processing: Automated pipeline to process multiple fake news datasets
The project provides convenient Poetry scripts for common tasks:
| Script | Command | Arguments | Description |
|---|---|---|---|
generate-data |
poetry run generate-data |
None | Process and combine multiple fake news datasets into a unified dataset |
train-rnn |
poetry run train-rnn |
--epochs <int> |
Train the RNN model for fake news detection |
train-base |
poetry run train-base |
None | Train the base model using TF-IDF and Logistic Regression |
visualize-rnn |
poetry run visualize-rnn |
--history-path <str> [--output-path <str>] |
Generate visualizations of RNN training results |
visualize-base |
poetry run visualize-base |
None | Generate visualizations of base model performance |
--epochs <int>(required): Number of epochs to train for
Example:
poetry run train-rnn --epochs 50--history-path <str>(required): Path to the training history JSON file--output-path <str>(optional): Path to save the output visualization. Defaults to "visualizations/training_history.png"
Example:
poetry run visualize-rnn --history-path history/training_history/model_128_0.001_0.0.json --output-path visualizations/my_training_results.pnggenerate-data: No arguments requiredtrain-base: No arguments requiredvisualize-base: No arguments required
These scripts are defined in pyproject.toml and provide a simple interface to the project's main functionality.
This guide will help you set up the development environment for the veritas project.
- Python 3.10 or higher
- Poetry (Python dependency management tool)
If you don't have Poetry installed, follow the official installation guide:
On macOS/Linux:
curl -sSL https://install.python-poetry.org | python3 -On Windows:
(Invoke-WebRequest -Uri https://install.python-poetry.org -UseBasicParsing).Content | py -Verify installation:
poetry --version-
Clone the repository (if you haven't already):
git clone <repository-url> cd veritas
-
Install dependencies using Poetry:
poetry install
-
Activate the Poetry virtual environment:
poetry shell
-
Verify the environment is active:
which python # Should point to Poetry's virtual environment pip list # Should show all project dependencies
This project uses Black for automatic code formatting to maintain consistent code style.
-
Install Black (if not already installed):
poetry add --group dev black
-
Verify installation:
poetry run black --version
The easiest way to use Black is with the VSCode extension:
-
Install the Black Formatter extension in VSCode:
- Open VSCode
- Go to Extensions (Ctrl+Shift+X or Cmd+Shift+X)
- Search for "Black Formatter"
- Install the extension by Microsoft
-
Configure VSCode to use Black:
- Open VSCode settings (Ctrl+, or Cmd+,)
- Search for "python formatting provider"
- Set it to "black"
- Enable "Format on Save" for automatic formatting
-
Format your code:
- Right-click in a Python file and select "Format Document"
- Or use the keyboard shortcut: Shift+Alt+F (Windows/Linux) or Shift+Option+F (Mac)
- Or enable "Format on Save" to automatically format when you save files
If you prefer using Black from the command line:
# Format all Python files in the project
poetry run black .
# Format a specific file
poetry run black src/base_model/main.py
# Check what would be formatted without making changes
poetry run black --check .When you're done working on the project:
exit # If using poetry shell
# or
deactivate # If the environment is still active- If you get permission errors: Make sure you have write permissions in the project directory
- If Poetry fails to install dependencies: Try updating Poetry first:
poetry self update - If you need to recreate the environment: Delete the
.venvfolder and runpoetry installagain - If Black formatting fails: Make sure you're in the Poetry environment and Black is installed
- If packages are missing: Run
poetry installto ensure all dependencies are installed
- Always use
poetry runor activate the Poetry environment before running scripts - Poetry automatically manages virtual environments and dependencies
- The
pyproject.tomlfile contains all project dependencies and configuration - Run
poetry run black .before committing to ensure consistent code formatting - Poetry creates a
.venvdirectory in your project folder for the virtual environment