#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Felix Muzny 11/8/2022 DS 2000 Lecture 18 - sentiment analysis, sets, moving averages, jupyter notebooks Logistics: - Homework 8 is out - this is your last HW for DS 2000 - there is a significant amount of extra credit available (so start early if this is something that you need) - due 11/18 - yes, you are doing sentiment analysis for this homework - checking your grades: - most accurate is calculate based on Gradescope grades - HW is 90% - Quizzes are 10% (drop your lowest quiz) - you can look in Canvas—know that this lags behind Gradescope - No quiz this week - No lecture on Friday (Veteran's day!) - I'll see you all next week! - remote attendance (https://bit.ly/remote-ds2000-muzny) Three ways to participate (please do one of these!) 1) via the PollEverywhere website: https://pollev.com/muzny 2) via text: text "muzny" to the number 22333 to join the session 3) via Poll Everywhere app (available for iOS or Android) """ """ HW 7 reflection --- Look at the sample speeds.pdf figure. (Or the one that you produced) How do we feel about it? A. looks good B. I have questions C. looks bad D. That line at 0 makes me queasy E. This graph is wrong? """ """ Sentiment ---- Are the following reviews: A. positive B. negative C. neutral """ """ Sets --- """ """ Moving Averages --- """ # from dataproc.py (Prof. Rachlin's version of # data_utils.py) def avg(L): """ Compute the numerical average of a list of numbers. If list is empty, return 0.0 """ if len(L) > 0: return sum(L) / len(L) else: return 0.0 def get_window(L, idx, window_size=1): """ Extract a window of values of specified size centered on the specified index L: List of values idx: Center index window_size: window size """ minrange = max(idx - window_size // 2, 0) maxrange = idx + window_size // 2 + (window_size % 2) return L[minrange:maxrange] def moving_average(L, window_size=1): """ Compute a moving average over the list L using the specified window size L: List of values window_size - The window size (default=1) return - A new list with smoothed values """ mavg = [] for i in range(len(L)): window = get_window(L, i, window_size) mavg.append(avg(window)) return mavg """ Next time: - Jupyter Notebooks - Classes and objects """