AFM 112 — Final Exam Cram Sheet

Analytic Methods for Business 1 · Rohani · cumulative · Google Sheets + Python · exam Mon Dec 15, 4:00 PM · open notes, no AI
● KEY framework / formula — know it cold ✎ COMMON TRAP — where marks are lost

Types The Four Analytics Types

● The Gartner analytic ascendancy ladder (value & difficulty rise as you climb):
TypeQuestionCase
DescriptiveWhat happened?Big Picture
DiagnosticWhy?Segment Analysis
PredictiveWhat will happen?OKCupid
PrescriptiveWhat should we do?Pet Adoption
  • Data → information → insight: raw facts → organised/summarised → information that changes a decision.
✎ Classic quiz move: a scenario ("why did sales drop in one region?") → classify the type (diagnostic). "What should we stock?" → prescriptive.

CRISP CRISP-DM — the spine

● Cross-Industry Standard Process for Data Mining — 6 phases, in order (B-D-P-M-E-D):
  1. Business Understanding — frame the decision/question; set objectives & success criteria.
  2. Data Understanding — collect, explore, describe, check quality.
  3. Data Preparation — clean, transform, tidy. ~80% of the effort.
  4. Modelling — build a Sheets model AND a Python model.
  5. Evaluation — does it answer the business question (not just accuracy)?
  6. Deployment — communicate/visualize; build the dashboard.
✎ It's iterative/cyclical, NOT linear — phases loop back (Evaluation → Business Understanding). The learning outcomes are literally the CRISP-DM steps.

Data Data Management & Tidy Data

  • Structure: structured (rows/cols) · unstructured (text/images, no schema) · semi-structured (JSON/XML — tags, no rigid table).
  • Qual vs quant: qualitative = categorical; quantitative = numeric. Discrete (countable) vs continuous (any value in a range).
  • Levels of measurement: nominal (no order) → ordinal (ordered, unequal gaps) → interval → ratio (true zero).
● Tidy data: each variable = a column, each observation = a row, each cell = one value. What pandas & pivot tables expect.
  • Data quality: accuracy, completeness, consistency, timeliness, validity, uniqueness.
  • Missing values → drop or impute (mean/median/mode). Outlier = far-from-the-rest point that distorts the mean. Population vs sample.

Sheets Google Sheets

● Cell references: relative A1 shifts when copied; absolute $A$1 is locked; mixed A$1 / $A1.
  • Functions: AVERAGE · MEDIAN · MODE · STDEV · VAR · CORREL · COUNT (numbers) vs COUNTA (non-empty) · COUNTIF · SUMIF · QUARTILE.INC.
  • Logical: IF(test, if_true, if_false) to build categories.
  • Pivot table = group-and-summarize (= pandas groupby). Formulas start with =.
✎ COUNT counts numbers only; COUNTA counts any non-empty cell. Lock references with $ before you fill down a column.

Python pandas — load, inspect, subset

  • import pandas as pd · import numpy as np
  • Load: df = pd.read_csv("file.csv")
  • Inspect: df.head() · df.info() (dtypes — text = object) · df.describe() (count/mean/std/min/Q1/median/Q3/max) · df.shape · df.columns
  • Column: df['col']. Filter rows: df[df['x']>5] or df.query('x>5'). Select cols: df[['a','b']].
  • New column: df['n']=… or .assign(n=…). Sort: df.sort_values('x').
✎ Lists are 0-indexed and slices exclude the stop: lst[0:2] = first two. In .info(), text shows as object (Colab's pandas) — that's the answer-key dtype.

Python groupby + derived columns

● Segment analysis = groupby (the pivot-table of pandas): df.groupby('region')['sales'].mean() or .groupby(...).agg({...}).
  • 2-way column: np.where(cond, a, b) — e.g. np.where(speed==4,'Not adopted','Adopted').
  • Multi-way column: np.select([c1,c2], [v1,v2], default=…) — e.g. income groups.
  • Unique: .nunique(); top/bottom: .nlargest() / .nsmallest().
✎ Numeric answers must match Python/Sheets EXACTLY — copy from the same call the key uses; don't hand-round.

Stats Descriptive Statistics

  • Mean = Σx/n (sensitive to outliers). Median = middle value (robust — use for skewed data like income). Mode = most frequent (only average for nominal).
  • Sample SD s = √[Σ(x−x̄)²/(n−1)] — pandas/Sheets use the n−1 sample formula. CV = s/x̄ (compare spread across scales).
● IQR = Q3 − Q1 (uses type-7 / QUARTILE.INC quartiles). Outlier if below Q1 − 1.5·IQR or above Q3 + 1.5·IQR (the boxplot fences).
  • z-score z = (x − μ)/σ — SDs from the mean. Skew: right/positive = long right tail, mean > median.
✎ If mean > median → right-skewed → report the median. df.describe() gives the whole five-number summary in one call.

Stats Correlation & Diagnostic Analytics

  • Correlation r (−1 to +1): strength/direction of a linear association; near ±1 strong, 0 none.
  • Diagnostic / segment analysis: split records into groups (region, type, time), compare segment stats, check correlations of candidate drivers, state the likely "why".
✎ Correlation is NOT causation — co-movement can be a confounder or coincidence. Diagnostic analytics suggests causes; it doesn't prove them.

Prob Probability & Conditional Probability

  • 0 ≤ P(A) ≤ 1; total = 1; complement P(not A) = 1 − P(A).
  • Addition: P(A or B) = P(A)+P(B)−P(A and B) (mutually exclusive → last term 0).
  • Multiplication: P(A and B) = P(A)·P(B|A); independent → P(A)·P(B).
  • Expected value E(X) = Σ x·P(x).
● Conditional: P(A | B) = P(A and B) / P(B). The course's pandas pipeline per group: n → freq (=n/total) → sumFreq (groupby sum) → condProb (=freq/sumFreq) = P(outcome | group).

Predict Predictive & Prescriptive

  • Predictive (OKCupid): predict income group from job via conditional probability. Classification (predict a label) vs regression (predict a number). Train/test split guards against overfitting (memorising noise). ⚠ income==-1 is a "did-not-report" sentinel, NOT missing.
  • Prescriptive (Pet Adoption): recommend an action. Binary target Adopted = np.where(speed==4,'Not adopted','Adopted'); find high-adoption subgroups — always check n (a high % on 5 rows is noise).
● Optimization: decision variables (what you choose) · objective (max/min, e.g. profit) · constraints (limits). LP optimum sits at a corner of the feasible region (Solver).

Viz Visualization & Dashboards

● Chart picker: categories → bar; trend over time → line; one numeric distribution → histogram/boxplot; two numerics → scatter; composition → stacked bar (pie sparingly).
  • Honest charts: maximise data-ink ratio, cut chartjunk, start bar axes at zero, label axes/units, one message per chart.
  • Dashboard = one focused view, leads with KPIs in plain language for a non-technical audience.
  • Storytelling: question → what the data shows → so-what/recommendation (lead with the insight).

GenAI The GenAI Module

  • How it works: a large language model predicts the next token from patterns in training data — it doesn't "look things up". Strengths: drafting, summarizing, explaining. Risks: hallucination, bias, confident-but-wrong.
  • Prompt engineering: give role, context, task, format, and examples; iterate. Context engineering: supply the right background/data so it answers for your situation.
  • Always review/verify GenAI output against a trusted source — you are accountable.
✎ AI is allowed on open-note weekly quizzes but banned on the in-person final. Collaboration is never allowed.

Print me (Cmd+P) · built from your AFM 112 guide, review deck, seminars & class notes · ● = key, ✎ = the trap that costs marks