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

Solar Panel Dust Monitoring System

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

Solar Panel Dust Monitoring System

The current residential solar panels lack an adequate monitoring system, which hinders their optimal utilization. This research aims to design an Internet of Things (IoT) monitoring system and employ machine learning techniques to predict the current and voltage generated by solar panels. Experimental studies have revealed a correlation between dust accumulation and the current output of solar panels. The proposed system facilitates the prediction of the optimal time for cleaning solar panels.

Read more
Improving the Quality and Safety of Food Production and Services in the Canteens of KMITL.

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

Improving the Quality and Safety of Food Production and Services in the Canteens of KMITL.

The activities of the project's operations consist of: checking microbe on sample food, hygienic condition of cooker, containers and materials, sanitation knowledge and private sanitation and food quality of canteen and cleaning of cooker. The Food Safety Management program collaborated with the Property Management office, planned the operations, and assessed food vendors based on the SAN 20 food safety standards requirements. Using A.13 testing kits, we conducted testing for coliform bacteria contamination in food, containers, equipment, and hand contact surfaces, collecting 6 samples. These included samples such as prepared food, areas in front of the store, and food handlers' hands. Additionally, we used A.11 testing kits to test for coliform bacteria contamination in water and ice. The analysis of results, including physical, microbiological, and chemical aspects, serve as a guideline for improving the quality and safety of food production and service in the institution's canteen.

Read more
Wildland Fire Fighter Suit

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

Wildland Fire Fighter Suit

The forest firefighting suit consists of the following components and uses: The forest firefighting suit is designed and developed to be suitable for the behavior of the officers and the conditions of the work area, consisting of a shirt and pants. The material used in the sewing of the suit is aramid fabric, which has the property of being able to prevent the spread of fire, to prevent the officers from burning while performing their duties in the event that the forest fire spreads close to them, which is different from the current suits that cannot prevent fires. The shirt is designed with a mesh on the side of the body to release internal heat so that air can circulate well. The sleeves at the elbows have a support point to prevent contact with the ground or obstacles. The collar has a slot for a portable fan and a fan air circulation channel on the back, which can be turned on while performing forest firefighting duties, helping to prevent the body temperature from getting too hot, reducing the risk of heatstroke. When the fan battery runs out, it can be removed for charging and put back in when needed. The pants are designed with mesh on the inside or in blind spots to release internal heat so that air can circulate well. The pants at the knees have a support point to prevent contact with the ground or obstacles. The forest firefighting suit, consisting of a shirt and pants, has been designed and developed to be able to be produced domestically, reducing imports from abroad

Read more