Analysis overview and configuration
| Parameter | Value | _row |
|---|---|---|
| n_trees | 100 | n_trees |
| contamination | 0.05 | contamination |
| sample_size | 32 | sample_size |
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.
The model identifies a consistent anomaly profile: weeks with zero TikTok investment paired with elevated Google Ads spending and
Data preprocessing and column mapping
| Metric | Value |
|---|---|
| Initial Rows | 200 |
| Final Rows | 200 |
| Rows Removed | 0 |
| Retention Rate | 100% |
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.
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.
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.
| Finding | Value |
|---|---|
| Total Observations | 200 |
| Anomalies Detected | 14 |
| Anomaly Rate | 7% |
| Detection Threshold | 0.5684 |
| Top Feature | TikTok |
| Score Separation | 0.0291 |
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.
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
Distribution of anomaly scores across all observations
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.
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
Two-dimensional feature space showing anomalies vs normal observations
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.
The scatter reveals that anomalies are primarily driven by atypical TikTok
Feature importance for anomaly detection via permutation analysis
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.
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
Comparison of mean feature values between normal and anomalous observations
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.
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.
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 |
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.
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.
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 |
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.
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 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 |
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.
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).
These statistics assume anomalies reflect genuine