Coder Social home page Coder Social logo

feddit-sentiment-analysis's Introduction

Feddit Sentiment Analysis

A web API predicting if comments on a given subfeddit or category are positive or negative. The project is implemented with FastAPI and Docker.

How-to-run

The webapp sentiment analysis model relies on external API for the classification. By default, a simple mocked model is enabled, if you don't care about the model just run:

docker-compose up -d --build

If you want to use the external API you have 2 options:

The OpenAI approach is an alternative if you don't work with AWS. Please keep in mind the following limitation for the OpenAI approach:

  • I didn't implement input sanitization
  • I didn't optimize the prompt
  • is much more expensive
  • is 2 times slower

Depending on your preferences and possibility (e.g. you may not have AWS account available), you can choose one model or the other via ENV configuration.

  • OpenAI approach:
SENTIMENT_MODEL=openai OPENAI_API_KEY=<your-openai-key> docker-compose up --build
  • AWS Comprehend approach:
PREDICTIONS_MODEL=aws_comprehend \
AWS_ACCESS_KEY_ID=<your-aws-access-key-id> \
AWS_SECRET_ACCESS_KEY=<your-aws-secret-access-key> \
docker-compose up --build

API

Check http://0.0.0.0:8000/docs for OpenAPI documentation.

Monitoring

To monitor the application I provided 2 tools:

  • JSON logger, printing to stdout and eventually collected by a log collector
  • Prometheus' metrics, exposed at http://localhost:8000/metrics and accessible at http://localhost:9090

Prometheus is more a proof of concept, I didn't implement any alerting or dashboard. In general if available there are better tools than Prometheus covering better distributed tracing aspect like NewRelic, Sentry, DataDog, Elastic APM, etc.

Tests

For the sake of simplicity and time saving I created only 2 tests:

  • Sample smoke test running against a live service
  • Simple unit test for the AWS model

feddit-sentiment-analysis's People

Contributors

mattfanto avatar

Watchers

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