Datafication, Exploratory Data Analysis, and Classification Models Study Guide

Course Overview, Logistics, and Learning Environment

  • Course Schedule and Structure:

    • Lectures run for 22 hours per week with a 1010-minute mid-lecture break (typically taken around 55 to 1212 minutes prior to the second hour).

    • Module 11 encompasses the first 44 weeks of the semester and covers all content evaluated on the midterm test.

    • Lecture design focuses on active, real-time student engagement rather than passive slide reading.

  • Engagement and Stats Apps:

    • Accessible on Canvas via the left-hand navigation menu under "Stats Apps" (toggle the menu display if hidden on mobile or small screens).

    • Allows anonymous live student input while attributing entries to Canvas profiles to record engagement marks.

    • Grace Period: Prep work contributions submitted up until Monday morning at 8:00 AM8:00\text{ AM} receive engagement credit, though completion prior to lectures is strongly recommended.

  • Communication Protocols and Staff Access:

    • Instructor Office: Room 320320, Building 303303.

    • Help Center / Drop-in Location: Room 170170, Building 302302 (fully refurbished).

    • Drop-in Hours: Available for 11 hour directly following lectures, Fridays all afternoon, and Mondays from 12:00 PM12:00\text{ PM} to 4:00 PM4:00\text{ PM}.

    • Email Policy: Direct email is mandatory for contacting staff (addresses listed on the "Meet the Team" Canvas page). Canvas direct messaging must not be used due to lost messages.

    • Ed Discussion: Online platform on Canvas for course-related queries. Existing threads must be searched before creating new posts.

    • Classroom Conduct: In-class chatter is prohibited due to hall acoustics that carry background voice audio across the room.

  • Course Assessments:

    • Quizzes: Located under the "Quizzes" tab on Canvas. Unlimited submission attempts are permitted prior to the deadline. Due every Friday at end of day (late penalties apply thereafter).

    • Weekly Tasks: Located in the course book under each chapter. Due every Monday at 10:00 PM10:00\text{ PM}. Tasks utilize unique individualized datasets; final responses must be downloaded as an HTML document and uploaded to Canvas under "Assignments" -> "Task 1".

    • Open Resource Policy: Prep work course notes and personal study guides may be brought directly into tests and examinations.

  • Class Representative Application Requirements:

    • Duties: Attend 22 mandatory meeting times during the semester and gather student feedback.

    • Application Format: Send an email to the instructor containing exactly 22 sentences (11 sentence detailing motivation for the role, 11 sentence describing field of study and background).

    • Deadline: End of business on Friday.

  • Technical Requirements and Course Tools:

    • Recommended Browser: Google Chrome is strongly advised (especially on macOS/Apple devices) for optimal compatibility with course web apps and scripts.

    • Insight Lite: Web application located under "Tools" in the course book, used for statistical data visualization, data import, and numerical analysis.

    • Panopto Video: Canvas folder housing all recorded lecture videos.

    • Software Guides: Available in the course book covering functions for Google Sheets and Insight Lite.

Datafication and Variables in Statistics

  • Concept of Datafication:

    • Datafication is the algorithmic process of transforming raw unstructured data or existing variables into structured quantitative or categorical variables using formulas or code.

    • Examples include converting raw unstructured text strings into explicit character counts, word counts, or logical indicators.

  • Sentiment Analysis:

    • Sentiment analysis converts qualitative text into measurable categories reflecting emotional tone (e.g., positive, negative, neutral).

    • Practical Applications: Used in social media monitoring, such as tracking consumer sentiment on Twitter following product releases (e.g., evaluating reactions to a novel licorice chocolate mango ice cream flavor).

    • Dictionary-Based Sentiment Analysis: Uses pre-defined word libraries to classify text based on target vocabulary (e.g., mapping "nervous" to negative sentiment or "excited" to positive sentiment).

  • Structure of a Rectangular Data Set:

    • A rectangular data set is organized such that every column represents a variable and every row (excluding header row 11) represents an individual case or entity.

    • Variable Types in Data Collection Spreadsheets:

    • timestamp: Date and time of submission.

    • writing ID: Unique cryptographic hash assigned to the entry.

    • device type: Categorical variable indicating hardware type (e.g., desktop/laptop vs. mobile).

    • screen width: Numeric variable recording screen resolution in pixels.

    • comment: Raw unstructured text string.

    • time taken in seconds: Continuous numeric variable representing completion duration.

    • user ID: Unique Canvas profile identifier mapped for engagement credit.

  • Classification of Variables:

    • Categorical Variable: Takes discrete non-numeric values, labels, or factor levels (e.g., device type, sentiment category, prior statistics experience level).

    • Numeric Variable: Takes continuous or discrete numerical values representing direct counts or measurements (e.g., screen width in pixels, completion duration in seconds, character count).

Google Sheets Operations and Data Tidying

  • Crowdsourcing Data Cleansing:

    • Datasets containing raw text inputs require manual crowdsourced auditing to systematically convert free-form comments into standardized categorical data.

    • A random number generator selects specific row indices between row 22 and the maximum dataset row (e.g., row 457457) to distribute auditing across reviewers.

  • Google Sheets Functions and Formulas:

    • Column Insertion: Right-click the header of an adjacent column (e.g., column H) and select "Insert 1 column to the left".

    • Character Length Calculation:

    • Function syntax: =LEN(cell_reference)=\text{LEN}(\text{cell\_reference})

    • Example: =LEN(G127)=\text{LEN}(G127) calculates the total number of characters contained in cell G127G127.

    • Duplicate Removal:

    • Path: Data -> Data cleanup -> Remove duplicates.

    • Select target unique identifier columns (e.g., submission ID or comment row) to eliminate double submissions.

  • Publishing Spreadsheets for Insight Lite Integration:

    • Path: File -> Share -> Publish to web.

    • Sheet Selection: Select the specific named worksheet tab.

    • File Format: Set output drop-down to "Comma-separated values (.csv)".

    • Link Verification: Ensure the generated URL ends explicitly with the .csv extension to guarantee readability by Insight Lite.

Exploratory Data Analysis Using Insight Lite

  • Data Import Procedure in Insight Lite:

    • Open Insight Lite via course book tools.

    • Path: File -> Import dataset -> Paste published .csv URL -> Click Import -> Click Confirm.

    • Select Visualize tab to initialize graphical exploration.

  • Variable Classifications in Bivariate Analysis:

    • Response Variable: The primary outcome variable being analyzed or predicted. Selected as Variable 11 in Insight Lite and plotted on the primary vertical axis.

    • Explanatory Variable: The secondary variable used to explain variations or structural differences in the response variable. Selected as Variable 22 in Insight Lite.

    • Terminology Standard: Replaces legacy scientific terms such as "dependent variable" (response variable) and "independent variable" (explanatory variable).

  • Analysis of Student Course Sentiment:

    • Overall Sentiment Distribution:

    • Positive Sentiment: Represented the statistical majority at 52.5%52.5\%.

    • Neutral and Negative Sentiment: Accounted for the remaining 47.5%47.5\% combined.

    • Sentiment Segmented by Prior Statistics Background:

    • Year 1313 Statistics Background: 65.55%65.55\% of students with Year 1313 high school statistics experience expressed a positive sentiment toward the course.

    • Less Prior Statistics Background: Approximately 33%33\% to 35%35\% of students with less prior statistics experience expressed positive sentiment.

    • Neutral Sentiment: Exhibited minimal variation between students with Year 1313 background and those with less background.

    • Evaluative Standards: Statistical evaluations must rely strictly on quantitative empirical data (e.g., percentages, proportions, counts) rather than anecdotal or contextual assumptions.

Classification Models, Baseline Models, and Spam Detection

  • Terminology in Text Classification:

    • Spam: Unsolicited, unwanted automated messages or promotional communications.

    • Ham: Legitimate, essential text messages from personal, academic, or professional contacts.

  • The Baseline Model Concept:

    • Definition: A baseline model is a naive classification benchmark that operates without incorporating any explanatory variables, predicting the overall majority class for every instance.

    • Baseline Performance: In a dataset where 52%52\% of total messages are ham, predicting "ham" for all incoming messages yields a baseline accuracy of 52%52\%.

    • Purpose: Serves as the baseline threshold that any feature-driven predictive model must exceed to demonstrate predictive utility.

  • Feature Engineering for Text Classification:

    • Categorical variables engineered from message text must feature clear, descriptive names and precise, unambiguous level definitions:

    • contains_numbers: Levels = contains numbers vs. no numbers.

    • contains_exclamation: Levels = contains exclamation vs. no exclamation.

    • contains_free_or_urgent: Levels = contains free/urgent vs. does not contain.

    • character_length_group: Levels = less than 100 characters vs. at least 100 characters.

    • contains_url: Levels = contains URL vs. no URL.

  • Graphical Evaluation of Explanatory Power in Mosaic Plots:

    • Bar Width: Represents the sample size / proportion of observations belonging to that category level of the explanatory variable.

    • Bar Height: Displays the relative proportion of response variable categories (spam vs. ham) within that specific explanatory level.

    • Criterion for Superior Predictors: Optimal explanatory variables produce maximum vertical contrast across levels (e.g., one level showing a high percentage of spam and another showing a high percentage of ham).

    • Comparative Evaluation of Candidates:

    • contains_url: Ineffective predictor; very few text messages contain URLs, yielding minimal overall predictive separation.

    • contains_free_or_urgent: Strong positive identifier (95%95\% spam when present), but weak negative identifier when absent (65%65\% ham, 35%35\% spam).

    • contains_numbers: Highly effective dual-level predictor. 77%77\% (up to 82.4%82.4\% in sub-samples) of messages containing numbers were spam, while 83%83\% (up to 57.4%57.4\% ham in contrast tests) of messages lacking numbers were ham.

Confusion Matrices and Model Evaluation Metrics

  • Structure of a Confusion Matrix:

    • A confusion matrix is a tabular grid displaying cross-tabulated counts of predicted classifications versus actual ground-truth classes.

    • Grid Components:

    • True Spam (Predicted Spam, Actual Spam)

    • False Spam / False Positive (Predicted Spam, Actual Ham)

    • False Ham / False Negative (Predicted Ham, Actual Spam)

    • True Ham (Predicted Ham, Actual Ham)

  • Formula for Percentage Classified Correctly (PCC):

    • PCC measures total classification accuracy of a model as a percentage:     PCC=(Number of Correct PredictionsTotal Number of Observations)×100%\text{PCC} = \left( \frac{\text{Number of Correct Predictions}}{\text{Total Number of Observations}} \right) \times 100\%

  • Sample Calculation from Class Exercise:

    • Decision Rule: Predict "Spam" if the message contains numbers; predict "Ham" if the message contains no numbers.

    • Evaluated Sample Size: 2020 text messages.

    • Correct Predictions: 1616 out of 2020 messages correctly identified (99 True Ham + 77 True Spam).

    • Computation:     PCC=(1620)×100%=80%\text{PCC} = \left( \frac{16}{20} \right) \times 100\% = 80\%

    • Model Performance Assessment: The feature-driven decision rule model (PCC=80%\text{PCC} = 80\%) significantly outperforms the naive baseline model (PCC=52%\text{PCC} = 52\%), establishing strong predictive value.