{"id":15914510,"url":"https://github.com/bbengfort/sentiment-reviews","last_synced_at":"2025-04-03T03:44:54.355Z","repository":{"id":192689177,"uuid":"687159220","full_name":"bbengfort/sentiment-reviews","owner":"bbengfort","description":"Code for the MLOps 201: Real Time Inferencing Webinar","archived":false,"fork":false,"pushed_at":"2023-09-11T17:37:28.000Z","size":42861,"stargazers_count":0,"open_issues_count":0,"forks_count":1,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-02-08T17:45:49.198Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-3-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/bbengfort.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2023-09-04T18:53:32.000Z","updated_at":"2023-09-04T21:52:34.000Z","dependencies_parsed_at":null,"dependency_job_id":"477e81db-644d-4356-8799-2b052c6b6d85","html_url":"https://github.com/bbengfort/sentiment-reviews","commit_stats":null,"previous_names":["bbengfort/sentiment-reviews"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bbengfort%2Fsentiment-reviews","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bbengfort%2Fsentiment-reviews/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bbengfort%2Fsentiment-reviews/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bbengfort%2Fsentiment-reviews/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/bbengfort","download_url":"https://codeload.github.com/bbengfort/sentiment-reviews/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246933357,"owners_count":20857052,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-10-06T17:03:47.064Z","updated_at":"2025-04-03T03:44:51.139Z","avatar_url":"https://github.com/bbengfort.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Sentiment Reviews\n\n**Code for the MLOps 201: Real Time Inferencing Webinar**\n\n## Prerequisites\n\nBefore you start, you'll need to crete an account or login to [rotational.app](https://rotational.app). Create a project called \"MLOps Tutorials\", then create two topics in the project:\n\n- `instances`: publish instances that need to have the model applied to them\n- `inferences`: publish the class and confidence of the models' prediction on each instance\n\nThen create a set of API keys with Full permissions; make sure to download the keys file; the API key secret is only available during this step!\n\nCopy `.env.template` to `.env` in your local repository, then fill in the missing environment variables with the client keys you downloaded; now you're ready to start docker compose to run the various processes in the project.\n\n## Quickstart\n\nTo run the code locally on your computer, first make sure that [Docker and Docker Compose are installed](https://docs.docker.com/compose/install/). Then run the following commands from the root of the repository that you've cloned to your computer:\n\n```\n$ docker compose --profile all build\n$ docker compose --profile all up\n```\n\nYou should now be able to navigate to http://localhost:8000/ and see the app running.\n\n## Sentiment Model\n\nThe model was trained on the [Kaggle Twitter US Airline Sentiment](https://www.kaggle.com/datasets/crowdflower/twitter-airline-sentiment?resource=download) dataset. The confusion matrix for the model is below:\n\n```\n                precision    recall  f1-score   support\n\n         NEG       0.81      0.93      0.86      1818\n         NEU       0.64      0.47      0.54       620\n         POS       0.77      0.60      0.68       459\n\n    accuracy                           0.78      2897\n   macro avg       0.74      0.67      0.70      2897\nweighted avg       0.77      0.78      0.77      2897\n```\n\nThe model uses an NLTK preprocessor that removes english stopwords and punctuation, lower casess and lemmatizes all words using the WordNet lemmatizer. A scikit-learn TFIDF vectorizer is used to vectorize the unigrams for the model. Finally a Logistic Regression (maximum entropy) model is used for classification.\n\nThe model can be found in [fixtures/model.pickle](fixtures/model.pickle) and you can use it to make predictions as follows:\n\n```\n$ ./models.py predict \"I hate waiting in line, this is absolutely horrid\"\n['NEG']\n[[ 3.2809592  -3.56670859 -2.75509941]]\n```\n\nThe first row is the classification and the second row is the confidence the model has in the 'NEG', 'NEU', and 'POS' classes respectively.","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbbengfort%2Fsentiment-reviews","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbbengfort%2Fsentiment-reviews","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbbengfort%2Fsentiment-reviews/lists"}