Penerapan Metode Klasifikasi K-Nearest Neighbor dan Lexicon Based untuk Analisis Sentimen Publik Terhadap Pemindahan Ibu Kota Negara dengan Ekstraksi Fitur TF-IDF
Analyze opinions expressed on X (formerly Twitter) regarding the relocation of Indonesia's capital city using combination of classifiers algorithm K-Nearest Neighbor (KNN), Feature Extraction TF-IDF, SMOTE for balancer, and also Lexicon-based approach for labeling data as positive, negative, or neutral sentiment.
dataset- Data regarding the relocation of Indonesia's capital city from X (formerly Twitter).
- Data crawling was done at 26 October 2024 with keywords: ibu kota baru, ibu kota nusantara, ibu kota pindah, ikn, pemindahan ibu kota, ibukota baru, ibukota nusantara, ibukota pindah, pemindahan ibukota.
- Some X Search Queries like: lang:id, since:2024-01-01, until:2024-10-01.
- Also the crawler use
LATESTorTOPtab from X.
slang, stopwords, negation, etcCustom LexiconEkstraksi FiturTF-IDF
BalancerSMOTE
Classifier AlgorithmK-Nearest Neighbor (KNN)
EvaluationConfusion MatrixClassification Report
Look at
requirements.txtfor more details.
gitpythonpipvirtualenv
- Export x cookies from browser with some cookies extractor extension on browser.
- Save it to
scraper/raw_cookies.json.- Generate
twikitcookies withscraper/cookies.py.- Save it to
scraper/twikit_cookies.json.- Run
scraper/scraper.py.
- Initialize
virtualenv
virtualenv <virtualenv_name>-
Activate
virtualenvWindows<virtualenv_name>/Scripts/activate
Linux/macOSsource <virtualenv_name>/Scripts/activate
-
Install dependencies on
virtualenv
pip install -r requirements.txt- Check installed dependencies on
virtualenv
pip freeze- Install a new kernel for
Jupyter Notebooknamed<virtualenv_name>onvirtualenv
python -m ipykernel install --user --name <virtualenv_name>- Update
pip
pip install wheel setuptools pip --upgrade- Start
Jupyter Notebookserver onvirtualenv
jupyter notebook- Deactivate
virtualenv
deactivatestreamlit run streamlit.py