Stazionarietà e differenziazione
Preparare una serie per la modellazione.
Stazionarietà e differenziazione è una lezione Data Science Academy gratuita su CoddyKit. Questa è la lezione 3 di 4. Puoi leggere la lezione completa qui gratuitamente — poi esercitati direttamente nel browser con un editor di codice integrato e un tutor IA disponibile 24/7. Fa parte del percorso di apprendimento Data Science Academy, e i tuoi progressi si sincronizzano tra il web e l'app CoddyKit. Il corso Data Science Academy include 4 lezioni in totale.
Parti di questa lezione non sono ancora state tradotte e vengono mostrate in inglese.
Models Like Steady Data
Most forecasting models assume the series behaves consistently over time. That property has a name: stationarity. 🎯
What Stationary Means
A stationary series has a stable mean and spread that do not drift over time. Its statistical mood stays the same.
Trends Break Stationarity
A rising trend means the mean keeps climbing, so the series is non-stationary. Many models will struggle until you fix that.
Seasonality Breaks It Too
Repeating seasonal swings make the average rise and fall on a cycle. That changing pattern also counts as non-stationary.
The ADF Test
You do not have to guess. The ADF test checks stationarity and returns a p-value you can read.
from statsmodels.tsa.stattools import adfuller
result = adfuller(sales)Reading the P-Value
If the ADF p-value is below 0.05, the series is likely stationary. Above it, you probably still have a trend to remove.
Differencing to the Rescue
Differencing replaces each value with how much it changed from the last step. This simple move often erases a trend.
diffed = sales.diff()Why It Removes Trends
By looking at changes instead of levels, a steady climb becomes a flat line wobbling around zero, which is stationary.
Drop the First NaN
The very first row has nothing to subtract, so diff leaves it NaN. Drop it before testing or modeling.
diffed = sales.diff().dropna()Differencing Again
If one round is not enough, difference the result a second time. The number of rounds becomes the d term in ARIMA.
Seasonal Differencing
To kill a yearly cycle, subtract the value 12 steps back. That seasonal diff targets the repeating pattern directly.
seasonal = sales.diff(12)Quick Check
An ADF test on your raw series returns a p-value of 0.40. What does that suggest?
Recap: Make It Steady
You learned to test stationarity with ADF and to remove trends and cycles using differencing before modeling.
Domande Frequenti
La lezione «Stazionarietà e differenziazione» è gratuita?
Sì — il testo completo di «Stazionarietà e differenziazione» è gratuito qui sul web. Per esercitarvi in modo interattivo (un editor di codice integrato e un tutor IA 24/7) e sbloccare il resto del corso Data Science Academy, passa a CoddyKit PRO. Il corso Data Science Academy include 4 lezioni in totale.
Cosa imparerò in «Stazionarietà e differenziazione»?
Preparare una serie per la modellazione. Eserciti Data Science Academy con codice pratico che esegui direttamente nel browser, e un tutor IA 24/7 risponde alle tue domande mentre lavori sulla lezione.
Ho bisogno di esperienza per iniziare Data Science Academy?
Non è richiesta alcuna esperienza precedente. Data Science Academy su CoddyKit è strutturato per principianti e studenti avanzati, quindi puoi iniziare da qui o dall'inizio e procedere al tuo ritmo. Questa è la lezione 3 di 4.
Quanto tempo richiede la lezione «Stazionarietà e differenziazione»?
La maggior parte delle lezioni CoddyKit richiede circa 5–10 minuti. Ogni lezione è breve e interattiva, quindi fai progressi costanti e riprendi esattamente da dove hai lasciato su web e app.
Posso scrivere ed eseguire codice in questa lezione Data Science Academy?
Sì. Ogni lezione Data Science Academy include un editor di codice integrato, quindi scrivi ed esegui codice reale direttamente nel tuo browser e ricevi feedback istantaneo dall'IA — nessuna configurazione locale necessaria.
Tutte le lezioni di questo corso
- Trend, stagionalità e rumore
- Finestre mobili e lag
- Stazionarietà e differenziazione
- Una prima previsione di riferimento