This README describes the experiment codes for 2021S2 COMP90049 Assignment3 and the input data used and output data in this assignment.
The following file tree shows the codes of this assignment (./code), input data used in experiments (./data), output data from experiments (./result_data), and the model generated by experiments (./model).
NOTE: the relative path of all these files should not be changed, otherwise some issues will occur during implementation.
├── code
│ ├── build_baseline.py
│ ├── predict_sentiment.py
│ └── sentiment_classifier.py
│ ├── my_function
│ │ ├── analyze_gender.py
│ │ ├── compute_tfidf.py
│ │ ├── feature_selection.py
│ │ └── transform_data.py
├── data
│ ├── dev_count.csv
│ ├── dev_tfidf.csv
│ ├── test_count.csv
│ ├── test_tfidf.csv
│ ├── train_count.csv
│ ├── train_tfidf.csv
│ └── vocab.txt
│ ├── gender_word_list.npz
├── model
│ ├── KNN_no_scalar_data_traditional_data_model.sav
│ ├── KNN_no_scalar_data_update_data_model.sav
│ ├── KNN_scalar_data_traditional_data_model.sav
│ ├── KNN_scalar_data_update_data_model.sav
│ ├── NB_no_scalar_data_traditional_data_model.sav
│ ├── NB_no_scalar_data_update_data_model.sav
│ ├── NB_scalar_data_traditional_data_model.sav
│ ├── NB_scalar_data_update_data_model.sav
│ ├── Softmax_no_scalar_data_traditional_data_model.sav
│ ├── Softmax_no_scalar_data_update_data_model.sav
│ ├── Softmax_scalar_data_traditional_data_model.sav
│ ├── Softmax_scalar_data_update_data_model.sav
├── result_data
│ ├── KNN_result.csv
│ ├── NB_result.csv
│ ├── Softmax_result.csv
│ ├── compute_info_tfidf_data.npz
- sklearn : 0.24.1
- pandas : 1.3.3
- numpy : 1.19.2
- scipy : 1.2.1
- nltk : 3.6.3
- pickle
- collections
- itertools
!! all of the python files should be implemented in this specified relative file path shown in File tree
- contain the main function to build baseline based on opinion lexicon
- mainly to build sentiment classifiers based on three types of machine learning algorithms (i.e., Naive Bayes, Softmax Regression, and KNN), and then train them on processed training dataset and unprocessed training dataset respectively.
- Also, the influences of gender bias on different classifiers are tested in sentiment_classifier.py
- Ultimately, the accuracy and F1-score of classifiers would be computed
- the test data would be processed by improved TFIDF feature selection approach mentioned in my report. Also, the test data would be predicted by the sentiment classifier based on Softmax Regression model.
contain The supplementary classes and functions defined by myself
- transform_data.py : define some functions to transform raw data (e.g., read .csv file given and convert tfidf type from string to float, transform a large np.matrix into a sparse matrix, etc.)
- compute_tfidf.py : define some functions to compute improved TFIDF method using information entropy.
- feature_selection.py : define the feature selector class, which contains traditional TFIDF feature selection method, improved TFIDF method and select K best features using chi-square.
- analyze_gender.py : define some functions help to analyze gender bias.