GithubHelp home page GithubHelp logo

handanyu / twitter-sensitive-analysis Goto Github PK

View Code? Open in Web Editor NEW
0.0 1.0 0.0 32.96 MB

update the traditional TFIDF method, and then use several Machine Learning models to train classifiers.

Python 50.11% TeX 49.89%

twitter-sensitive-analysis's Introduction

Twitter-Sensitive-Analysis

README

This README describes the experiment codes for 2021S2 COMP90049 Assignment3 and the input data used and output data in this assignment.

File tree

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

Packages need to be installed

  • sklearn : 0.24.1
  • pandas : 1.3.3
  • numpy : 1.19.2
  • scipy : 1.2.1
  • nltk : 3.6.3
  • pickle
  • collections
  • itertools

Implementation of Python code

!! all of the python files should be implemented in this specified relative file path shown in File tree

build_baseline.py

  • contain the main function to build baseline based on opinion lexicon

sentiment_classifier.py

  • 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

predict_sentiment.py

  • 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.

Other .py in 'my_function' file

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.

twitter-sensitive-analysis's People

Contributors

handanyu avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.