ความคงที่และการหาผลต่าง
เตรียมอนุกรมสำหรับสร้างโมเดล
ความคงที่และการหาผลต่าง เป็นบทเรียน Data Science Academy ฟรีบน CoddyKit นี่คือบทเรียนที่ 3 จากทั้งหมด 4 บทเรียน คุณสามารถอ่านบทเรียนทั้งหมดด้านล่างฟรี — จากนั้นลองปฏิบัติด้วยตัวคุณเองในเบราว์เซอร์พร้อมตัวแก้ไขโค้ดในตัวและติวเตอร์ AI ตลอด 24/7 บทเรียนนี้เป็นส่วนหนึ่งของเส้นทางการเรียน Data Science Academy และความก้าวหน้าของคุณจะซิงค์ข้ามเว็บและแอป CoddyKit คอร์ส Data Science Academy มีบทเรียนทั้งหมด 4 บทเรียน
บางส่วนของบทเรียนนี้ยังไม่ได้รับการแปล และแสดงเป็นภาษาอังกฤษ
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.
คำถามที่พบบ่อย
บทเรียน “ความคงที่และการหาผลต่าง” ฟรีหรือไม่
ใช่ — ข้อความเต็มของ “ความคงที่และการหาผลต่าง” ฟรีให้อ่านที่นี่บนเว็บ เพื่อปฏิบัติแบบโต้ตอบ (ตัวแก้ไขโค้ดในตัวและติวเตอร์ AI ตลอด 24/7) และปลดล็อคส่วนที่เหลือของคอร์ส Data Science Academy ให้อัปเกรดเป็น CoddyKit PRO คอร์ส Data Science Academy มีบทเรียนทั้งหมด 4 บทเรียน
คุณจะเรียนรู้อะไรในบทเรียน “ความคงที่และการหาผลต่าง”
เตรียมอนุกรมสำหรับสร้างโมเดล คุณปฏิบัติ Data Science Academy ด้วยโค้ดที่ใช้งานได้จริงที่คุณเรียกใช้โดยตรงในเบราว์เซอร์ และติวเตอร์ AI ตลอด 24/7 ตอบคำถามของคุณขณะที่คุณไปผ่านบทเรียน
คุณต้องมีประสบการณ์ก่อนที่จะเริ่มเรียน Data Science Academy หรือไม่
ไม่จำเป็นต้องมีประสบการณ์มาก่อน Data Science Academy บน CoddyKit ออกแบบมาสำหรับผู้เริ่มต้นไปจนถึงผู้เรียนขั้นสูง คุณสามารถเริ่มต้นที่นี่หรือเริ่มจากตัวแรกและเรียนด้วยความเร็วของคุณเอง นี่คือบทเรียนที่ 3 จากทั้งหมด 4 บทเรียน
บทเรียน “ความคงที่และการหาผลต่าง” ใช้เวลานานแค่ไหน
บทเรียน CoddyKit ส่วนใหญ่ใช้เวลาประมาณ 5–10 นาที แต่ละบทเรียนจึงสั้นและเป็นแบบโต้ตอบ คุณสามารถก้าวหน้าอย่างต่อเนื่องและกลับมาเรียนต่อจากตรงที่เพิ่งหยุดบนเว็บและแอปได้เลย
ฉันเขียนและรันโค้ดในบทเรียน Data Science Academy นี้ได้ไหม
ได้ บทเรียน Data Science Academy ทุกบทมีตัวแก้ไขโค้ดในตัว คุณจึงเขียนและรันโค้ดจริงได้เลยในเบราว์เซอร์ และได้รับข้อเสนอแนะจาก AI ในทันที — ไม่ต้องติดตั้งในเครื่องของคุณ
บทเรียนทั้งหมดในหลักสูตรนี้
- แนวโน้ม ฤดูกาล และสัญญาณรบกวน
- หน้าต่างเลื่อนและค่าหน่วง
- ความคงที่และการหาผลต่าง
- พื้นฐานการพยากรณ์ครั้งแรก