A machine learning project that analyzes sentiment in Indonesian text using XGBoost and transformer-based models. The project provides tools to classify text as positive, negative, or neutral.
This project implements a sentiment analysis system that:
- Scrapes reviews from Google Play Store (specifically from the MyPertamina app)
- Processes and labels Indonesian text data
- Trains an XGBoost model using TF-IDF feature extraction
- Implements an easy-to-use inference interface
- Text sentiment classification (positive, negative, neutral)
- Pre-processed data using TF-IDF vectorization
- Optimized XGBoost classifier with Bayesian hyperparameter tuning
- Simple API for sentiment prediction
- Clone the repository:
git clone https://github.com/yourusername/indonesian-sentiment-analysis.git
cd indonesian-sentiment-analysis- Install the required dependencies:
pip install -r requirements.txt- Make sure you have the model files in the
model/directory:xgb_sentiment_analysis_pipeline.jobliblabel_encoder.joblib
from sentiment_analyzer.XGBoostSentimentAnalyzer import XGBoostSentimentAnalyzer
# Initialize the sentiment analyzer
sentiment_analyzer = XGBoostSentimentAnalyzer()
# Predict sentiment for a text
text = "aplikasi ini sangat bagus"
prediction = sentiment_analyzer(text)
print(f"Sentiment: {prediction}")The project includes a Jupyter notebook for easy inference:
- Open
notebook_inference.ipynb - Change the
TEXTvariable to your input text - Run the notebook cells to get a sentiment prediction
The model was trained on reviews scraped from the MyPertamina app on Google Play Store:
- 30,000 reviews in Indonesian language
- Distribution: ~74% negative, ~24% positive, ~2% neutral
- Initial labeling performed using a pre-trained multilingual sentiment model
- TF-IDF Vectorizer
- n-gram range: (1, 2)
- No IDF weighting
- XGBoost with optimized hyperparameters:
- Learning rate: 0.087
- Max depth: 8
- Number of estimators: 600
- Subsample: 0.763
- Colsample bytree: 0.594
- Gamma: 2.46e-09
The model was evaluated using an 80/20 train/test split with stratification.
├── model/ # Saved model files
├── notebook_inference.ipynb # Inference notebook
├── notebook_training_model.ipynb # Training notebook
├── sentiment_analyzer/ # Python package
│ └── XGBoostSentimentAnalyzer.py # Sentiment analyzer class
├── requirements.txt # Project dependencies
└── README.md # Project documentation
[Include your license information here]
[Include contribution guidelines here]
- Initial sentiment labeling performed using
lxyuan/distilbert-base-multilingual-cased-sentiments-student - This project was built with scikit-learn, XGBoost, and other open-source libraries