Homework 1: The Brand & Reaction Engine
You are a digital strategy consultant. A client has handed you a CSV file of their tweet history. They want to know: What do they talk about? Who should they sponsor? And can AI help them manage their feed autonomously?
Instructions
-
Create a Streamlit web app titled "[Your Name] Strategic Tweet Engine" that processes a CSV file of tweets and includes the following 5 Tabs:
-
Tab 1: The Leaderboard
Display a clean data table of the user's tweets. The table must show tweets ranked specifically by Engagement Rate (Favorites / Views). -
Tab 2: The Activity Heatmap
Build a Heatmap showing posting frequency:- X-Axis: Hour of Day (0-23)
- Y-Axis: Day of Week (Mon-Sun)
-
Tab 3: Topic Modeler
Use AI to analyze the text of all of the tweets. Identify the top 5 "Core Pillars" (topics) of the account. Display the results in a table with two columns: Topic Name and Description. -
Tab 4: Brand Compatibility Agent
Create an input box where the user types a Brand Name (e.g., "Nike", "Yale University"). Use AI to analyze the brand against all of the user's tweets and output a Compatibility Score (0-100%) along with a paragraph of strategic reasoning. -
Tab 5: The News Reactor
Create an input box where the user enters a News Article URL. When a URL is provided, the app should scrape the article text usingnewspaper3kor a similar library, then use AI to generate a reactive tweet in the user's specific voice based on all of their tweets. Display the generated tweet in a styled "Tweet Card" UI that includes a dummy Avatar icon, dummy Name, and the tweet Text.
-
Tab 1: The Leaderboard
-
The app should be robust, professionally styled, and error-free.
Submission Checklist
Your submission should include the following files zipped into a file called hw1.zip:
app.py- the main app filerequirements.txt- listing all dependencies
Grading Breakdown (100 Points)
| Component | Points | Description |
|---|---|---|
| Foundation & Tab 1 | 5 | App runs smoothly; CSV loads correctly; Tab 1 correctly sorts and displays the Leaderboard by Engagement Rate. |
| Tab 2: Heatmap Visuals | 20 | Heatmap correctly aggregates data by Day vs. Hour. |
| Tab 3: Topic Modeler | 15 | AI successfully extracts meaningful topics and displays them in a structured 2-column DataFrame (not just a blob of text). |
| Tab 4: Brand Agent | 25 | The AI provides a logical numeric score and specific reasoning connecting the Brand values to the User's specific tweet content. |
| Tab 5: News Reactor | 30 | App successfully scrapes a real URL, and uses AI to generate a relevant tweet in the user's voice, and renders it in the styled "Tweet Card" UI. |
| Proper Submission Zip | 5 | hw1.zip is submitted and correctly contains app.py and requirements.txt with the expected structure and filenames. |