Additional Exercises for Dictionary Method

Ex.

  1. Read in the childrens_lit.csv.bz2 file from the data folder.
  2. Come up with a hypothesis on what you think the sentiment ratings is for children's literature.
  3. Do a sentiment analysis on a subset of chilren's literature using the dictionary method from lecture.
    • Use the positive and negative words from lecture

Question 1


In [3]:
import pandas as pd
import nltk
import matplotlib.pyplot as plt


#read in our data
df = ...

Since the number of children literaturs is a lot to analyze, we'll just randomly select 5 books to do a sentiment analysis using the dictionary method.

Note: In case you're not familiar with seed. Seed is just a function that initializes a fixed state for random number generatoring. Basically if everyone uses the same number as an input to seed(), then everyone will get the same result when generating randomly.


In [ ]:
import numpy as np
np.random.seed(1)
df = df.sample(5)
df

Question 2

[your hypothesis here]

Question 3


In [6]:
# Your code here