KMITL Innovation Expo 2025 Logo

A Comparison of The Performance of Machine Learning Methods on Time Series Data Using Lagged Time Intervals

Abstract

This special problem aims to compare the performance of machine learning methods in time series forecasting using lagged time periods as independent variables. The lagged periods are categorized into three groups: lagged by 10 units, lagged by 15 units, and lagged by 20 units. The study employs four machine learning methods: Decision Tree (DT), Random Forest (RF), K-Nearest Neighbors (KNN), and Support Vector Machine (SVM). The time series data simulated as independent variables diverse including characteristics: Random Walk data, Trending data, and Non-Linear data, with sample sizes of 100, 300, 500, and 700. The research methodology involves splitting the data into 90% for training and 10% for testing. Simulations and analysis are performed using the R programming language, with 1,000 iterations conducted. The results are evaluated based on the average mean squared error (AMSE) and the average mean absolute percentage error (AMAPE) are calculated to identify the best performing method. The research findings revealed that for Random Walk data, the best performing methods are Random Forest and Support Vector Machine. For Trend data, the best performing methods are Random Forest. For Non-Linear data, the best performing methods are Support Vector Machine. When tested with real-world data, the results show that for the Euro-to-Thai Baht exchange rate, the best methods are Random Forest and Support Vector Machine. For the S&P 500 Index in USD, the best performing methods are Random Forest. For the Bank of America Corp Index in USD, the best performing methods are Support Vector Machine.

Objective

ปัจจุบันเทคโนโลยีสารสนเทศมีบทบาทสำคัญต่อการดำรงชีวิตของมนุษย์ ทำให้มีการพัฒนาเทคโนโลยีเพื่ออำนวยความสะดวกต่อการดำรงชีวิตของมนุษย์ มีแหล่งข้อมูลข่าวสารที่ทันสมัย รวมถึงแหล่งข้อมูลขนาดใหญ่ที่เรียกกว่าข้อมูลมหัต (Big Data) เป็นข้อมูลที่มีปริมาณมาก (Volume) มีความเปลี่ยนแปลงอย่างรวดเร็วอยู่ตลอดเวลา (Velocity) และมีความหลากหลายสูง (Variety) เนื่องจากคุณสมบัติเหล่านี้จัดเป็นอุปสรรคหรือปัญหาของ ข้อมูลขนาดใหญ่ที่ไม่สามารถนำข้อมูลมาใช้ประโยชน์ได้ทันทีจึงต้องมีกระบวนการจัดการข้อมูล ขนาดใหญ่เสียก่อน โดยใช้วิธีการเรียนรู้ของเครื่อง (Machine Learning) เข้ามาเกี่ยวข้อง การเรียนรู้ด้วยเครื่อง (Machine Learning) คือวิทยาการคอมพิวเตอร์ประเภทหนึ่ง เกี่ยวข้องกับการศึกษาและสร้างอัลกอริทึมที่สามารถเรียนรู้ข้อมูลและทำนายข้อมูลได้ สามารถแบ่งการเรียนรู้ของเครื่องออกเป็น 2 กลุ่มประกอบด้วย การเรียนรู้แบบไม่มีผู้สอน (Unsupervised Learning) คือการวิเคราะห์ข้อมูลที่ไม่มีตัวแปรตามหรือคำตอบกำกับไว้ มุ่งเน้นไปที่การหาความสัมพันธ์ระหว่างข้อมูลและการแบ่งกลุ่มเพื่อลดมิติของข้อมูล เช่น การวิเคราะห์แบ่งกลุ่ม (Cluster Analysis) ซึ่งได้รับความนิยมใช้เพื่อลดมิติของข้อมูลและการแบ่งกลุ่มข้อมูลด้วยคุณลักษณะต่าง ๆ และการเรียนรู้แบบมีผู้สอน (Supervised Learning) คือการวิเคราะห์ข้อมูลที่มีตัวแปรตามหรือคำตอบกำกับไว้ ถ้าตัวแปรตามเป็นเชิงปริมาณจะเป็นการพยากรณ์ข้อมูลอนุกรมเวลา (Time series) แต่ถ้าตัวแปรตามเป็นเชิงคุณภาพจะเป็นการวิเคราะห์การจำแนก (Classification) โดยเทคนิคที่นิยมใช้อย่างแพร่หลายได้แก่ การถดถอยโลจิสติกส์ (Logistic Regression) ต้นไม้ตัดสินใจ (Decision Tree) เทคนิคป่าสุ่ม (Random Forest) และโครงข่ายประสาทเทียม (Artificial Neural Network) เป็นต้น การจำแนกถูกนำมาประยุกต์ใช้ในงานวิจัยในหลายด้าน (วริทธิ์พล , 2565) ข้อมูลอนุกรมเวลา (Time Series) คือ ชุดข้อมูลที่รวบรวมและจัดเก็บตามลำดับ ต่อเนื่องกันภายใต้การเพิ่มขึ้นของเวลา โดยข้อมูลดังกล่าวจะถูกเก็บรวบรวมอย่างต่อเนื่องในระยะเวลาติดต่อกัน ตามช่วงเวลาที่ต้องการ เช่น ข้อมูลราคาทองคำ ข้อมูลปริมาณน้ำในเขื่อน ซึ่งจะถูกบันทึกข้อมูลเป็นวัน ในบางกรณี การจัดเก็บข้อมูลอาจมีลักษณะการจัดเก็บแบบเป็นช่วงเวลาต่อเนื่องกัน เพื่อสร้างตัวแบบอนุกรมเวลา (Time Series Model) ในการทำนายเหตุการณ์ที่จะเกิดขึ้นในอนาคตโดยการวิเคราะห์อนุกรมเวลา (Time Series Analysis) ในการวิเคราะห์อนุกรมเวลา ส่วนใหญ่ข้อมูลอนุกรมเวลาเป็นข้อมูลที่เยอะ ซับซ้อน และมีการเปลี่ยนแปลงอยู่ตลอดเวลา จึงทำให้ยากต่อการหาวิธีที่ดีที่สุดในการพยากรณ์ จึงได้มีการนำการเรียนรู้ด้วยเครื่องมาใช้ในการวิเคราะห์ข้อมูล เพราะ วิธีการเรียนรู้ด้วยเครื่องมีประสิทธิภาพในการวิเคราะห์ข้อมูลอนุกรมเวลามากกว่า (พรทิวา , 2564) โดยทั่วไปในการวิเคราะห์อนุกรมเวลาจะใช้ตัวแปรเพียงตัวเดียว แต่ในวิธีของการเรียนรู้ด้วยเครื่องจะมีการใช้ตัวแปรอิสระ ( ) มาช่วยในการพยากรณ์ ในการวิจัยครั้งนี้จึงสนใจนำช่วงเวลาที่ช้ากว่ากัน (Lag) ของข้อมูลอนุกรมเวลา เข้ามาเป็นตัวแปรอิสระ โดยตัวแปรตาม ( ) คือ ข้อมูลอนุกรมเวลาชุดเดิม แล้วจึงนำไปวิเคราะห์ด้วยวิธีการเรียนรู้ด้วยเครื่อง ประกอบด้วย วิธีต้นไม้ตัดสินใจ (Decision Tree) ป่าสุ่ม (Random Forest) วิธีเพื่อนบ้านใกล้เคียงสุด K อันดับ (K Nearest-Neighbor: KNN) และวิธีซัพพอร์ตเวกเตอร์แมชชีน (Support Vector Machine) โดยแต่ละวิธีจะทำการศึกษาเกี่ยวกับการวัดความถูกต้องและความผิดพลาดในการจำแนกข้อมูล Lai et al. (2023) งานวิจัยนี้เกี่ยวกับการพยากรณ์สถานการณ์ปัจจุบันของโควิด 19 โดยใช้ข้อมูลน้ำเสีย ให้ผู้ป่วยโควิด 19 เป็นตัวแปร และให้ปริมาณไวรัสในตัวอย่างน้ำเสียเป็นตัวแปร ผู้วิจัยไม่ทราบตัวแปร จึงได้ใช้วิธีช่วงเวลาที่ช้ากว่ากัน (Lag) เอามาช่วยในการพยากรณ์ตัวแปร พอทราบค่าได้นำไปพยากรณ์ด้วยวิธีการเรียนรู้ด้วยเครื่อง ประกอบไปด้วย แบบจำลองอารีแมกซ์ (Autoregressive Integrated Moving Average with Exogenous Variables : ARIMAX) และการเรียนรู้ด้วยเครื่องจากชุดข้อมูลแบบลำดับเวลา (Time Series Machine Learning : TSML) โดยเทคนิคที่ดีที่สุด คือ วิธีการเรียนรู้ด้วยเครื่องจากชุดข้อมูลแบบลำดับเวลา พรทิวา (2564) งานวิจัยนี้เกี่ยวกับระบบวิเคราะห์ข้อมูลอนุกรมเวลาด้วยเทคนิคทางการเรียนรู้ของเครื่อง โดยเปรียบเทียบวิธีพยากรณ์ออกเป็น 3 เทคนิคประกอบไปด้วยเทคนิควิเคราะห์การถดถอยพหุคูณ (Multiple Linear Regression) วิธีต้นไม้ตัดสินใจ (Decision Tree) และ วิธีป่าสุ่ม (Random Forest) โดยใช้การคัดเลือกเทคนิคที่เหมาะสมที่สุดสำหรับการพยากรณ์โดยใช้เกณฑ์ค่าเฉลี่ยของค่าสัมบูรณ์เปอร์เซ็นต์ความคลาดเคลื่อน (Mean Absolute Percentage Error, MAPE) ต่ำที่สุดผลวิจัยพบว่าการเปรียบเทียบเทคนิคระหว่างวิธีต้นไม้ตัดสินใจ วิธีป่าไม้สุ่ม และ การถดถอยพหุคูณ สำหรับการพยากรณ์ยอดขายรวมรายวันแยกตามรายสินค้าและจำนวนผู้เสียชีวิตรายใหม่จาก สถานการณ์ COVID-19 ในประเทศไทยพบว่าเทคนิคให้ค่า MAPE เฉลี่ยต่ำที่สุดคือ เทคนิคป่าสุ่ม Kayode-Ajala. (2022) งานวิจัยนี้เกี่ยวกับการประยุกต์ใช้อัลกอริทึมการเรียนรู้ของเครื่อง ในการตรวจจับเว็บไซต์ที่เป็นแฟร์ชิ่ง ซึ่งใช้วิธีการเรียนรู้ด้วยเครื่องประกอบด้วย วิธีซัพพอร์ตเวกเตอร์แมชชีน (Support Vector Machine) วิธีเพื่อนบ้านใกล้เคียงสุด K อันดับ (K Nearest-Neighbor: KNN) วิธีต้นไม้ตัดสินใจ (Decision Trees) และ วิธีป่าสุ่ม (Random Forest) ซึ่งวิธีที่ดีที่สุดคือ วิธีเพื่อนบ้านใกล้เคียงสุด K อันดับ Ballı (2021) งานวิจัยนี้เกี่ยวกับการวิเคราะห์ข้อมูลของการระบาดโควิด-19 และการพยากรณ์จำนวนผู้ติดเชื้อรวมในระยะสั้นๆ โดยใช้เทคนิคการเรียนรู้ด้วยเครื่องประกอบวิธีการถดถอยเชิงเส้น (Linear regression) วิธีโครงข่ายประสาทเทียมแบบเพอร์เซ็ปตรอนหลายชั้น (multi-layer perceptron) วิธีป่าสุ่ม (random forest) วิธีนาอีฟ เบย์ (Naive Bayes) และ วิธีซัพพอร์ตเวกเตอร์แมชชีน (Support Vector Machine) พบว่าเทคนิคให้ค่า MAPE เฉลี่ยต่ำที่สุดคือ วิธีซัพพอร์ตเวกเตอร์แมชชีน Bemthuis et al. (2023) งานวิจัยนี้เกี่ยวกับระบบสนับสนุนการตัดสินใจ (Decision Support Systems) กำลังพัฒนาไปในทิศทางที่ซับซ้อนมากขึ้น โดยมุ่งหวังที่จะทำให้การตัดสินใจเป็นไปโดยอัตโนมัติมากที่สุด จึงวิธีการที่ใช้เทคนิคการจำแนกประเภทด้วยต้นไม้การตัดสินใจ และเปรียบเทียบประสิทธิภาพกับผลลัพธ์ที่ได้จากการใช้เทคนิคสนับสนุนเวกเตอร์แมชชีน การทดลองของเราพบว่า วิธีการของเรามีความแม่นยำและความยืดหยุ่นในด้านการดึงกฎทางธุรกิจ ต้นไม้การตัดสินใจ จากการศึกษางานวิจัยที่เกี่ยวข้องทางผู้วิจัยจึงสนใจศึกษาการเปรียบเทียบประสิทธิภาพของวิธีการเรียนรู้ด้วยเครื่องจากข้อมูลอนุกรมเวลา โดยวิธีการช่วงเวลาที่ช้ากว่ากัน ซึ่งประกอบไปด้วยวิธีต้นไม้ตัดสินใจ (Decision Tree) วิธีป่าสุ่ม (Random Forest) วิธีเพื่อนบ้านใกล้เคียงสุด K อันดับ (K Nearest-Neighbor: KNN) และวิธีซัพพอร์ตเวกเตอร์แมชชีน (Support Vector Machine) โดยพิจารณาค่าเฉลี่ยของค่าคาดเคลื่อนกำลังสองเฉลี่ย (Mean Square Error: AMSE) และค่าเฉลี่ยของค่าเฉลี่ยเปอร์เซ็นต์ความคลาดเคลื่อนสัมบูรณ์ (Mean Absolute Percentage Error: AMAPE) เป็นเกณฑ์ในการวัดประสิทธิภาพของแบบจำลอง และเป็นแนวทางการในการเปรียบเทียบประสิทธิภาพด้วยวิธีการเรียนรู้ด้วยเครื่อง เพื่อตัดสินใจในการเลือกแบบจำลองที่ดีที่สุด

Other Innovations

Chillhouse with ChillGuys

คณะสถาปัตยกรรม ศิลปะและการออกแบบ

Chillhouse with ChillGuys

This project aims to study the load transfer in timber building structures by analyzing weight distribution across key structural components such as beams, columns, and floors, as well as the load-bearing behavior of wood under different conditions. The research incorporates structural calculations and modeling to examine load transfer patterns. Additionally, it enhances skills in design, analysis, and teamwork, providing practical knowledge applicable to real-world construction projects.

Read more
Characteristics and nutrition values of cereal bar fortified with Asian sea bass bone bio-calcium powder.

คณะอุตสาหกรรมอาหาร

Characteristics and nutrition values of cereal bar fortified with Asian sea bass bone bio-calcium powder.

Bio-calcium powders were extracted from Asian sea bass bone by heat-treated alkaline with fat removal and bleaching supplementary method. Cereal bars (CBs) were fortified with produced bio-calcium at 3 levels: (1) increased calcium (IS-Ca; calcium ≥10% Thai RDI), (2) good source of calcium (GS-Ca; calcium ≥15% Thai RDI), and (3) high calcium (H-Ca; calcium ≥30% Thai RDI) which were consistent with the notification of the Ministry of Public Health, Thailand: No. 445; Nutrition claim issued in B.E. 2023. Moisture content, water activity, color, calcium content and FTIR analysis of bio-calcium powders were measured. Dimension, color, water activity, pH and texture of fortified CBs were determined. Produced bio-calcium could be classified as a dried food with light yellow-white color. Calcium contents in bio-calcium powder was 23.4% (w/w). Dimension, weight and color except b* and ΔE* values of fortified CBs were not different (P > 0.05) from those of the control. Fortifying of bio-calcium resulted in harder texture CBs. An increase of fortified bio-calcium amounts decreased carbohydrate and fat but increased of protein, ash and calcium in the fortified CBs. Shelf life of CBs was to be shorten by fortification of bio-calcium powder because of the increment of moisture, water activity and pH. Yield of bio-calcium production was 40.30%. Production cost of bio-calcium was approximately 7,416 Bth/kg while cost of fortified CBs increased almost 2-3 times compared to the control. Calcium contents in IS-Ca (921.12 mg/100g), GS-Ca (1,287.10 mg/100g) and H-Ca (2,639.70 mg/100g) cereal bars could be claimed as increased calcium, good source of calcium and high calcium, respectively. In conclusion, production of cereal bar fortified with Asian sea bass bone bio-calcium powder as a fortified food was possible. However, checking the remained hazardous reagents in bio-calcium powder must be carried out before using in food products and analysis of calcium bioavailability, sensory acceptance and shelf life of the developed products should be determined in further studies.

Read more
Botanical Hand Care: Nourish and Protect with Murraya Extract

คณะวิทยาศาสตร์

Botanical Hand Care: Nourish and Protect with Murraya Extract

Development of Hand Cream from Murraya Extract Using an Eco-Friendly Extraction Process. This research focuses on extracting active compounds from Murraya paniculata using a water-based, environmentally friendly method. The extract exhibits outstanding antibacterial properties and anti-oxidant. It is incorporated into a hand cream formulation.

Read more