Posts

Seasonality code

 import pandas as pd import numpy as np from scipy import stats from scipy.signal import find_peaks from sklearn.feature_extraction.text import TfidfVectorizer from sklearn.ensemble import RandomForestClassifier from sklearn.model_selection import train_test_split, cross_val_score from sklearn.metrics import classification_report, confusion_matrix from sklearn.preprocessing import StandardScaler from datetime import datetime, timedelta import warnings warnings.filterwarnings(‘ignore’) class SeasonalClassifier: def **init**(self, min_weeks=16, min_observations_per_season=2): “”” Initialize the seasonal classifier ```     Args:         min_weeks: Minimum weeks of data required for K-W test         min_observations_per_season: Minimum observations per season for reliability     """     self.min_weeks = min_weeks     self.min_observations_per_season = min_observations_per_season     self.high_conf...

Building a Smart Keyword Seasonality Analyzer: From Expert Intuition to AI-Powered Insights

 # Building a Smart Keyword Seasonality Analyzer: From Expert Intuition to AI-Powered Insights *How we built a system that combines embedding-based relevance detection with statistical seasonality analysis to understand search patterns at scale* --- ## The Challenge: Beyond Human Intuition When analyzing keyword seasonality for the South Korean market, we faced a classic data science dilemma: **expert knowledge vs. algorithmic scalability**.  Our marketing experts could look at search data for "winter jacket" and instantly recognize the seasonal pattern. They could spot that "thermal coat" was relevant to our winter apparel product line. But with thousands of keywords to analyze, this human-centered approach hit three major roadblocks: 1. **Scale**: Experts can't tag 10,000+ keywords manually 2. **Bias**: Human intuition favors high-volume, obvious patterns 3. **Inconsistency**: Different experts tag the same keyword differently We needed a solution that **prese...

Beyond Seasonality: Integrating External Events in Time Series Analysis

In today's data-driven business environment, understanding the patterns in your time series data is essential for making informed decisions. While seasonal decomposition techniques like STL (Seasonal-Trend-Loess) are powerful tools for separating seasonal patterns from underlying trends, they often miss a critical factor: the impact of external events. When analyzing sales, web traffic, or consumer behavior, external events like holidays, promotions, or cultural celebrations can cause significant spikes that traditional time series analysis might misattribute to noise or seasonality. This is particularly true in markets with strong cultural events that dramatically affect consumer behavior. In this article, I'll share a comprehensive approach that extends STL decomposition to: 1. Normalize for price impacts using elasticity models 2. Account for external events using your own events calendar 3. Handle additional factors like promotions and out-of-stock situations 4. Automatical...

Improving Time Series Analysis: STL Decomposition with Price Normalization

In the world of data analysis, understanding seasonal patterns in time series data can be crucial for making informed business decisions. Whether you're analyzing web traffic, product sales, or marketing impressions, seasonal trends often tell an important story. However, external factors like price changes can mask these patterns, making it difficult to identify true seasonality. In this article, I'll walk you through an enhanced approach to Seasonal-Trend-Loess (STL) decomposition that normalizes for price impacts and automatically flags seasonal patterns. This technique is particularly valuable for businesses where pricing dynamics can significantly affect performance metrics. ## The Challenge with Traditional Time Series Analysis Standard time series decomposition separates data into three components: - **Trend**: The long-term progression of the series - **Seasonality**: Repeating patterns at fixed intervals - **Residual**: The irregular remainder after removing trend and ...