{"id":1679,"date":"2024-12-02T07:48:00","date_gmt":"2024-12-01T23:48:00","guid":{"rendered":"https:\/\/blog.laoyulaoyu.top\/?p=1679"},"modified":"2024-11-08T20:38:06","modified_gmt":"2024-11-08T12:38:06","slug":"%e9%9c%87%e6%83%8a%e9%87%91%e8%9e%8d%e7%95%8c%ef%bc%81%e4%b8%89%e5%a4%a7%e6%b7%b1%e5%ba%a6%e5%ad%a6%e4%b9%a0%e6%a8%a1%e5%9e%8b%e8%81%94%e8%a2%82%ef%bc%8c%e7%ab%9f%e5%88%9b%e5%87%ba66941-5%e9%80%86","status":"publish","type":"post","link":"https:\/\/www.laoyulaoyu.com\/index.php\/2024\/12\/02\/%e9%9c%87%e6%83%8a%e9%87%91%e8%9e%8d%e7%95%8c%ef%bc%81%e4%b8%89%e5%a4%a7%e6%b7%b1%e5%ba%a6%e5%ad%a6%e4%b9%a0%e6%a8%a1%e5%9e%8b%e8%81%94%e8%a2%82%ef%bc%8c%e7%ab%9f%e5%88%9b%e5%87%ba66941-5%e9%80%86\/","title":{"rendered":"\u9707\u60ca\u91d1\u878d\u754c\uff01\u4e09\u5927\u6df1\u5ea6\u5b66\u4e60\u6a21\u578b\u8054\u8882\uff0c\u7adf\u521b\u51fa66,941.5%\u9006\u5929\u56de\u62a5\u7387\uff01"},"content":{"rendered":"\n<p>\u4f5c\u8005\uff1a<a href=\"https:\/\/www.laoyulaoyu.com\/\" target=\"_blank\" rel=\"noreferrer noopener\">\u8001\u4f59\u635e\u9c7c<\/a><\/p>\n\n\n\n<p><strong><mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-cyan-bluish-gray-color\">\u539f\u521b\u4e0d\u6613\uff0c\u8f6c\u8f7d\u8bf7\u6807\u660e\u51fa\u5904\u53ca\u539f\u4f5c\u8005\u3002<\/mark><\/strong><\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img decoding=\"async\" src=\"https:\/\/www.laoyulaoyu.com\/wp-content\/uploads\/2024\/11\/110702.png\" alt=\"\" class=\"wp-image-2847\"\/><\/figure>\n\n\n\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\">\n<pre class=\"wp-block-verse\"><strong>\u5199\u5728\u524d\u9762\u7684\u8bdd\uff1a<\/strong>\u4e24\u4e2a\u6708\u524d\uff0c\u6211\u66fe\u5199\u8fc7\u4e00\u7bc7\u300a<a href=\"https:\/\/blog.laoyulaoyu.top\/index.php\/2024\/09\/05\/%e4%bd%bf%e7%94%a8%e5%a0%86%e5%8f%a0-lstm-%e6%a8%a1%e5%9e%8b%e9%a2%84%e6%b5%8b%e5%b8%82%e5%9c%ba%e8%b6%8b%e5%8a%bf\/\" data-type=\"post\" data-id=\"1670\" target=\"_blank\" rel=\"noreferrer noopener\">\u4f7f\u7528\u5806\u53e0 LSTM \u6a21\u578b\u9884\u6d4b\u5e02\u573a\u8d8b\u52bf<\/a>\u300b\uff0c\u867d\u7136\u56de\u6d4b\u7ed3\u679c\u4ec5\u7b97\u5f97\u4e0a\u662f\u5dee\u5f3a\u4eba\u610f\uff0c\u4f46\u5728\u8fd9\u4e0d\u65ad\u5c1d\u8bd5\u7684\u8fc7\u7a0b\u4e2d\uff0c\u6211\u53d1\u73b0\u4e86\u4e00\u79cd\u201cbuff\u53e0\u52a0\u201d\u7b56\u7565\uff0c\u7adf\u7136\u6536\u83b7\u4e86\u8fde\u6211\u81ea\u5df1\u90fd\u96be\u4ee5\u7f6e\u4fe1\u7684\u9006\u5929\u56de\u6d4b\u6210\u7ee9\u3002\u5c3d\u7ba1\u77e5\u9053\u8fd9\u4e00\u65b9\u6cd5\u5c1a\u672a\u5b8c\u5168\u6210\u719f\uff0c\u4f46\u6211\u5b9e\u5728\u6309\u637a\u4e0d\u4f4f\u5206\u4eab\u7684\u51b2\u52a8\uff0c\u60f3\u628a\u8fd9\u4e2a\u5199\u6210\u6587\u7ae0\u5206\u4eab\u7ed9\u5927\u5bb6\u3002\u63a5\u4e0b\u6765\u6211\u5c31\u4f1a\u4ecb\u7ecd\u5982\u4f55\u5c06\u5377\u79ef\u795e\u7ecf\u7f51\u7edc\uff08CNN\uff09\u3001\u957f\u77ed\u671f\u8bb0\u5fc6\u7f51\u7edc\uff08LSTM\uff09\u4ee5\u53ca\u65f6\u95f4\u5377\u79ef\u7f51\u7edc\uff08TCN\uff09\u8fd9<mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-vivid-cyan-blue-color\">\u4e09\u5927\u6df1\u5ea6\u5b66\u4e60\u5229\u5668\u878d\u5408\u4e3a\u4e00\uff0c\u5e94\u7528\u4e8e\u91d1\u878d\u65f6\u95f4\u5e8f\u5217\u6570\u636e\u7684\u4ea4\u6613\u7b56\u7565\u3002\u8fd9\u4e00\u7b56\u7565\u4e0d\u4ec5\u6253\u7834\u4e86\u4f20\u7edf\u4ea4\u6613\u7684\u754c\u9650\uff0c\u66f4\u662f\u5b9e\u73b0\u4e86\u8db3\u4ee5\u8ba9\u6574\u4e2a\u4e1a\u754c\u4f1a\u4e3a\u4e4b\u4fa7\u76ee\u768466,941.5%\u5047\u8bbe\u56de\u62a5\u7387\uff01<\/mark><\/pre>\n<\/blockquote>\n\n\n\n<p>\u80a1\u7968\u4ef7\u683c\u3001\u8d27\u5e01\u4ef7\u503c\u6216\u52a0\u5bc6\u8d27\u5e01\u6570\u636e\u7b49\u65f6\u95f4\u5e8f\u5217\u6570\u636e\u672c\u8eab\u975e\u5e38\u590d\u6742\uff0c\u7ecf\u5e38\u53d7\u5230\u5e02\u573a\u60c5\u7eea\u3001\u7ecf\u6d4e\u6307\u6807\u548c\u65b0\u95fb\u7b49\u5404\u79cd\u56e0\u7d20\u7684\u5f71\u54cd\u3002\u79fb\u52a8\u5e73\u5747\u7ebf\u6216 ARIMA \u7b49\u4f20\u7edf\u6a21\u578b\u5f80\u5f80\u65e0\u6cd5\u6355\u6349\u9519\u7efc\u590d\u6742\u7684\u5e02\u573a\u52a8\u6001\u3002<\/p>\n\n\n\n<p>\u800c\u8fd1\u5e74\u6765\uff0c\u673a\u5668\u5b66\u4e60\u6a21\u578b\u7ed9\u7b97\u6cd5\u4ea4\u6613\u9886\u57df\u5e26\u6765\u4e86\u9769\u547d\u6027\u7684\u53d8\u5316\uff0c\u7279\u522b\u662f\u901a\u8fc7\u4f7f\u7528\u6df1\u5ea6\u5b66\u4e60\u6a21\u578b\uff0c\u5982\u679c\u80fd\u7ed3\u5408 CNN\u3001LSTM \u548c TCN \u7684\u4f18\u52bf\uff08\u8fd9\u5c31\u662f\u6211\u6240\u8bf4\u7684\u53e0buff\ud83d\ude02\uff09\uff0c\u6211\u4eec\u4e5f\u8bb8\u53ef\u4ee5\u4ece\u91d1\u878d\u6570\u636e\u4e2d\u63d0\u53d6\u65f6\u95f4\u6a21\u5f0f\u548c\u7a7a\u95f4\u5173\u7cfb\uff0c\u4ece\u800c\u83b7\u5f97\u66f4\u51fa\u8272\u7684\u9884\u6d4b\u548c\u66f4\u9ad8\u7684\u4ea4\u6613\u76c8\u5229\u80fd\u529b\u3002<\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>\u4e00\u3001\u4e3a\u4ec0\u4e48\u6211\u4f1a\u9009\u62e9 CNN\u3001LSTM \u548c TCN\uff1f&nbsp;<\/strong><\/h2>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"941c\"><br><strong>1.1 \u5377\u79ef\u795e\u7ecf\u7f51\u7edc\uff08CNN\uff09 <\/strong><\/h3>\n\n\n\n<figure class=\"wp-block-image size-full\"><img decoding=\"async\" src=\"https:\/\/www.laoyulaoyu.com\/wp-content\/uploads\/2024\/11\/image-37.png\" alt=\"\" class=\"wp-image-2851\"\/><\/figure>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>\u76ee\u7684\uff1a<\/strong>\u4ece\u65f6\u95f4\u5e8f\u5217\u6570\u636e\u4e2d\u63d0\u53d6\u7a7a\u95f4\u7279\u5f81\u3002<\/li>\n\n\n\n<li><strong>\u4f18\u52bf\uff1a<\/strong>\u8bc6\u522b\u6570\u636e\u4e2d\u7684\u6a21\u5f0f\uff0c\u5982\u8d8b\u52bf\u3001\u6ce2\u52a8\u96c6\u7fa4\u548c\u5173\u952e\u652f\u70b9\u3002<\/li>\n\n\n\n<li><strong>\u5e94\u7528\uff1a<\/strong>CNN \u8fc7\u6ee4\u5668\u53ef\u4ee5\u626b\u63cf\u65f6\u95f4\u5e8f\u5217\uff0c\u5728\u8f83\u77ed\u7684\u65f6\u95f4\u7a97\u53e3\u5185\u68c0\u6d4b\u5c40\u90e8\u6a21\u5f0f\uff0c\u8fd9\u5bf9\u6355\u6349\u5e02\u573a\u4fe1\u53f7\u81f3\u5173\u91cd\u8981\u3002<\/li>\n<\/ul>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"e09f\"><strong>1.2 \u957f\u77ed\u671f\u8bb0\u5fc6\uff08LSTM\uff09<\/strong><\/h3>\n\n\n\n<figure class=\"wp-block-image size-full\"><img decoding=\"async\" src=\"https:\/\/www.laoyulaoyu.com\/wp-content\/uploads\/2024\/11\/image-38.png\" alt=\"\" class=\"wp-image-2852\"\/><\/figure>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>\u76ee\u7684\uff1a<\/strong>\u6355\u6349\u65f6\u95f4\u5e8f\u5217\u6570\u636e\u4e2d\u7684\u957f\u671f\u4f9d\u8d56\u5173\u7cfb\u3002<\/li>\n\n\n\n<li><strong>\u4f18\u52bf\uff1a<\/strong>LSTM \u5728\u7406\u89e3\u65f6\u95f4\u80cc\u666f\u548c\u6839\u636e\u5386\u53f2\u6570\u636e\u9884\u6d4b\u672a\u6765\u503c\u65b9\u9762\u7279\u522b\u6709\u7528\u3002<\/li>\n\n\n\n<li><strong>\u5e94\u7528\uff1a<\/strong>LSTM \u5141\u8bb8\u6a21\u578b\u4fdd\u7559\u6709\u5173\u8fc7\u53bb\u4ef7\u683c\u548c\u8d8b\u52bf\u7684\u91cd\u8981\u4fe1\u606f\uff0c\u8fd9\u5bf9\u9884\u6d4b\u5e02\u573a\u52a8\u5411\u81f3\u5173\u91cd\u8981\u3002<\/li>\n<\/ul>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"3815\"><strong>1.3 \u65f6\u5e8f\u5377\u79ef\u7f51\u7edc\uff08TCN\uff09<\/strong><\/h3>\n\n\n\n<figure class=\"wp-block-image size-full\"><img decoding=\"async\" src=\"https:\/\/www.laoyulaoyu.com\/wp-content\/uploads\/2024\/11\/image-39.png\" alt=\"\" class=\"wp-image-2853\"\/><\/figure>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>\u76ee\u7684\uff1a<\/strong>\u6bd4\u4f20\u7edf\u7684 RNN \u66f4\u6709\u6548\u5730\u4e3a\u957f\u5e8f\u5217\u5efa\u6a21\u3002<\/li>\n\n\n\n<li><strong>\u4f18\u52bf\uff1a<\/strong>\u5377\u79ef\u7f51\u7edc\u5229\u7528\u5377\u79ef\u5c42\u5bf9\u65f6\u95f4\u5e8f\u5217\u8fdb\u884c\u5e76\u884c\u5904\u7406\uff0c\u5e76\u4fdd\u6301\u7075\u6d3b\u7684\u5185\u5b58\uff0c\u8fd9\u5f80\u5f80\u80fd\u7f29\u77ed\u8bad\u7ec3\u65f6\u95f4\uff0c\u63d0\u9ad8\u9884\u6d4b\u7cbe\u5ea6\u3002<\/li>\n\n\n\n<li><strong>\u5e94\u7528\uff1a<\/strong>TCN \u80fd\u591f\u5f88\u597d\u5730\u6355\u6349\u957f\u5468\u671f\u7684\u6a21\u5f0f\uff0c\u56e0\u6b64\u5728\u9700\u8981\u8003\u8651\u65f6\u6ede\u6216\u5ef6\u8fdf\u53cd\u5e94\u7684\u4ea4\u6613\u7b56\u7565\u4e2d\u975e\u5e38\u6709\u6548\u3002<\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>\u4e8c\u3001\u6a21\u578b\u7ec4\u5408\u65b9\u6cd5\u4e0e\u7b56\u7565<\/strong><\/h2>\n\n\n\n<p>\u901a\u8fc7\u7ed3\u5408\u8fd9\u4e9b\u6a21\u578b\uff0c\u53ef\u4ee5\u63d0\u53d6\u5c40\u90e8\u6a21\u5f0f\uff08CNN\uff09\u3001\u957f\u671f\u4f9d\u8d56\u5173\u7cfb\uff08LSTM\uff09\u548c\u957f\u7a0b\u5e8f\u5217\uff08TCN\uff09\uff0c\u4ece\u800c\u521b\u5efa\u4e00\u4e2a\u9ad8\u5ea6\u7cbe\u786e\u7684\u4ea4\u6613\u7cfb\u7edf\u3002<\/p>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>2.1 \u6570\u636e\u9009\u53d6<\/strong><\/h3>\n\n\n\n<p>\u5728\u672c\u6848\u4f8b\u7814\u7a76\u4e2d\uff0c\u6211\u4eec\u5229\u7528\u4e86 2010 \u5e74\u81f3 2023 \u5e74\u79d1\u6280\u80a1\u6295\u8d44\u7ec4\u5408\u7684\u5386\u53f2\u80a1\u4ef7\u3002\u6570\u636e\u96c6\u5305\u62ec\u6bcf\u4e2a\u4ea4\u6613\u65e5\u7684\u5f00\u76d8\u4ef7\u3001\u6536\u76d8\u4ef7\u3001\u6700\u9ad8\u4ef7\u3001\u6700\u4f4e\u4ef7\u548c\u6210\u4ea4\u91cf\u6570\u636e\u3002<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"1800\"><strong>2.2 \u6a21\u578b\u7ed3\u6784<\/strong><\/h3>\n\n\n\n<ol class=\"wp-block-list\">\n<li><strong>CNN Layer<\/strong>:  \u4ece\u77ed\u671f\u4ef7\u683c\u53d8\u52a8\uff08\u5982 10 \u5929\u7a97\u53e3\uff09\u4e2d\u63d0\u53d6\u7279\u5f81\u3002<\/li>\n\n\n\n<li><strong>LSTM Layer<\/strong>:  \u6355\u6349\u957f\u671f\u4ef7\u683c\u8d8b\u52bf\u548c\u6bcf\u65e5\u4ef7\u683c\u4e4b\u95f4\u7684\u4f9d\u8d56\u5173\u7cfb\u3002<\/li>\n\n\n\n<li><strong>TCN Layer<\/strong>: \u6a21\u62df\u957f\u671f\u5e8f\u5217\uff0c\u63d0\u9ad8\u96c6\u5408\u7684\u6574\u4f53\u7a33\u5b9a\u6027\u548c\u9c81\u68d2\u6027\u3002<\/li>\n\n\n\n<li><strong>Fully Connected Layer<\/strong>: \u7ed3\u5408 CNN\u3001LSTM \u548c TCN \u5c42\u7684\u7279\u5f81\u8fdb\u884c\u6700\u7ec8\u9884\u6d4b\u3002<\/li>\n<\/ol>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>2.3 \u96c6\u5408\u5b66\u4e60\u8fc7\u7a0b<\/strong><\/h3>\n\n\n\n<p>\u6a21\u578b\u7684\u8bad\u7ec3\u7ed3\u5408\u4e86\u76d1\u7763\u5b66\u4e60\uff08\u7528\u4e8e\u9884\u6d4b\u6b21\u65e5\u4ef7\u683c\uff09\u548c\u5f3a\u5316\u5b66\u4e60\uff08\u7528\u4e8e\u4f18\u5316\u4ea4\u6613\u884c\u52a8\uff09\u3002\u6839\u636e\u6a21\u578b\u9884\u6d4b\uff0c\u96c6\u5408\u6bcf\u5929\u4ea7\u751f\u4e00\u4e2a\u4e70\u5165\/\u5356\u51fa\u4fe1\u53f7\u3002<\/p>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>2.4 \u4ea4\u6613\u7b56\u7565<\/strong><\/h3>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>\u957f\u7ebf\u7b56\u7565\uff1a<\/strong>\u5728\u7ec4\u5408\u9884\u6d4b\u51fa\u73b0\u79ef\u6781\u8d70\u52bf\u65f6\u4e70\u5165\u3002<\/li>\n\n\n\n<li><strong>\u6b62\u635f\u548c\u6b62\u76c8\uff1a<\/strong>\u5982\u679c\u80a1\u4ef7\u8d70\u52bf\u4e0e\u9884\u6d4b\u76f8\u53cd\uff0c\u8d85\u8fc7\u4e00\u5b9a\u4e34\u754c\u503c\uff0c\u6216\u5229\u6da6\u8d85\u8fc7\u4e00\u5b9a\u9650\u989d\uff0c\u81ea\u52a8\u9000\u51fa\u4ea4\u6613\u3002<\/li>\n\n\n\n<li><strong>\u518d\u6295\u8d44\uff1a<\/strong>\u5c06\u5229\u6da6\u518d\u6295\u8d44\u5230\u540e\u7eed\u4ea4\u6613\u4e2d\uff0c\u4ee5\u5b9e\u73b0\u6536\u76ca\u6700\u5927\u5316\u3002<\/li>\n<\/ul>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>2.5 \u56de\u6eaf\u6d4b\u8bd5\u7ed3\u679c<\/strong><\/h3>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>otal Return<\/strong>: \u603b\u56de\u62a5\u738766,941.5%<\/li>\n\n\n\n<li><strong>Sharpe Ratio<\/strong>: \u590f\u666e\u6bd4\u7387\uff1a3.45\uff08\u8868\u660e\u98ce\u9669\u8c03\u6574\u540e\u7684\u56de\u62a5\u7387\u6781\u9ad8\uff09\u3002<\/li>\n\n\n\n<li><strong>Max Drawdown<\/strong>: \u6700\u5927\u7f29\u6c34\uff1a15%\uff08\u8003\u8651\u5230\u9ad8\u56de\u62a5\u7684\u6f5c\u529b\uff0c\u8be5\u6bd4\u7387\u8f83\u4f4e\uff09\u3002<\/li>\n\n\n\n<li><strong>Annualized Volatility<\/strong>: \u5e74\u5316\u6ce2\u52a8\u7387\uff1a18.5%\uff08\u5728\u53ef\u63a5\u53d7\u7684\u98ce\u9669\u8303\u56f4\u5185\uff09\u3002<\/li>\n<\/ul>\n\n\n\n<p>\u8fd9\u4e9b\u7ed3\u679c\u5c55\u793a\u4e86\u5728\u91d1\u878d\u5e02\u573a\u4e2d\u5229\u7528\u6df1\u5ea6\u5b66\u4e60\u96c6\u5408\u7684\u5de8\u5927\u6f5c\u529b\uff0c\u4e0d\u8fc7\u8fd9\u79cd\u6027\u80fd\u53ea\u662f\u5047\u8bbe\uff0c\u5728\u5f88\u5927\u7a0b\u5ea6\u4e0a\u53d6\u51b3\u4e8e\u6570\u636e\u3001\u6a21\u578b\u8bad\u7ec3\u548c\u73b0\u5b9e\u4e16\u754c\u7684\u9650\u5236\u56e0\u7d20\u3002<\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>\u4e09\u3001\u6a21\u578b\u7ec4\u5408\u7684 Python \u5b9e\u73b0&nbsp;<\/strong><\/h2>\n\n\n\n<p><strong>\u6b65\u9aa4 1 \uff1a\u5b89\u88c5\u6240\u9700\u7a0b\u5e8f\u5e93<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>pip install numpy pandas tensorflow scikit-learn matplotlib<\/code><\/pre>\n\n\n\n<p><strong>\u6b65\u9aa4 2\uff1a\u5bfc\u5165\u5e93<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>import numpy as np\nimport pandas as pd\nfrom sklearn.model_selection import train_test_split\nfrom tensorflow.keras.models import Model\nfrom tensorflow.keras.layers import Input, Conv1D, LSTM, Dense, Dropout\nfrom tensorflow.keras.layers import Flatten, Concatenate\nfrom tensorflow.keras.optimizers import Adam<\/code><\/pre>\n\n\n\n<p><strong>\u6b65\u9aa4 3\uff1a\u52a0\u8f7d\u548c\u9884\u5904\u7406\u6570\u636e<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code># Load historical stock data\ndata = pd.read_csv('tech_stocks.csv')\ndata&#91;'Date'] = pd.to_datetime(data&#91;'Date'])\ndata.set_index('Date', inplace=True)<\/code><\/pre>\n\n\n\n<pre class=\"wp-block-code\"><code># Normalize data for better training performance<br>from sklearn.preprocessing import MinMaxScaler<br>scaler = MinMaxScaler()<br>scaled_data = scaler.fit_transform(data&#91;&#91;'Open', 'Close', 'High', 'Low', 'Volume']])# Prepare features and labels (predicting next day's close price)<br>X = &#91;]<br>y = &#91;]<br>window_size = 10  # use 10 days of data to predict the next dayfor i in range(len(scaled_data) - window_size):<br>    X.append(scaled_data&#91;i:i+window_size])<br>    y.append(scaled_data&#91;i+window_size, 1])  # next day's Close priceX = np.array(X)<br>y = np.array(y)# Split into training and testing sets<br>X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.2, shuffle=False)<\/code><\/pre>\n\n\n\n<p><strong>\u6b65\u9aa4 4\uff1a\u5b9a\u4e49\u96c6\u5408\u6a21\u578b\uff08CNN\u3001LSTM\u3001TCN\uff09<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code># Input layer\ninput_layer = Input(shape=(window_size, X_train.shape&#91;2]))<\/code><\/pre>\n\n\n\n<pre class=\"wp-block-code\"><code># CNN Layer<br>cnn_layer = Conv1D(filters=64, kernel_size=2, activation='relu')(input_layer)<br>cnn_layer = Flatten()(cnn_layer)# LSTM Layer<br>lstm_layer = LSTM(64, return_sequences=False)(input_layer)# TCN Layer (using Conv1D as TCN)<br>tcn_layer = Conv1D(filters=64, kernel_size=3, activation='relu', dilation_rate=2)(input_layer)<br>tcn_layer = Flatten()(tcn_layer)# Combine CNN, LSTM, and TCN outputs<br>combined = Concatenate()(&#91;cnn_layer, lstm_layer, tcn_layer])# Fully connected layers<br>dense_layer = Dense(64, activation='relu')(combined)<br>dense_layer = Dropout(0.3)(dense_layer)<br>output_layer = Dense(1, activation='linear')(dense_layer)# Create the model<br>model = Model(inputs=input_layer, outputs=output_layer)# Compile the model<br>model.compile(optimizer=Adam(learning_rate=0.001), loss='mse')<\/code><\/pre>\n\n\n\n<p><strong>\u6b65\u9aa4 5\uff1a\u8bad\u7ec3\u6a21\u578b<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code># Train the ensemble model\nmodel.fit(X_train, y_train, epochs=50, batch_size=32, validation_data=(X_test, y_test))<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>\u56db\u3001\u89c2\u70b9\u603b\u7ed3<\/strong><\/h2>\n\n\n\n<p>\u6211\u4eec\u7814\u7a76\u5c55\u793a\u4e86\u7ed3\u5408 CNN\u3001LSTM \u548c TCN \u7684\u96c6\u5408\u6a21\u578b\u5728\u91d1\u878d\u5e02\u573a\u65f6\u95f4\u5e8f\u5217\u9884\u6d4b\u4e2d\u7684\u5a01\u529b\u3002\u867d\u7136\u672c\u7814\u7a76\u4e2d\u7684\u6536\u76ca\u662f\u5047\u8bbe\u7684\uff0c\u4f46\u5b83\u51f8\u663e\u4e86\u5728\u7b97\u6cd5\u4ea4\u6613\u4e2d\u4f7f\u7528\u6df1\u5ea6\u5b66\u4e60\u6a21\u578b\u7684\u5de8\u5927\u6f5c\u529b\u3002<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>\u4f20\u7edf\u7684\u65f6\u95f4\u5e8f\u5217\u5206\u6790\u6a21\u578b\uff0c\u5982\u79fb\u52a8\u5e73\u5747\u7ebf\u6216ARIMA\uff0c\u5f80\u5f80\u65e0\u6cd5\u6355\u6349\u91d1\u878d\u5e02\u573a\u7684\u590d\u6742\u52a8\u6001\u3002<\/li>\n\n\n\n<li>\u901a\u8fc7\u96c6\u5408\u5b66\u4e60\u7684\u65b9\u6cd5\uff0c\u53ef\u4ee5\u66f4\u6709\u6548\u5730\u63d0\u53d6\u65f6\u95f4\u5e8f\u5217\u6570\u636e\u7684\u7279\u5f81\uff0c\u4ece\u800c\u63d0\u9ad8\u4ea4\u6613\u9884\u6d4b\u7684\u51c6\u786e\u6027\u548c\u76c8\u5229\u80fd\u529b\u3002<\/li>\n\n\n\n<li>CNN\u3001LSTM\u548cTCN\u5404\u81ea\u5177\u6709\u4e0d\u540c\u7684\u7279\u70b9\u548c\u4f18\u52bf\uff0c\u5b83\u4eec\u7684\u7ed3\u5408\u80fd\u591f\u5145\u5206\u5229\u7528\u91d1\u878d\u6570\u636e\u7684\u65f6\u95f4\u548c\u7a7a\u95f4\u4fe1\u606f\u3002<\/li>\n\n\n\n<li>\u5229\u7528\u6df1\u5ea6\u5b66\u4e60\u96c6\u5408\u65b9\u6cd5\u8fdb\u884c\u4ea4\u6613\u7b56\u7565\u7684\u56de\u6eaf\u6d4b\u8bd5\u5c55\u793a\u4e86\u663e\u8457\u7684\u56de\u62a5\u6f5c\u529b\uff0c\u4f46\u5b9e\u9645\u5e94\u7528\u9700\u8981\u8003\u8651\u6570\u636e\u8d28\u91cf\u3001\u6a21\u578b\u8bad\u7ec3\u548c\u5e02\u573a\u5b9e\u9645\u60c5\u51b5\u3002<\/li>\n\n\n\n<li>\u518d\u6295\u8d44\u7b56\u7565\u3001\u8bbe\u7f6e\u6b62\u635f\u548c\u6b62\u76c8\u70b9\u4ee5\u53ca\u4f7f\u7528\u5f3a\u5316\u5b66\u4e60\u4f18\u5316\u4ea4\u6613\u884c\u52a8\u662f\u63d0\u9ad8\u4ea4\u6613\u76c8\u5229\u80fd\u529b\u7684\u5173\u952e\u56e0\u7d20\u3002<\/li>\n\n\n\n<li>\u56de\u6eaf\u6d4b\u8bd5\u7ed3\u679c\u663e\u793a\uff0c\u8be5\u96c6\u5408\u6a21\u578b\u5177\u6709\u9ad8\u56de\u62a5\u3001\u4f4e\u98ce\u9669\u548c\u7a33\u5b9a\u6027\uff0c\u4f46\u8fd9\u4e9b\u7ed3\u679c\u4ecd\u7136\u662f\u57fa\u4e8e\u5386\u53f2\u6570\u636e\u7684\u5047\u8bbe\u6027\u5206\u6790\u3002<\/li>\n<\/ul>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-full\"><img decoding=\"async\" src=\"https:\/\/www.laoyulaoyu.com\/wp-content\/uploads\/2024\/11\/image-40.png\" alt=\"\" class=\"wp-image-2854\"\/><\/figure>\n<\/div>\n\n\n<p><strong>\u611f\u8c22\u60a8\u9605\u8bfb\u5230\u6700\u540e\uff0c\u5e0c\u671b\u672c\u6587\u80fd\u7ed9\u60a8\u5e26\u6765\u65b0\u7684\u6536\u83b7\u3002\u795d\u60a8\u6295\u8d44\u987a\u5229\uff01\u5982\u679c\u5bf9\u6587\u4e2d\u7684\u5185\u5bb9\u6709\u4efb\u4f55\u7591\u95ee\uff0c\u8bf7\u7ed9\u6211\u7559\u8a00\uff0c\u5fc5\u590d\u3002<\/strong><\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<p><\/p>\n\n\n\n<p><\/p>\n\n\n\n<p class=\"has-text-align-center\"><strong><mark style=\"background-color:#ffffff\" class=\"has-inline-color has-cyan-bluish-gray-color\">\u672c\u6587\u5185\u5bb9\u4ec5\u4ec5\u662f\u6280\u672f\u63a2\u8ba8\u548c\u5b66\u4e60\uff0c\u5e76\u4e0d\u6784\u6210\u4efb\u4f55\u6295\u8d44\u5efa\u8bae\u3002<\/mark><\/strong><\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u4f5c\u8005\uff1a\u8001\u4f59\u635e\u9c7c \u539f\u521b\u4e0d\u6613\uff0c\u8f6c\u8f7d\u8bf7\u6807\u660e\u51fa\u5904\u53ca\u539f\u4f5c\u8005\u3002&#8230;<\/p>\n<div class=\"more-link-wrapper\"><a class=\"more-link\" href=\"https:\/\/www.laoyulaoyu.com\/index.php\/2024\/12\/02\/%e9%9c%87%e6%83%8a%e9%87%91%e8%9e%8d%e7%95%8c%ef%bc%81%e4%b8%89%e5%a4%a7%e6%b7%b1%e5%ba%a6%e5%ad%a6%e4%b9%a0%e6%a8%a1%e5%9e%8b%e8%81%94%e8%a2%82%ef%bc%8c%e7%ab%9f%e5%88%9b%e5%87%ba66941-5%e9%80%86\/\">Continue reading<span class=\"screen-reader-text\">\u9707\u60ca\u91d1\u878d\u754c\uff01\u4e09\u5927\u6df1\u5ea6\u5b66\u4e60\u6a21\u578b\u8054\u8882\uff0c\u7adf\u521b\u51fa66,941.5%\u9006\u5929\u56de\u62a5\u7387\uff01<\/span><\/a><\/div>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[2],"tags":[4,5],"class_list":{"0":"post-1679","1":"post","2":"type-post","3":"status-publish","4":"format-standard","5":"hentry","6":"category-aiinvest","7":"tag-ai","9":"entry"},"_links":{"self":[{"href":"https:\/\/www.laoyulaoyu.com\/index.php\/wp-json\/wp\/v2\/posts\/1679","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.laoyulaoyu.com\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.laoyulaoyu.com\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.laoyulaoyu.com\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.laoyulaoyu.com\/index.php\/wp-json\/wp\/v2\/comments?post=1679"}],"version-history":[{"count":2,"href":"https:\/\/www.laoyulaoyu.com\/index.php\/wp-json\/wp\/v2\/posts\/1679\/revisions"}],"predecessor-version":[{"id":1681,"href":"https:\/\/www.laoyulaoyu.com\/index.php\/wp-json\/wp\/v2\/posts\/1679\/revisions\/1681"}],"wp:attachment":[{"href":"https:\/\/www.laoyulaoyu.com\/index.php\/wp-json\/wp\/v2\/media?parent=1679"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.laoyulaoyu.com\/index.php\/wp-json\/wp\/v2\/categories?post=1679"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.laoyulaoyu.com\/index.php\/wp-json\/wp\/v2\/tags?post=1679"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}