Giter Site home page Giter Site logo

pypinion's Introduction

PyPinion

PyPinion is a classification model designed to identify opinions in news articles.

Overview

This initial version is based on self-labeled sentences from 7,000 random CNN articles using a library called Simple Transformers to classify if a sentence is an opinion or not. Simple Transformers is based on the Transformers library by HuggingFace.

The current model leverages a pre-trained RoBERTa architecture from Facebook and performs reasonably against standard news sentences. The model is currently more of a proof-of-concept and there are plans for a more robust and scientific approach to its development.

Model evaluation metrics

  • Accuracy: 91.08%
  • F1 Score: 91.79%
  • ROC AUC: 90.93%
  • Precision: 90.69%
  • Recall: 92.91%

Important Notes

  • Slow to score large amounts of sentences
  • Not intended to be a fact identifier
  • Not tested on colloquial or informal text like twitter

Usage

from simpletransformers.classification import ClassificationModel


sent = 'The president should always speak to the people that got him into office' # Example sentence

trained_model = ClassificationModel("roberta", PATH) # PATH is the location of the extracted trained model
predictions, raw_outputs = trained_model.predict([sent])

print(predictions[0]) # '1' indicates opinion,'0' indicates non-opinion

Examples

Sentence Prediction Result
The show was successful because even though it was about death, it lacked violence. Opinion
The apparent car bomb attack happened outside of St. Finbar's Catholic Church, according to Plateau Gov. Jonah David Jang. Non-Opinion
Perhaps it's good for his job as a comedian, but, personally, there's no sense of schadenfreude. Opinion
Similarly, when fewer people are waiting to cross the road, the traffic is given a longer set of green lights. Non-Opinion
They choose to stop paying, one way or another. Opinion
South Sudan, which became independent in 2011, is facing many challenges. Opinion
FC Shakhtar regretfully informs that on 8 February 2014 the life of a footballer Maicon Pereira de Oliveira tragically ended. Non-Opinion
The list includes the startups I consider to have the most potential, to be the most viable -- not necessarily the most popular or hyped. Opinion
Europe has more than its fair share of sausages that time forgot. Opinion
The Spanish club, also hit with a $455,000 fine, says the transfer ban is "disproportionate" and "excessive." Non-Opinion

pypinion's People

Contributors

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