Code Monkey home page Code Monkey logo

sentiment_analysis's Introduction

Sentiment_Analysis

Overview

This is the code for this video on Sentiment Analysis for the Data Lit Course by Siraj Raval on Youtube and School of AI.

Instructions

This code is a jupyter notebook. Download it by clicking the green download button here on Github, then go to Google Colab and upload it. There, you can run the code in the browser without having to install any dependencies locally. You only need to fill out your specific twitter auth variables. To create them, go to twitter apps.

sentiment_analysis's People

Contributors

ayushs136 avatar llsourcell 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  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  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  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

sentiment_analysis's Issues

Twitter API Keys

Please tell in the notebook how to get the authentication keys.

Error in cell 5

Great tutorial @llSourcell !
The code needs only a simple fix:

Cell 5

import nltk
nltk.download('lexicon')

should be replaced with

import nltk
nltk.download('vader_lexicon')

Having error in running 4th cell

I am pasting the error message below:


TweepError Traceback (most recent call last)
in ()
4 api = tweepy.API(auth)
5
----> 6 tweets = api.search('Artificial Intelligence', count=200)
7
8

/usr/local/lib/python3.6/dist-packages/tweepy/binder.py in _call(*args, **kwargs)
248 return method
249 else:
--> 250 return method.execute()
251
252 # Set pagination mode

/usr/local/lib/python3.6/dist-packages/tweepy/binder.py in execute(self)
232 raise RateLimitError(error_msg, resp)
233 else:
--> 234 raise TweepError(error_msg, resp, api_code=api_error_code)
235
236 # Parse the response payload

TweepError: [{'code': 215, 'message': 'Bad Authentication data.'}]

A more formal introduction to Sentiment Analysis

Hi @llSourcell. Firstly, kudos to you for your DataLit initiative.

Sentiment Analysis has always been one of my favorite topics. Not only because it's fun but also for its offering for real-world business use-cases. I wrote this tutorial last year to introduce the problem of Sentiment Analysis in a bit more formal way but tried to keep the language as simple as possible so that beginners can easily pick it up. It would be great if you could add it to the list of resources pertaining to Sentiment Analysis. on the respective video of this tutorial. Here's the list of contents I covered in the article:

image

'TypeError' on running the last cell in Colab

I'm getting an error when I'm running the 6th block at CoLab. The code however is running fine on my local computer. Please advise. Thank you.

Pasting the error.

TypeError Traceback (most recent call last)
/usr/local/lib/python3.6/dist-packages/pandas/core/indexes/base.py in get_value(self, series, key)
2565 try:
-> 2566 return libts.get_value_box(s, key)
2567 except IndexError:

pandas/_libs/tslib.pyx in pandas._libs.tslib.get_value_box()

pandas/_libs/tslib.pyx in pandas._libs.tslib.get_value_box()

TypeError: 'str' object cannot be interpreted as an integer

During handling of the above exception, another exception occurred:

KeyError Traceback (most recent call last)
in ()
5
6 for index, row in data.iterrows():
----> 7 ss = sid.polarity_scores(row["Tweets"])
8 listy.append(ss)
9

/usr/local/lib/python3.6/dist-packages/pandas/core/series.py in getitem(self, key)
621 key = com._apply_if_callable(key, self)
622 try:
--> 623 result = self.index.get_value(self, key)
624
625 if not is_scalar(result):

/usr/local/lib/python3.6/dist-packages/pandas/core/indexes/base.py in get_value(self, series, key)
2572 raise InvalidIndexError(key)
2573 else:
-> 2574 raise e1
2575 except Exception: # pragma: no cover
2576 raise e1

/usr/local/lib/python3.6/dist-packages/pandas/core/indexes/base.py in get_value(self, series, key)
2558 try:
2559 return self._engine.get_value(s, k,
-> 2560 tz=getattr(series.dtype, 'tz', None))
2561 except KeyError as e1:
2562 if len(self) > 0 and self.inferred_type in ['integer', 'boolean']:

pandas/_libs/index.pyx in pandas._libs.index.IndexEngine.get_value()

pandas/_libs/index.pyx in pandas._libs.index.IndexEngine.get_value()

pandas/_libs/index.pyx in pandas._libs.index.IndexEngine.get_loc()

pandas/_libs/hashtable_class_helper.pxi in pandas._libs.hashtable.PyObjectHashTable.get_item()

pandas/_libs/hashtable_class_helper.pxi in pandas._libs.hashtable.PyObjectHashTable.get_item()

KeyError: 'Tweets'

Extended Text - New Twitter Update

Siraj - Love this video! I have never commited, pulled or done any changes to another person's repository so I thought I would leave it here.

When you perform a search using api.search in tweepy, if you run it the way you have specified it will recover the old character limit (140 characters, ends with "..."). I read through the Twitter Dev API documentation and its a pretty easy fix to get the full 280 characters.

Please note, that the behavior of RT/"Retweets" still only returns 140 characters, but still is searching correctly.

Keep up the videos!

Zac

auth = tweepy.OAuthHandler(consumer_key, consumer_secret)
auth.set_access_token(access_token, access_token_secret)

api = tweepy.API(auth)

tweets = api.search('Artificial Intelligence', count=200, tweet_mode = 'extended')

data = pd.DataFrame(data=[tweet.text full_text for tweet in tweets], columns=['Tweets'])
display(data.head(10))
print(tweets[0].created_at)

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.