Giter Site home page Giter Site logo

al0new0lf / twitter-sentiment-analysis Goto Github PK

View Code? Open in Web Editor NEW
1.0 1.0 2.0 4.74 MB

Academic - Distributed system for twitter sentiment analysis

License: MIT License

JavaScript 1.18% CSS 1.66% HTML 0.27% Svelte 38.09% TypeScript 10.19% Jupyter Notebook 36.15% Python 11.49% Dockerfile 0.98%

twitter-sentiment-analysis's Introduction

Twitter-sentiment-analysis

This project is an app backboned by a distributed system that performs sentiment analysis on tweets. The app is built using svelte and flask, and the distributed system is built using Apache Kafka and Apache Spark.

Architecture

Architecture

The system is composed of 3 layers:

App (User Interface)

The user interface is a web application developed with Svelte that allows users to interact with the system. They can view jobs history and details, as well as initiate new jobs to either predict the sentiment of a single tweet or multiple tweets in a file.

API (Backend)

The API is a RESTful service developed with Flask that serves as the intermediary between the user interface, the system and the database. It is responsible for handling user requests, processing them and returning the results.

System (Kafka and Spark)

The system is composed of two main components: the Kafka pipeline and the Spark job. The Kafka pipeline ingests Twitter posts and sends them to the Spark job for processing. The Spark job preprocess, analyzes the data and provides instant sentiment prediction.

After prediction, the results are stored in a mongodb database for future reference, Then is sent back an ID to the user interface for a confirmation. The user can then query the database for the results of the job.

Docker

The system and API are containerized with Docker to ensure portability and ease of deployment. The containers are orchestrated with Docker Compose to manage the system components and their dependencies.

Model

The sentiment analysis model is a pre-trained Cross-Validation & Logistic Regression model that is trained on a dataset of more than 63k tweets. The model is used to predict the sentiment of a tweet as either positive, negative, neutral or irrelevant. The model performs with an accuracy of 93%.

Getting Started

First, clone the repository:

git clone https://github.com/aL0NEW0LF/twitter-sentiment-analysis

Frontend

To run the frontend, navigate to the app directory and run the following commands:

cd app
pnpm install

To start the frontend, run the following command:

pnpm run dev --open

Backend

To run the backend, you should compose the docker containers with:

docker-compose -f docker-compose.yml up -d

then go to the TheKafkaShore container command line to create the kafka topics with:

kafka-topics --create --topic twitter --bootstrap-server TheKafkaShore:9092
kafka-topics --create --topic job_id --bootstrap-server TheKafkaShore:9092

Then you are good to go.

TODO

  • Change saving jéSon schema to mongodb for data storage optimization.
  • Add streaming tweet and one by one treatment.
  • Add .env variables to remove hard coded variables.

twitter-sentiment-analysis's People

Contributors

al0new0lf avatar samashi47 avatar dhafahd avatar

Stargazers

 avatar

Watchers

 avatar

Forkers

samashi47 dhafahd

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.