Analysis Overview
Analysis overview and configuration
| Parameter | Value | _row |
|---|---|---|
| n_trees | 100 | n_trees |
| contamination | 0.05 | contamination |
| sample_size | 32 | sample_size |
Purpose
This analysis applies Isolation Forest, an unsupervised anomaly detection algorithm, to identify unusual weeks in marketing spend patterns across four channels (TikTok, Facebook, Google Ads, and Sales). The model processes 200 weekly observations to flag statistically isolated spending behaviors that deviate from normal patterns, enabling the marketing team to investigate potential operational issues or strategic shifts.
Key Findings
- Anomalies Detected: 14 weeks (7% anomaly rate) flagged from 200 observations with 100% data retention
- Top Anomaly Driver: TikTok spending shows the strongest isolation signal (importance score: 100), indicating it most effectively distinguishes anomalous weeks
- Score Separation: Mean anomaly score of 0.568 with minimal separation (0.029) suggests anomalies are subtly different from normal patterns rather than extreme outliers
- Feature Patterns: Anomalous weeks show TikTok spending at $0 (vs. $3,168 normal mean), Google Ads elevated to $2,017 (vs. $1,483 normal), and Sales slightly reduced to $9,795 (vs. $10,734 normal)
Interpretation
The model identifies a consistent anomaly profile: weeks with zero TikTok investment paired with elevated Google Ads spending and
Data preprocessing and column mapping
Purpose
This section documents the data intake and cleaning phase for the Isolation Forest anomaly detection model. Perfect retention (100%) indicates no rows were removed during preprocessing, meaning all 200 weekly observations of marketing spend across TikTok, Facebook, Google Ads, and Sales proceeded to model training without data loss.
Key Findings
- Initial Rows: 200 observations retained without removal
- Retention Rate: 100% — no filtering, imputation, or exclusion applied during preprocessing
- Train/Test Split: Not applicable for unsupervised anomaly detection; all data used for model fitting
- Data Quality Status: No missing values or quality issues detected requiring row removal
Interpretation
The perfect retention rate reflects clean input data with no missing feature values across the four marketing channels. This is favorable for anomaly detection, as Isolation Forest requires complete observations to build isolation trees effectively. The absence of preprocessing transformations (scaling, encoding) suggests features were already in numeric form and suitable for the algorithm without standardization.
Context
Unsupervised models like Isolation Forest don't require train/test splits; instead, all observations contribute to learning the normal spending patterns. The quality checks confirm the dataset met baseline requirements, though this doesn't guarantee the anomalies detected (14 instances) are business-meaningful—only that data integrity was maintained.
Executive Summary
Executive summary of anomaly detection results
| Finding | Value |
|---|---|
| Total Observations | 200 |
| Anomalies Detected | 14 |
| Anomaly Rate | 7% |
| Detection Threshold | 0.5684 |
| Top Feature | TikTok |
| Score Separation | 0.0291 |
Key Findings:
• 14 observations scored below the anomaly threshold of 0.5684
• 'TikTok' is the strongest driver of anomaly isolation
• Score separation between anomalies and normal observations: 0.0291
• Anomaly mean score: 0.5679 vs normal mean score: 0.597
Recommendation: Review the top-ranked anomalies in the Anomaly Details section. Investigate records with scores below 0.5684 — these may indicate data quality issues, fraud, or unusual events requiring attention.
Purpose
This analysis applied Isolation Forest anomaly detection to 200 weeks of marketing spend data across TikTok, Facebook, Google Ads, and Sales channels. The objective was to identify anomalous spending patterns that deviate from normal operational behavior, enabling the marketing team to flag unusual weeks for investigation and corrective action.
Key Findings
- Anomaly Detection Rate: 14 anomalies identified (7% of 200 observations) — within expected contamination parameters and sufficient for actionable insight
- Top Anomaly Driver: TikTok spend shows 100% feature importance, indicating zero TikTok spend is the strongest anomaly signal
- Score Separation: Minimal gap (0.029) between anomaly and normal observation scores suggests subtle but consistent deviations rather than extreme outliers
- Directional Pattern: Anomalous weeks show TikTok spend at $0 (vs. normal mean $3,168), while Google Ads spending increases 36% and Facebook drops 85.5%
Interpretation
The model successfully isolated 14 weeks with atypical marketing spend allocation. These anomalies are characterized primarily by absence of TikTok investment combined with compensatory shifts in other channels. The tight score clustering (mean 0.59, range 0.57–0.67) indicates the anomal
Anomaly Score Distribution
Distribution of anomaly scores across all observations
Purpose
This section evaluates the effectiveness of the Isolation Forest algorithm in separating anomalous weeks from normal marketing spend patterns. By examining the distribution of anomaly scores across all 200 observations, we can assess whether the model successfully identified distinct behavioral outliers in TikTok, Facebook, Google Ads, and Sales spending.
Key Findings
- Anomaly Detection Rate: 7% (14 anomalies detected) — Aligns with the 5% contamination parameter, indicating the model identified slightly more anomalies than expected, suggesting genuine outliers exist in the marketing spend data
- Score Range: 0.57–0.67 — Narrow range indicates tight clustering, with anomalies concentrated at the threshold boundary
- Mean Anomaly Score: 0.59 — Anomalies cluster just above the 0.5684 threshold, showing marginal separation from normal observations
- Score Separation: 0.029 — Low separation metric suggests anomalies are not dramatically distinct from normal weeks
Interpretation
The model identified 14 weeks with unusual spending patterns, though the tight score distribution (SD = 0.02) reveals these anomalies are subtly different from normal weeks rather than extreme outliers. This modest separation suggests anomalous weeks represent gradual deviations in spend allocation rather than dramatic spikes or col
Feature Space: Anomalies vs Normal
Two-dimensional feature space showing anomalies vs normal observations
Purpose
This scatter plot maps 200 weekly observations across TikTok (x-axis) and Google Ads (y-axis) spend, the two most influential features in the anomaly detection model. It reveals how anomalous weeks cluster spatially relative to normal operations, enabling visual identification of unusual spending patterns that the Isolation Forest algorithm isolated as statistically distinct.
Key Findings
- Anomalies Detected: 14 weeks (7% of 200 observations) flagged as anomalous, with all sharing an anomaly score of 0.57 at the detection threshold
- TikTok Dominance: TikTok spend (x-axis) has 100% feature importance, indicating it is the primary driver separating anomalies from normal weeks
- Spatial Pattern: Anomalous weeks show extreme TikTok values (either zero or very high, up to $13,901), while normal weeks cluster around moderate spend levels with median TikTok spend of $0 and high variability (SD=$4,750)
- Google Ads Consistency: Anomalous weeks maintain relatively stable Google Ads spend ($1,899–$2,151), contrasting sharply with normal weeks' broader range
Interpretation
The scatter reveals that anomalies are primarily driven by atypical TikTok
Feature Importance
Feature importance for anomaly detection via permutation analysis
Purpose
This section identifies which marketing spend channels are most critical for detecting anomalous weeks. By measuring how much each feature contributes to anomaly isolation, the analysis reveals which spending patterns are most distinctive when weeks deviate from normal behavior. This directly supports the objective of understanding what drives anomalous marketing activity across the four channels.
Key Findings
- TikTok (Importance: 100): Dominates anomaly detection, indicating that TikTok spending patterns are the strongest differentiator between normal and anomalous weeks
- Google Ads (Importance: 94.44): Nearly as critical as TikTok, suggesting consistent and distinctive spending behavior
- Sales (Importance: 76.26): Moderate contributor to anomaly isolation
- Facebook (Importance: 46.27): Lowest importance; contributes least to distinguishing anomalous weeks from normal activity
Interpretation
The stark dominance of TikTok (100 vs. 46.27 for Facebook) reveals that anomalous weeks are primarily characterized by unusual TikTok spending patterns. The 14 detected anomalies show zero TikTok spend across all cases, making this the defining feature. Google Ads maintains consistent, predictable spending even during anomalies, while Facebook's low importance suggests its spending varies similarly in both normal and anom
Normal vs Anomaly Comparison
Comparison of mean feature values between normal and anomalous observations
Purpose
This section reveals the behavioral signatures of anomalous weeks by comparing average spending patterns across channels. Rather than just identifying which weeks are anomalous, it shows why they're anomalous—exposing the distinctive spending profiles that distinguish anomalies from normal operations in the marketing spend dataset.
Key Findings
- TikTok: Anomalies show zero spending (mean=0) versus normal weeks averaging $3,168—the most dramatic differentiator and primary driver of anomaly detection
- Google Ads: Anomalies average $2,017 versus normal weeks at $1,483, representing a 36% increase rather than decrease
- Facebook & Sales: Anomalies show reduced spending (−85.5% and −8.8% respectively) compared to normal weeks
- Variability Pattern: Anomalous weeks exhibit lower standard deviations across all channels, indicating more consistent but atypical spending profiles
Interpretation
The anomalies cluster around a distinct pattern: complete TikTok shutdown paired with elevated Google Ads investment and suppressed Facebook/Sales activity. This isn't random noise—it's a coherent alternative spending strategy. The low variance in anomalous weeks suggests these represent deliberate budget reallocations rather than measurement errors, making them strategically meaningful for understanding campaign variations.
Context
Top Anomalies
Top anomalous observations ranked by severity score
| anomaly_rank | anomaly_score | TikTok | Google Ads | Sales | |
|---|---|---|---|---|---|
| 1 | 0.5664 | 0 | 0 | 2037 | 1.113e+04 |
| 2 | 0.5671 | 0 | 0 | 2065 | 1.001e+04 |
| 3 | 0.5671 | 0 | 0 | 1958 | 9923 |
| 4 | 0.5677 | 0 | 4793 | 1898 | 1.175e+04 |
| 5 | 0.5677 | 0 | 0 | 2039 | 8134 |
| 6 | 0.5677 | 0 | 0 | 1990 | 9130 |
| 7 | 0.5684 | 0 | 0 | 1910 | 8068 |
| 8 | 0.5684 | 0 | 0 | 2144 | 1.164e+04 |
| 9 | 0.5684 | 0 | 0 | 1900 | 8085 |
| 10 | 0.5684 | 0 | 0 | 2015 | 9229 |
| 11 | 0.5684 | 0 | 0 | 2100 | 1.084e+04 |
| 12 | 0.5684 | 0 | 0 | 1995 | 9702 |
| 13 | 0.5684 | 0 | 0 | 2151 | 1.16e+04 |
| 14 | 0.5684 | 0 | 0 | 2034 | 7885 |
Purpose
This section identifies the 14 most anomalous weeks in marketing spend across TikTok, Facebook, Google Ads, and Sales. By ranking observations by anomaly severity, it isolates weeks that deviate most from typical spending patterns, enabling focused investigation of unusual marketing behavior and potential operational issues.
Key Findings
- Anomaly Count: 14 weeks detected (7% of 200 total weeks) - aligns with the 5% contamination parameter set in model configuration
- Mean Anomaly Score: 0.568 for anomalies vs. 0.597 for normal weeks - a separation of 0.029 indicates modest but meaningful distinction between groups
- Pattern Observed: Anomalous weeks show zero TikTok spend (100% of anomalies), elevated Google Ads spend (+36% vs. normal), and reduced Facebook spend (-85.5% vs. normal)
Interpretation
The tight score separation (0.029) reflects that Isolation Forest detected subtle multivariate deviations rather than extreme univariate outliers. Anomalous weeks cluster around a specific spending profile: absent TikTok investment paired with consistent Google Ads and Sales activity. This pattern suggests systematic shifts in channel allocation rather than random fluctuations, warranting investigation into whether these weeks correspond to campaign strategy changes or budget constraints.
Model Configuration
Isolation Forest model parameters and configuration
| parameter | value |
|---|---|
| Algorithm | Isolation Forest (solitude) |
| Number of Trees | 100 |
| Contamination Rate | 5% |
| Sample Size | 32 |
| Features Used | 4 |
| Total Observations | 200 |
| Anomalies Detected | 14 |
| Normal Observations | 186 |
| Detection Threshold | 0.5684 |
| Top Feature | TikTok |
Purpose
This section documents the Isolation Forest model's configuration parameters that govern how anomalies are detected in marketing spend data. The settings—100 trees and 5% contamination rate—directly determine the sensitivity and specificity of anomaly identification across TikTok, Facebook, Google Ads, and Sales channels. Understanding these parameters is essential for interpreting why 14 specific weeks were flagged as anomalous.
Key Findings
- Number of Trees (n_trees): 100 - Provides sufficient ensemble diversity to reliably isolate anomalies through recursive partitioning while maintaining computational efficiency
- Contamination Rate: 5% - Explicitly calibrates the model to expect approximately 14 anomalies in the 200-week dataset, aligning detected anomalies (14) with prior expectations
- Anomalies Detected: 14 observations - Matches the 7% observed anomaly rate, validating that the contamination parameter was appropriately tuned for this marketing spend dataset
Interpretation
The model configuration reflects a balanced approach to anomaly detection in marketing spend patterns. The 5% contamination assumption translates to expecting roughly 10 anomalous weeks; the actual detection of 14 (7% rate) suggests slightly more deviation than anticipated, though within reasonable variance. The 100-tree ensemble ensures robust isolation decisions by reducing
Statistical Summary
Statistical comparison of features for normal vs anomalous groups
| feature | normal_mean | normal_sd | anomaly_mean | anomaly_sd | pct_difference |
|---|---|---|---|---|---|
| TikTok | 3168 | 4854 | 0 | 0 | -100 |
| 2354 | 2521 | 342.4 | 1281 | -85.5 | |
| Google Ads | 1483 | 891.7 | 2017 | 82.47 | 36 |
| Sales | 1.073e+04 | 2764 | 9795 | 1428 | -8.8 |
Purpose
This section compares feature behavior between normal and anomalous weeks to identify which marketing channels deviate most dramatically during anomalies. It reveals the statistical signatures of anomalous spending patterns, directly supporting the core objective of understanding what makes certain weeks unusual across TikTok, Facebook, Google Ads, and Sales.
Key Findings
- TikTok: -100% difference – anomalous weeks show zero spending versus ~$3,168 average in normal weeks, making it the strongest anomaly indicator
- Facebook: -85.5% difference – severely reduced spending during anomalies ($342 vs $2,354 normally)
- Google Ads: +36% difference – uniquely elevated during anomalies ($2,017 vs $1,483 normally), showing inverse behavior
- Sales: -8.8% difference – minimal deviation, suggesting anomalies are driven by ad spend patterns rather than revenue
Interpretation
Anomalous weeks are characterized by a distinctive spending profile: complete TikTok shutdown paired with Google Ads elevation. This pattern suggests deliberate budget reallocation rather than random fluctuation. The tight Google Ads standard deviation (82.47) during anomalies indicates consistent, intentional spending levels, while normal weeks show high variability (891.69).
Context
These statistics assume anomalies reflect genuine