Science Score: 57.0%
This score indicates how likely this project is to be science-related based on various indicators:
-
✓CITATION.cff file
Found CITATION.cff file -
✓codemeta.json file
Found codemeta.json file -
✓.zenodo.json file
Found .zenodo.json file -
✓DOI references
Found 2 DOI reference(s) in README -
○Academic publication links
-
○Academic email domains
-
○Institutional organization owner
-
○JOSS paper metadata
-
○Scientific vocabulary similarity
Low similarity (7.9%) to scientific vocabulary
Repository
SUTD Machine Learning Project
Basic Info
Statistics
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
- Releases: 0
Metadata Files
README.md
50.007 Machine Learning Project
| Team Member | Student ID | | :-----------: | :--------: | | Qiao Yingjie | 1004514 | | Zhang Peiyuan | 1004539 | | Huang He | 1004561 |
Introduction
In the repository, we present a pure python based implementation of the hidden markov model (HMM) and second-order hidden markov model for the task of simple sentiment analysis.
Please refer to our Report for implementation details and results.
Dependencies:
- Python 3.6+ Only (no external libraries required)
Demo
Run all trainings and evaluations for Part 1,2,3,4 at one go:
bash
./run_all
Part 1
Relevant code section:
- Function that computes the emission probability: hmm.py Line 36-67
- Introducing $k=1$ for calculating the emission probability for <UNK>: hmm.py Line 60-65
- Simple sentiment analysis based on emission probability: hmm.py Line 298-321
To run the code
bash
python3 hmm.py --train "ES/train" --test "ES/dev.in" --naive
python3 hmm.py --train "RU/train" --test "RU/dev.in" --naive
Part 2 & 3
Relevant code section:
- Function that computes the transition probability: hmm.py Line 69-108
- We use log-likelihood to compute the probability of emission and transition to avoid underflow: hmm.py Line 100
- We also introduce a smoothing factor which is a small constant that will be used to estimate close-to-zero probability to avoid undefined log-likelihood probabilities. hmm.py Line 100
- Top-k Viterbi algorithm: hmm.py Line 186-260
To run the code
bash
python3 hmm.py --train "ES/train" --test "ES/dev.in" --top-k "5"
python3 hmm.py --train "RU/train" --test "RU/dev.in" --top-k "5"
Part 4: RNN & 2nd Order HMM
We implement the second order HMM in secondorderhmm.py
To run the code
bash
python3 second_order_hmm.py --train "ES/train" --test "ES/dev.in"
python3 second_order_hmm.py --train "RU/train" --test "RU/dev.in"
Acknowledgement
We refer to the following resources when implementing this project:
- Sung-Hyun, Yang, et al. “Log-Viterbi Algorithm Applied on Second-Order Hidden Markov Model for Human Activity Recognition.” International Journal of Distributed Sensor Networks, Apr. 2018, doi:10.1177/1550147718772541.
- RNN: pangolulu / rnn-from-scratch
Owner
- Name: Yingjie Qiao
- Login: YingjieQiao
- Kind: user
- Location: Singapore
- Company: @ByteDance
- Website: https://yingjieqiao.github.io/
- Repositories: 29
- Profile: https://github.com/YingjieQiao
Do solid works, build exciting things, and make an impact.
Citation (CITATION.cff)
cff-version: 1.2.0
message: "If you use this repository, please cite it as below."
authors:
- family-names: "Huang"
given-names: "He"
orcid: "https://orcid.org/0000-0002-9217-4977"
affiliation: "Singapore University of Technology and Design"
- family-names: "Zhang"
given-names: "Peiyuan"
affiliation: "Singapore University of Technology and Design"
- family-names: "Qiao"
given-names: "Yingjie"
affiliation: "Singapore University of Technology and Design"
title: "Pure Python Hidden Markov Model Implementation for Sentiment Analysis"
version: 0.0.1
date-released: 2021-12-13
url: "https://github.com/YingjieQiao/SentimentAnalysis"
GitHub Events
Total
Last Year
Issues and Pull Requests
Last synced: 12 months ago
All Time
- Total issues: 0
- Total pull requests: 0
- Average time to close issues: N/A
- Average time to close pull requests: N/A
- Total issue authors: 0
- Total pull request authors: 0
- Average comments per issue: 0
- Average comments per pull request: 0
- Merged pull requests: 0
- Bot issues: 0
- Bot pull requests: 0
Past Year
- Issues: 0
- Pull requests: 0
- Average time to close issues: N/A
- Average time to close pull requests: N/A
- Issue authors: 0
- Pull request authors: 0
- Average comments per issue: 0
- Average comments per pull request: 0
- Merged pull requests: 0
- Bot issues: 0
- Bot pull requests: 0