A neural network-based classifier for IMDB movie reviews sentiment analysis using Keras.
ANNImdbClassifier is a Python implementation of a sentiment analysis model that classifies IMDB movie reviews as either positive or negative. The project uses a simple Artificial Neural Network (ANN) built with Keras to achieve this classification task.
- Loads and preprocesses the IMDB dataset from Keras
- Transforms text reviews into numerical vectors using one-hot encoding
- Implements a sequential neural network with multiple dense layers
- Visualizes training and validation metrics (loss and accuracy)
- Provides a clean, object-oriented implementation
- Python 3.x
- Keras
- TensorFlow (backend for Keras)
- NumPy
- Matplotlib
-
Clone the repository:
git clone https://github.com/corticalstack/ANNImdbClassifier.git cd ANNImdbClassifier
-
Install the required dependencies:
pip install tensorflow keras numpy matplotlib
Simply run the main script:
python main.py
This will:
- Load the IMDB dataset
- Preprocess the data
- Build and train the neural network model
- Display training and validation metrics graphs
The classifier is implemented as a single class ImdbClassifier
with the following methods:
__init__()
: Initializes the classifier, loads and preprocesses databuild_model()
: Creates and trains the neural network modelload_data()
: Loads the IMDB dataset from Kerasdecode_review()
: Converts encoded reviews back to human-readable textvectorize_sequences()
: Transforms integer sequences into binary matrices
The neural network architecture consists of:
- Input layer: Dense layer with 16 neurons and ReLU activation
- Hidden layer: Dense layer with 16 neurons and ReLU activation
- Output layer: Single neuron with sigmoid activation for binary classification
The model visualizes both training and validation metrics:
- Loss over epochs
- Accuracy over epochs
These visualizations help in understanding the model's learning process and identifying potential overfitting.
This project is licensed under the MIT License - see the LICENSE file for details.