(Luận văn thạc sĩ hcmute) ứng dụng mạng neuron để dự báo mưa với cơ sở dữ liệu được thu thập trong khu vực triển khai mạng cảm biến không dây

107 2 0
(Luận văn thạc sĩ hcmute) ứng dụng mạng neuron để dự báo mưa với cơ sở dữ liệu được thu thập trong khu vực triển khai mạng cảm biến không dây

Đang tải... (xem toàn văn)

Tài liệu hạn chế xem trước, để xem đầy đủ mời bạn chọn Tải xuống

Thông tin tài liệu

BỘ GIÁO DỤC VÀ ĐÀO TẠO TRƯỜNG ĐẠI HỌC SƯ PHẠM KỸ THUẬT THÀNH PHỐ HỒ CHÍ MINH LUẬN VĂN THẠC SĨ DƯƠNG CAO TRỌNG NHÂN ỨNG DỤNG MẠNG NEURON ĐỂ DỰ BÁO MƯA VỚI CƠ SỞ DỮ LIỆU ĐƯỢC THU THẬP TRONG KHU VỰC TRIỂN KHAI MẠNG CẢM BIẾN KHÔNG DÂY NGÀNH: KỸ THUẬT ĐIỆN TỬ - 60520203 S K C0 Tp Hồ Chí Minh, tháng 09/2020 Luan van BỘ GIÁO DỤC VÀ ĐÀO TẠO TRƯỜNG ĐẠI HỌC SƯ PHẠM KỸ THUẬT THÀNH PHỐ HỒ CHÍ MINH LUẬN VĂN THẠC SĨ DƯƠNG CAO TRỌNG NHÂN ỨNG DỤNG MẠNG NEURON ĐỂ DỰ BÁO MƯA VỚI CƠ SỞ DỮ LIỆU ĐƯỢC THU THẬP TRONG KHU VỰC TRIỂN KHAI MẠNG CẢM BIẾN KHÔNG DÂY NGÀNH: KỸ THUẬT ĐIỆN TỬ - 60520203 Tp Hồ Chí Minh Tháng Năm 2020 Luan van BỘ GIÁO DỤC VÀ ĐÀO TẠO TRƯỜNG ĐẠI HỌC SƯ PHẠM KỸ THUẬT THÀNH PHỐ HỒ CHÍ MINH LUẬN VĂN THẠC SĨ DƯƠNG CAO TRỌNG NHÂN ỨNG DỤNG MẠNG NEURON ĐỂ DỰ BÁO MƯA VỚI CƠ SỞ DỮ LIỆU ĐƯỢC THU THẬP TRONG KHU VỰC TRIỂN KHAI MẠNG CẢM BIẾN KHÔNG DÂY NGÀNH: KỸ THUẬT ĐIỆN TỬ - 60520203 Hướng dẫn khoa học: PGS.TS VÕ MINH HUÂN Tp Hồ Chí Minh Tháng Năm 2020 Luan van i Luan van ii Luan van iii Luan van iv Luan van v Luan van vi Luan van LÝ LỊCH KHOA HỌC I LÝ LỊCH SƠ LƯỢC: Họ & tên: Dương Cao Trọng Nhân Giới tính: Nam Ngày, tháng, năm sinh: 09/01/1995 Nơi sinh: TP HCM Quê quán: Trà Vinh Dân tộc: Kinh Chỗ riêng địa liên lạc: 131 Xuân Hồng, Phường 12, Quận Tân Bình, Thành Phố Hồ Chí Minh Điện thoại quan: Điện thoại nhà riêng: 0902795763 E-mail: duongcaotrongnhan95@gmail.com II QUÁ TRÌNH ĐÀO TẠO: Đại học: Hệ đào tạo: Chính quy Thời gian đào tạo từ 09/2013 đến 09/2017 Nơi học (trường, thành phố): Đại học Sư Phạm Kỹ Thuật Thành phố Hồ Chí Minh Ngành học: Cơng nghệ kĩ thuật điện tử truyền thông Tên đồ án, luận án môn thi tốt nghiệp: Điều khiển thiết bị sử dụng sóng não Ngày & nơi bảo vệ đồ án, luận án thi tốt nghiệp: 13/02/2017 Rajamangala University of Technology Lanna Người hướng dẫn: Dr Nopadon Maneetien vii Luan van mẫu học Khi đó, nên xem xét đến khả sử dụng thêm lớp ẩn với số nơron nhỏ giảm bớt số nơron lớp ẩn thứ Đánh giá hệ thống 4.7.1 Ưu điểm - Hệ thống có mức tiêu thụ lượng thấp - Xây dựng hệ thống truyền nhận công nghệ Zigbee với nhiều nút cảm biến đặt nhiều khoảng cách xa - Hệ thống thu thập lưu trữ thông số môi trường diễn ổn định - Khối cảm biến có khả mở rộng phạm vi số cảm biến - Có khả cập nhật dự báo thời tiết tức thời 4.7.2 Nhược điểm - Vì hệ thống dự báo thời tiết nên ln đặt ngồi trời, thời tiết xấu mưa to, gió lớn làm hỏng hệ thống dẫn đến làm gián đoạn việc lấy liệu từ cảm biến - Thông số liệu huấn luyện thu thập chưa nhiều, chưa đủ đặc trưng nên số trường hợp dự báo sai 70 Luan van Chương 5: KẾT LUẬN Kết luận 5.1.1 Kết đạt Xây dựng mơ hình thu thập liệu ổn định, tiêu tốn lượng điểm thu thập hoạt động nhiều khu vực khác Xây dựng thành công hệ thống dự báo thời tiết thuật toán máy học áp dụng vấn đề lý thuyết tìm hiểu mơ hình thu thập liệu khơng dây, mạng nơron truyền thẳng nhiều lớp, thuật toán lan truyền ngược bước cần thực phân tích, thiết kế xây dựng ứng dụng cho toán dự báo thời tiết Thuật toán để dự đoán kiện mưa thông số thời tiết đáp ứng yêu cầu đặt ra, dự đoán với độ xác cao Các thực nghiệm cho thấy, huấn luyện tốt tập liệu đầy đủ hoàn thiện với tham số lựa chọn cẩn thận kết dự báo đạt độ xác cao Luận văn có nghiên cứu để thực nghiệm dự báo thông số thu thập với mơ hình thuật tốn khác như: Logistic Regression, Naive Bayes, K-Nearest Neighbor, Decision Tree, Random Forest, Support Vector Machine Đồng thời, so sánh hiệu khả dự báo mơ hình thuật tốn với mơ hình mạng nơron nhân tạo nhiều lớp sử dụng thuật toán lan truyền ngược mà học viên đề xuất cho hệ thống luận văn 5.1.2 Hạn chế Với thời gian có hạn, liệu huấn luyện thu thập chưa nhiều, chưa đủ đặc trưng nên mơ hình đưa kết thời điểm mùa ý nghĩa lớn thực tiễn, lúc giao mùa phải huấn luyện lại mạng Để mơ hình dự báo thu kết cao tập liệu huấn luyện phải lớn, phải đặc trưng cho mùa 71 Luan van Hệ thống đôi lúc truyền nhận chưa ổn định, số thời điểm thông số từ nút cảm biến gửi đến xử lý trung tâm thông số lỗi Hướng phát triển Trong tương lai, học viên tiếp tục nghiên cứu sâu rộng mạng nơron nhân tạo Kết hợp lai ghép mạng nơron nhân tạo với phương pháp khác để tối ưu khả tiên đoán mạng nơron nhân tạo nhằm hướng tới việc áp dụng mạng nơron vào dự báo vấn đề thực tế Mở rộng phạm vi thu thập liệu cách gia tăng số lượng khối cảm biến nhiều khu vực với khoảng cách lớn hơn, đồng thời tích hợp mạch pin để tiết kiệm lượng Cải thiện khả dự đoán với tập liệu lớn Mở rộng thời gian thu thập liệu thu thập thêm nhiều thông số môi trường khác để tăng khả tổng qt hóa mơ hình dự báo đa dạng yếu tố đầu vào với nhiều liệu thời tiết diễn thời điểm năm Hệ thống tích hợp chức cảnh báo cố, ghi nhận thay đổi bất thường xảy hệ thống máy chủ 72 Luan van Tài Liệu Tham Khảo [1] Tác động biến đổi khí hậu đến tự nhiên xã hội Internet: Tác động biến đổi khí hậu đến tự nhiên xã hội (quangnam.gov.vn), 12/06/2018 [2] Cảnh báo thời tiết cực đoan ảnh hưởng đến sản xuất nông nghiệp Internet: Cảnh báo thời tiết cực đoan ảnh hưởng đến sản xuất nông nghiệp (nongdan.com.vn), 15/02/2019 [3] Tăng liệu thời tiết nông nghiệp, giảm rủi ro biến đổi khí hậu Internet: Tăng liệu thời tiết nông nghiệp,giảm rủi ro biến đổi khí hậu | baotintuc.vn, 20/08/2017 [4] Các phương pháp dự báo thời tiết hàng không Việt Nam Internet: Các phương pháp dự báo thời tiết hàng không Việt Nam (vatm.vn), 20/09/2018 [5] S Ray A Quick Review of Machine Learning Algorithms 2019 International Conference on Machine Learning, Big Data, Cloud and Parallel Computing (COMITCon), 2019, pp 35-39 [6] T Truong, A Dinh and K Wahid An IoT environmental data collection system for fungal detection in crop fields, 2017 IEEE 30th Canadian Conference on Electrical and Computer Engineering (CCECE), 2017, pp 1-4 [7] J K Roy, D Gupta and S Goswami An improved flood warning system using WSN and Artificial Neural Network 2012 Annual IEEE India Conference, 2012, pp 770-774 [8] Mohsen Hayati, Zahra Mohebi Application of Artificial Neural Networks for Temperature Forecasting World Academy of Science, Engineering and Technology, Vol 4, Issue 1, pp 662-666, 2007 73 Luan van [9] L P Dinesh Kumar, S Shakena Grace, A Krishnan, V M Manikandan, R Chinraj and M R Sumalatha Data filtering in wireless sensor networks using neural networks for storage in cloud, 2012 International Conference on Recent Trends in Information Technology, 2012, pp 202-205 [10] Trịnh Lương Miên Tổng quan mạng cảm biến khơng dây Tạp chí tự động hóa ngày nay, số 157, tr 1-2, 2014 [11] Ian F Akyildiz and Mehmet Can Vuran Wireless Sensor Network John Wiley & Sons Ltd, 2010, pp 10-15 [12] Jose A Gutierrez; Edgar H Callaway; Raymond L Barrett IEEE Std 802.15.4 Technical Overview Low-Rate Wireless Personal Area Networks: Enabling Wireless Sensors with IEEE 802.15.4, 2007 [13] C M Ramya, M Shanmugaraj and R Prabakaran Study on ZigBee technology 2011 3rd International Conference on Electronics Computer Technology, 2011, pp 297-301 [14] M Hasan, P Biswas, M T I Bilash and M A Z Dipto Smart Home Systems: Overview and Comparative Analysis 2018 Fourth International Conference on Research in Computational Intelligence and Communication Networks (ICRCICN), 2018, pp 264-268 [15] Tạ Quốc Dũng, Lê Thế Hà, Phạm Duy Khang Ứng dụng mạng Neural nhân tạo dự báo độ rỗng Tạp chí dầu khí, số 7, tr 18-27, 2019 [16] A Sperduti An overview on supervised neural networks for structure Proceedings of International Conference on Neural Networks, 1997, pp 2550-2554 [17] M Chen, U Challita, W Saad, C Yin and M Debbah Artificial Neural Networks-Based Machine Learning for Wireless Networks: A Tutorial IEEE Communications Surveys & Tutorials, vol 21, no 4, pp 3039-3071, 2019 74 Luan van [18] C Bircanoğlu and N Arıca A comparison of activation functions in artificial neural networks 2018 26th Signal Processing and Communications Applications Conference (SIU), 2018, pp 1-4 [19] M Verhelst and B Moons, Embedded Deep Neural Network Processing: Algorithmic and Processor Techniques Bring Deep Learning to IoT and Edge Devices IEEE Solid-State Circuits Magazine, vol 9, no 4, pp 55-65, Fall 2017 [20] I R Widiasari, L E Nugroho and Widyawan Deep learning multilayer perceptron (MLP) for flood prediction model using wireless sensor network based hydrology time series data mining 2017 International Conference on Innovative and Creative Information Technology (ICITech), 2017, pp 1-5 [21] A J Smola B Schölkopf A tutorial on support vector regression Statistics and Computing, tập 14, số 3, pp 199-222, 2004 [22] S Nurunnahar, D B Talukdar, R I Rasel and N Sultana A short term wind speed forcasting using SVR and BP-ANN: A comparative analysis 2017 20th International Conference of Computer and Information Technology (ICCIT), 2017, pp 1-6 [23] M Muthmainnah, M Ashar, I M Wirawan and T Widiyaningtyas Time Series Forecast for Rainfall Intensity in Malang City with Naive Bayes Methodology 2018 International Conference on Sustainable Information Engineering and Technology (SIET), 2018, pp 137-14 [24] A Geetha and G M Nasira.Data mining for meteorological applications: Decision trees for modeling rainfall prediction 2014 IEEE International Conference on Computational Intelligence and Computing Research, 2014, pp 1-4 [25] S C Sreenivasa, S K Agarwal and R Kumar Short term wind forecasting using logistic regression driven hypothesis in artificial neural network 2014 6th IEEE Power India International Conference (PIICON), 2014, pp 1-6 75 Luan van [26] Z Liu and Z Zhang Solar forecasting by K-Nearest Neighbors method with weather classification and physical model 2016 North American Power Symposium (NAPS), 2016, pp 1-6 [27] Y Liu and H Wu Prediction of Road Traffic Congestion Based on Random Forest 2017 10th International Symposium on Computational Intelligence and Design (ISCID), 2017, pp 361-364 76 Luan van Phụ Lục A Source code Neural Network Chương trình viết ngơn ngữ python biên dịch phần mềm biên dịch Visual Studio Code: """ @author: Duong Cao Trong Nhan """ # Thêm thư viện import numpy as np import pandas as pd import json import matplotlib.pyplot as plt from sklearn.metrics import mean_absolute_error, mean_squared_error # Hàm lỗi def mean_absolute_percentage_error(y_true, y_pred): y_true, y_pred = np.array(y_true), np.array(y_pred) return np.mean(np.abs((y_true - y_pred) / y_true)) * 100 def root_mean_squared_error(y_true, y_pred): mean = mean_squared_error(y_true, y_pred) return np.sqrt(mean) # Hàm sigmoid def sigmoid(x): return 1/(1+np.exp(-x)) # Đạo hàm hàm sigmoid def sigmoid_derivative(x): return x*(1-x) # Lớp neural network class NeuralNetwork: def init (self, layers, alpha=0.1): # Mô hình layer ví dụ [2,2,1] self.layers = layers 77 Luan van # Hệ số learning rate self.alpha = alpha # Tham số W, b self.W = [] self.b = [] # Khởi tạo tham số layer for i in range(0, len(layers)-1): w_ = np.random.randn(layers[i], layers[i+1]) b_ = np.zeros((layers[i+1], 1)) self.W.append(w_/layers[i]) self.b.append(b_) # Tóm tắt mơ hình neural network def repr (self): return "Neural network [{}]".format("".join(str(l) for l in self.layers)) # Train mơ hình với liệu def fit_partial(self, x, y): A = [x] # trình feedforward out = A[-1] for i in range(0, len(self.layers) - 1): out = sigmoid(np.dot(out, self.W[i]) + (self.b[i].T)) A.append(out) # trình backpropagation y = y.reshape(-1, 1) dA = [-(y/A[-1] - (1-y)/(1-A[-1]))] dW = [] db = [] for i in reversed(range(0, len(self.layers)-1)): dw_ = np.dot((A[i]).T, dA[-1] * sigmoid_derivative(A[i+1])) db_ = (np.sum(dA[-1] * sigmoid_derivative(A[i+1]), 0)).reshape(1,1) dA_ = np.dot(dA[-1] * sigmoid_derivative(A[i+1]), self.W[i].T) dW.append(dw_) db.append(db_) dA.append(dA_) # Đảo ngược dW, db 78 Luan van dW = dW[::-1] db = db[::-1] # Gradient descent for i in range(0, len(self.layers)-1): self.W[i] = self.W[i] - self.alpha * dW[i] self.b[i] = self.b[i] - self.alpha * db[i] def fit(self, X, y, epochs=20, verbose=10): error = np.zeros((1, epochs)) epoch_train = np.zeros((1, epochs)) out_put = np.zeros((1, epochs)) for epoch in range(0, epochs): self.fit_partial(X, y) if epoch % verbose == 0: loss = self.calculate_loss(X, y) print("Epoch {}, loss {}".format(epoch, loss)) error[0,epoch] = float(loss) epoch_train[0,epoch] = int(epoch) out_put[0,epoch] = self.predict(X) return error, epoch_train, out_put # Dự đoán def predict(self, X): for i in range(0, len(self.layers) - 1): X = sigmoid(np.dot(X, self.W[i]) + (self.b[i].T)) return X # Tính loss function def calculate_loss(self, X, y): y_predict = self.predict(X) #return np.sum((y_predict-y)**2)/2 return -(np.sum(y*np.log(y_predict) + (1-y)*np.log(1-y_predict))) #============= Input Data from csv =============== data_csv= pd.read_csv('weatherdata.csv') len_csv = for i in range(len(data_csv)): if data_csv.loc[i,"Precipitation"]> 0: len_csv += Weather_csv = np.zeros((1, len_csv)) print ("Weather_csv", Weather_csv) Temp = [] Humi = [] 79 Luan van j = for i in range(len(data_csv)): if data_csv.loc[i,"Precipitation"]> 0: Weather_csv[0,j] = data_csv.loc[i,"Temperature"] j += Weather_csv[0,j] = data_csv.loc[i,"Humidity"] j += Temp.append(data_csv.loc[i,"Temperature"]) Humi.append(data_csv.loc[i,"Humidity"]) print ("Weather_csv_update", Weather_csv) Max_temp_csv = max(Temp) Min_temp_csv = min(Temp) Max_humi_csv = max(Humi) Min_humi_csv = min(Humi) X = Weather_csv #X = np.array([[80,90,100,98]]) y = np.array([[1]]) print ("XXX",X) print ("yyy",y) #======================== Tranning Json ================ p = NeuralNetwork([len_csv, 100, 1], 0.1) loss, epoch, out_put = p.fit(X, y, 100, 10) print ("error",loss) print ("epoch_train",epoch) print("out put of each loop", out_put) #======================== Final output ================ print("output:",p.predict(X)) #======================== Error ================ mae_predict = mean_absolute_error(y, p.predict(X)) mse_predict = mean_squared_error(y, p.predict(X)) mape_predict = mean_absolute_percentage_error(y, p.predict(X)) rmse_predict = root_mean_squared_error(y, p.predict(X)) print('MSE Predict = %f' % mse_predict) print('MAE Predict = %f' % mae_predict) print('MAPE Predict = %f' % mape_predict) print('RMSE Predict = %f' % rmse_predict) #============= Input Data from json =============== with open('db_sensorTest.json', 'r') as myfile: data = json.load(myfile) len_temp = len_humi = 80 Luan van for data_json in data: if (data_json['Name'] == "DQSMART02028327F5_temp" or data_json['Name'] == "DQSMART-02025CE097_temp"): len_temp += elif (data_json['Name'] == "DQSMART02028327F5_humi" or data_json['Name'] == "DQSMART-02025CE097_humi"): len_humi += Weather = np.zeros((1, len_temp + len_humi)) print ("Len Weather",len_temp + len_humi) print ("Weather", Weather) i = for data_json in data: if (data_json['Name'] == "DQSMART02028327F5_temp" or data_json['Name'] == "DQSMART-02025CE097_temp"): if (Min_temp_csv < int(data_json['Temp']) < Max_temp_csv): Weather[0,i] = int(data_json['Temp']) i += # continue else: Weather[0,i] = int((Min_temp_csv + Max_temp_csv)/2) i += # continue elif (data_json['Name'] == "DQSMART02028327F5_humi" or data_json['Name'] == "DQSMART-02025CE097_humi"): if (Min_humi_csv < int(data_json['Humi']) < Max_humi_csv): Weather[0,i] = int(data_json['Humi']) i += # continue else: Weather[0,i] = int((Min_humi_csv + Max_humi_csv)/2) i += # continue print ("Weather_update", Weather) print ("i", i) X = Weather #X = np.array([[80,90,100,98]]) y = np.array([[1]]) print ("XXX",X) print ("yyy",y) #======================== Tranning Json ================ p = NeuralNetwork([len_temp + len_humi, 100, 1], 0.1) 81 Luan van loss, epoch, out_put = p.fit(X, y, 100, 10) print ("error",loss) print ("epoch_train",epoch) print("out put of each loop", out_put) #======================== Final output ================ print("output:",p.predict(X)) #======================== Error ================ mae_predict = mean_absolute_error(y, p.predict(X)) mse_predict = mean_squared_error(y, p.predict(X)) mape_predict = mean_absolute_percentage_error(y, p.predict(X)) rmse_predict = root_mean_squared_error(y, p.predict(X)) print('MSE Predict = %f' % mse_predict) print('MAE Predict = %f' % mae_predict) print('MAPE Predict = %f' % mape_predict) print('RMSE Predict = %f' % rmse_predict) #============================Testing ===================== with open('file-json.json', 'r') as myfile: data = json.load(myfile) Weather_test = np.zeros((1, len_temp + len_humi)) print ("Len Weather test",len_temp + len_humi) print ("Weather test", Weather_test) i = for data_json in data: if i > len_temp + len_humi: break else: if (data_json['Name'] == "DQSMART02028327F5_temp" or data_json['Name'] == "DQSMART02025CE097_temp") and (Min_temp_csv < int(data_json['Temp']) < Max_temp_csv) : Weather_test[0,i] = int(data_json['Temp']) i += continue if (data_json['Name'] == "DQSMART02028327F5_humi" or data_json['Name'] == "DQSMART02025CE097_humi") and (Min_humi_csv < int(data_json['Humi']) < Max_humi_csv) : Weather_test[0,i] = int(data_json['Humi']) i += continue 82 Luan van print ("Weather_test_update", Weather_test) test = Weather_test print("predict:",p.predict(test)) #====================== Picture ====================== plt.plot(epoch[0],loss[0], 'b-', lw=2, label='Loss') plt.xlabel('Epoch') plt.ylabel('Loss') plt.title('Cross Entropy Loss') plt.legend() plt.show() plt.plot(epoch[0],out_put[0], 'r-', lw=2, label='Output') plt.xlabel('Epoch') plt.ylabel('Output') plt.title('Neural network trainning') plt.legend() plt.show() 83 Luan van Luan van ... PHẠM KỸ THU? ??T THÀNH PHỐ HỒ CHÍ MINH LUẬN VĂN THẠC SĨ DƯƠNG CAO TRỌNG NHÂN ỨNG DỤNG MẠNG NEURON ĐỂ DỰ BÁO MƯA VỚI CƠ SỞ DỮ LIỆU ĐƯỢC THU THẬP TRONG KHU VỰC TRIỂN KHAI MẠNG CẢM BIẾN KHÔNG DÂY NGÀNH:... THẠC SĨ DƯƠNG CAO TRỌNG NHÂN ỨNG DỤNG MẠNG NEURON ĐỂ DỰ BÁO MƯA VỚI CƠ SỞ DỮ LIỆU ĐƯỢC THU THẬP TRONG KHU VỰC TRIỂN KHAI MẠNG CẢM BIẾN KHÔNG DÂY NGÀNH: KỸ THU? ??T ĐIỆN TỬ - 60520203 Hướng dẫn khoa... luận văn thiết kế hệ thống dự báo mưa dựa mạng nơron nhân tạo kết hợp với mạng cảm biến không dây Mạng nơron nhân tạo xử lý thông số môi trường thu thập từ mạng cảm biến để đưa dự báo kiện mưa

Ngày đăng: 02/02/2023, 10:03

Tài liệu cùng người dùng

Tài liệu liên quan