GithubHelp home page GithubHelp logo

daspartho / predict-subreddit Goto Github PK

View Code? Open in Web Editor NEW
31.0 2.0 5.0 836 KB

NLP model that predicts subreddit based on the title of a post

Home Page: https://huggingface.co/spaces/daspartho/predict-subreddit

License: Apache License 2.0

Jupyter Notebook 63.83% Python 36.17%
deep-learning distilbert huggingface-transformers nlp praw reddit sequence-classification text-classification huggingface huggingface-spaces

predict-subreddit's Introduction

Predict Subreddit

Generic badge

An NLP model that predicts subreddit based on the title of a post.

Play with it on HuggingFace Space

Post on r/MachineLearning

Data Collection

The model was trained using the titles of the top 1000 posts from the top 250 subreddits scraped using PRAW.

Dataset hosted on HuggingFace

Steps to create the dataset using dataset.py script:

  • Make sure to install the requirements using pip install -r requirements.txt
  • Create a .env file consisting of reddit authentication info like this
ID = <YOUR_ID>
SECRET = <YOUR_SECRET>
AGENT = <YOUR_AGENT>
  • Now run the script to create the dataset like this
python3 dataset.py <npage> <dfilename>

npage is the no of pages to scrape for top subreddits from redditlist.com (1 page => 125 subs) and filename is the csv filename to save the dataset to.

  • After the above steps are run, a csv file will be created under give filename consisting of title and subreddit pairs.

Modelling

HuggingFace Transformers' DistilBERT, is fine-tuned on the dataset of post titles labelled with their respective subreddit.

For steps to make the model check out the model notebook in the repo or open in Colab.

Model hosted on HuggingFace

Examples

Limitations and bias

  • Since the model is trained on top 250 subreddits (for reference) therefore it can only categorise within those subreddits.
  • Some subreddits have a specific format for their post title, like r/todayilearned where post title starts with "TIL" so the model becomes biased towards "TIL" --> r/todayilearned. This can be removed by cleaning the dataset of these specific terms.
  • In some subreddit like r/gifs, the title of the post doesn't matter much, so the model performs poorly on them.

Contributing

If you want to contribute code, simply create a pull request. If you have an idea, create an issue and the developers will look into it!

predict-subreddit's People

Contributors

amrrs avatar daspartho avatar

Stargazers

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