{"id":1625,"date":"2024-11-13T07:03:00","date_gmt":"2024-11-12T23:03:00","guid":{"rendered":"https:\/\/blog.laoyulaoyu.top\/?p=1625"},"modified":"2024-10-21T23:07:36","modified_gmt":"2024-10-21T15:07:36","slug":"%e4%bb%85%e9%9c%80%e5%85%ab%e6%ad%a5%ef%bc%8c%e6%89%93%e9%80%a0%e7%a7%81%e4%ba%ba%e4%b8%93%e5%b1%9e%e8%82%a1%e7%a5%a8%e9%a2%84%e6%b5%8b%e6%a8%a1%e5%9e%8b","status":"publish","type":"post","link":"https:\/\/www.laoyulaoyu.com\/index.php\/2024\/11\/13\/%e4%bb%85%e9%9c%80%e5%85%ab%e6%ad%a5%ef%bc%8c%e6%89%93%e9%80%a0%e7%a7%81%e4%ba%ba%e4%b8%93%e5%b1%9e%e8%82%a1%e7%a5%a8%e9%a2%84%e6%b5%8b%e6%a8%a1%e5%9e%8b\/","title":{"rendered":"\u4ec5\u9700\u516b\u6b65\uff0c\u6253\u9020\u79c1\u4eba\u4e13\u5c5e\u80a1\u7968\u9884\u6d4b\u6a21\u578b"},"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\/10\/100716.png\" alt=\"\" class=\"wp-image-2568\"\/><\/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>\u521b\u5efa\u5c5e\u4e8e\u81ea\u5df1\u7684\u80a1\u7968\u4ef7\u683c\u9884\u6d4b\u6a21\u578b\u4e00\u5b9a\u4f1a\u8ba9\u6211\u4eec\u611f\u5230\u5174\u594b\u548c\u6ee1\u8db3\uff01\u672c\u6587\u5c06\u63d0\u4f9b\u4e00\u4efd\u8be6\u7ec6\u7684\u642d\u5efa\u6307\u5357\uff0c\u5e26\u9886\u5927\u5bb6\u4f7f\u7528 Python \u8bed\u8a00\u548c\u4e00\u4e9b\u5e93\u6765<mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-vivid-cyan-blue-color\">\u6784\u5efa\u4e13\u5c5e\u4e8e\u4f60\u7684\u80a1\u7968\u4ef7\u683c\u9884\u6d4b\u6a21\u578b<\/mark>\u3002\u5982\u679c\u6ca1\u6709\u592a\u591a\u7f16\u7a0b\u7ecf\u9a8c\u4e5f\u4e0d\u7528\u62c5\u5fc3\uff0c\u8ddf\u7740\u6211\u4e00\u6b65\u6b65\u6765\uff0c\u4f60\u4e5f\u80fd\u6210\u529f\u3002<\/pre>\n<\/blockquote>\n\n\n\n<p><\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>\u4e00\u3001\u4e3a\u4ec0\u4e48\u8981\u521b\u5efa\u81ea\u5b9a\u4e49\u80a1\u7968\u9884\u6d4b\u6a21\u578b\uff1f<\/strong><\/h2>\n\n\n\n<p>\u521b\u5efa\u81ea\u5b9a\u4e49\u80a1\u7968\u9884\u6d4b\u6a21\u578b\u7684\u539f\u56e0\u662f\u591a\u65b9\u9762\u7684\uff0c\u5b83\u4f53\u73b0\u4e86\u6295\u8d44\u8005\u5bf9\u5e02\u573a\u6df1\u5165\u7406\u89e3\u548c\u4e2a\u6027\u5316\u7b56\u7565\u7684\u8ffd\u6c42\u3002<\/p>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>\u6d1e\u5bdf\uff1a\u6df1\u5165\u4e86\u89e3\u4e0d\u540c\u56e0\u7d20\u5982\u4f55\u5f71\u54cd\u80a1\u7968\u4ef7\u683c\u3002<\/strong><\/h3>\n\n\n\n<p>\u9996\u5148\uff0c\u5e02\u573a\u662f\u590d\u6742\u591a\u53d8\u7684\uff0c\u4f20\u7edf\u7684\u9884\u6d4b\u65b9\u6cd5\u53ef\u80fd\u65e0\u6cd5\u5168\u9762\u6355\u6349\u5e02\u573a\u52a8\u6001\u3002\u901a\u8fc7\u6784\u5efa\u81ea\u5b9a\u4e49\u6a21\u578b\uff0c\u6295\u8d44\u8005\u53ef\u4ee5\u6839\u636e\u81ea\u5df1\u5bf9\u5e02\u573a\u7684\u72ec\u7279\u89c1\u89e3\uff0c\u5c06\u591a\u79cd\u56e0\u7d20\u7eb3\u5165\u8003\u91cf\u8303\u56f4\uff0c\u5982\u5b8f\u89c2\u7ecf\u6d4e\u6307\u6807\u3001\u516c\u53f8\u8d22\u52a1\u72b6\u51b5\u3001\u5e02\u573a\u60c5\u7eea\u7b49\uff0c\u4ece\u800c\u66f4\u51c6\u786e\u5730\u9884\u6d4b\u80a1\u7968\u4ef7\u683c\u7684\u8d70\u52bf\u3002<\/p>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>\u5b9a\u5236\uff1a\u6839\u636e\u60a8\u7684\u5177\u4f53\u9700\u6c42\u548c\u504f\u597d\u5b9a\u5236\u6a21\u578b\u3002<\/strong><\/h3>\n\n\n\n<p>\u5176\u6b21\uff0c\u81ea\u5b9a\u4e49\u6a21\u578b\u5141\u8bb8\u6295\u8d44\u8005\u6839\u636e\u81ea\u5df1\u7684\u98ce\u9669\u504f\u597d\u548c\u6295\u8d44\u76ee\u6807\u8fdb\u884c\u4e2a\u6027\u5316\u8c03\u6574\u3002\u4e0d\u540c\u7684\u6295\u8d44\u8005\u6709\u4e0d\u540c\u7684\u6295\u8d44\u7406\u5ff5\u548c\u7b56\u7565\uff0c\u901a\u8fc7\u81ea\u5b9a\u4e49\u6a21\u578b\uff0c\u4ed6\u4eec\u53ef\u4ee5\u5c06\u8fd9\u4e9b\u7406\u5ff5\u878d\u5165\u9884\u6d4b\u8fc7\u7a0b\u4e2d\uff0c\u5236\u5b9a\u51fa\u66f4\u7b26\u5408\u81ea\u5df1\u9700\u6c42\u7684\u6295\u8d44\u7b56\u7565\u3002<\/p>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>\u521b\u65b0\uff1a\u5c1d\u8bd5\u5404\u79cd\u6280\u5de7\uff0c\u53d1\u73b0\u6700\u9002\u5408\u81ea\u5df1\u7684\u65b9\u6cd5\u3002<\/strong><\/h3>\n\n\n\n<p>\u6b64\u5916\uff0c\u81ea\u5b9a\u4e49\u6a21\u578b\u8fd8\u5177\u6709\u4e00\u5b9a\u7684\u7075\u6d3b\u6027\u548c\u53ef\u6269\u5c55\u6027\u3002\u968f\u7740\u5e02\u573a\u73af\u5883\u548c\u6295\u8d44\u8005\u9700\u6c42\u7684\u53d8\u5316\uff0c\u6295\u8d44\u8005\u53ef\u4ee5\u4e0d\u65ad\u5bf9\u6a21\u578b\u8fdb\u884c\u4f18\u5316\u548c\u6539\u8fdb\uff0c\u4ee5\u9002\u5e94\u65b0\u7684\u5e02\u573a\u60c5\u51b5\u3002\u8fd9\u79cd\u7075\u6d3b\u6027\u4f7f\u5f97\u81ea\u5b9a\u4e49\u6a21\u578b\u5728\u5e94\u5bf9\u5e02\u573a\u53d8\u5316\u65f6\u66f4\u52a0\u5f97\u5fc3\u5e94\u624b\u3002<br><\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><br><strong>\u4e8c\u3001\u642d\u5efa\u81ea\u5b9a\u4e49\u80a1\u7968\u9884\u6d4b\u6a21\u578b<\/strong><\/h2>\n\n\n\n<h3 class=\"wp-block-heading\"><br><strong>\u7b2c\u2460\u6b65 \u9700\u8981\u4e86\u89e3\u7684\u5de5\u5177\u548c\u5e93<\/strong><\/h3>\n\n\n\n<p>\u5728\u6df1\u5165\u4e86\u89e3\u4ee3\u7801\u4e4b\u524d\uff0c\u8ba9\u6211\u4eec\u5148\u719f\u6089\u4e00\u4e0b\u6211\u4eec\u8981\u7528\u5230\u7684\u5de5\u5177\u548c\u5e93\uff1a<\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li>Python\uff1a\u6211\u4eec\u5c06\u4f7f\u7528\u7684\u7f16\u7a0b\u8bed\u8a00\u3002<\/li>\n\n\n\n<li>Pandas\uff1a\u7528\u4e8e\u6570\u636e\u5904\u7406\u3002<\/li>\n\n\n\n<li>NumPy\uff1a\u7528\u4e8e\u6570\u503c\u8fd0\u7b97\u3002<\/li>\n\n\n\n<li>Scikit-learn\uff1a\u7528\u4e8e\u6784\u5efa\u548c\u8bc4\u4f30\u673a\u5668\u5b66\u4e60\u6a21\u578b\u3002<\/li>\n\n\n\n<li>XGBoost \u548c LightGBM\uff1a\u5148\u8fdb\u7684\u589e\u5f3a\u6280\u672f\uff0c\u53ef\u63d0\u9ad8\u51c6\u786e\u6027\u3002<\/li>\n\n\n\n<li>Yahoo Finance:\uff1a\u96c5\u864e\u8d22\u7ecf\uff0c\u7528\u4e8e\u83b7\u53d6\u80a1\u7968\u6570\u636e\u3002<\/li>\n<\/ol>\n\n\n\n<h3 class=\"wp-block-heading\"><br><strong>\u7b2c\u2461\u6b65 \u52a0\u8f7d\u548c\u51c6\u5907\u6570\u636e<\/strong><\/h3>\n\n\n\n<p>\u9996\u5148\uff0c\u60a8\u9700\u8981\u80a1\u7968\u6570\u636e\u3002\u4e0b\u9762\u4ecb\u7ecd\u5982\u4f55\u83b7\u53d6\u548c\u51c6\u5907\u6570\u636e\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code><code>import yfinance as yf\nimport pandas as pd\n\ndef load_data(ticker):\nstock = yf.Ticker(ticker)\ndf = stock.history(period=\"1y\")\ndf&#91;'Date'] = df.index\nreturn df<\/code><\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\"><br><strong>\u7b2c\u2462\u6b65 \u6dfb\u52a0\u6280\u672f\u6307\u6807<\/strong><\/h3>\n\n\n\n<p>\u8981\u8fdb\u884c\u9884\u6d4b\uff0c\u5c31\u9700\u8981\u521b\u5efa\u53cd\u6620\u5e02\u573a\u72b6\u51b5\u7684\u7279\u5f81\u3002\u4ee5\u4e0b\u662f\u4e00\u4e9b\u53ef\u4ee5\u4f7f\u7528\u7684\u6280\u672f\u6307\u6807\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code><code>def bollinger_bands(close, window=20, num_std=2):\nrolling_mean = close.rolling(window=window).mean()\nrolling_std = close.rolling(window=window).std()\nupper_bb = rolling_mean + (rolling_std * num_std)\nlower_bb = rolling_mean - (rolling_std * num_std)\nreturn upper_bb, lower_bb<\/code>\n<code>\ndef compute_rsi(close, window=14):\ndelta = close.diff()\ngain = (delta.where(delta &gt; 0, 0)).rolling(window=window).mean()\nloss = (-delta.where(delta &lt; 0, 0)).rolling(window=window).mean()\nrs = gain \/ loss\nreturn 100 - (100 \/ (1 + rs))<\/code><\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\"><br><strong>\u7b2c\u2463\u6b65 \u9009\u62e9\u5e76\u8bad\u7ec3\u6a21\u578b<\/strong><\/h3>\n\n\n\n<p>\u6211\u4eec\u5c06\u4f7f\u7528\u5404\u79cd\u6a21\u578b\u548c\u96c6\u5408\u6280\u672f\u6765\u83b7\u5f97\u6700\u4f73\u7ed3\u679c\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code><code>from sklearn.model_selection import train_test_split\nfrom sklearn.pipeline import Pipeline\nfrom sklearn.preprocessing import StandardScaler\nfrom sklearn.ensemble import VotingRegressor\nfrom sklearn.linear_model import LinearRegression\nfrom sklearn.ensemble import RandomForestRegressor, GradientBoostingRegressor\nfrom sklearn.svm import SVR\nimport xgboost as xgb\nimport lightgbm as lgb\nmodels = {\n'Decision Tree': DecisionTreeRegressor(random_state=42),\n'Linear Regression': LinearRegression(),\n'Random Forest': RandomForestRegressor(random_state=42),\n'Gradient Boosting': GradientBoostingRegressor(random_state=42),\n'Support Vector Machine': SVR(),\n'XGBoost': xgb.XGBRegressor(random_state=42),\n'LightGBM': lgb.LGBMRegressor(random_state=42)\n}\ndef train_and_evaluate(X, y, selected_models):\nX_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.2, random_state=42)\nscaler = StandardScaler()\nif len(selected_models) &gt; 1:\nvoting_regressor = VotingRegressor(\nestimators=&#91;(name, models&#91;name]) for name in selected_models]\n)\nmodel = Pipeline(steps=&#91;\n('scaler', scaler),\n('regressor', voting_regressor)\n])\nelse:\nmodel = Pipeline(steps=&#91;\n('scaler', scaler),\n('regressor', models&#91;selected_models&#91;0]])\n])\nmodel.fit(X_train, y_train)\ny_pred = model.predict(X_test)<\/code>\n<code>mae = mean_absolute_error(y_test, y_pred)\nmse = mean_squared_error(y_test, y_pred)\nrmse = np.sqrt(mse)\nr2 = r2_score(y_test, y_pred)\nmape = mean_absolute_percentage_error(y_test, y_pred)<\/code>\n<code>return mae, mse, rmse, r2, mape, y_test, y_pred, model<\/code><\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\"><br><strong>\u7b2c\u2464\u6b65 \u591a\u6a21\u578b\u7ed3\u5408<\/strong><\/h3>\n\n\n\n<p>\u8fd9\u79cd\u65b9\u6cd5\u7684\u5f3a\u5927\u529f\u80fd\u4e4b\u4e00\u662f\u80fd\u591f\u5c06\u591a\u4e2a\u6a21\u578b\u7ec4\u5408\u6210\u4e00\u4e2a\u66f4\u5f3a\u5927\u7684\u6a21\u578b\u3002\u8fd9\u901a\u5e38\u6bd4\u5355\u72ec\u4f7f\u7528\u4efb\u4f55\u4e00\u4e2a\u6a21\u578b\u90fd\u80fd\u5e26\u6765\u66f4\u597d\u7684\u6027\u80fd\u3002\u4e0b\u9762\u4ecb\u7ecd\u5982\u4f55\u4f7f\u7528\u6295\u7968\u56de\u5f52\u5668\u7ec4\u5408\u6a21\u578b\uff1a<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img decoding=\"async\" src=\"https:\/\/www.laoyulaoyu.com\/wp-content\/uploads\/2024\/10\/image-33.png\" alt=\"\" class=\"wp-image-2570\"\/><\/figure>\n\n\n\n<h3 class=\"wp-block-heading\"><br><br><strong>\u7b2c\u2465\u6b65  \u4fdd\u5b58\u60a8\u7684\u6a21\u578b<\/strong><\/h3>\n\n\n\n<p>\u8bad\u7ec3\u597d\u6a21\u578b\u540e\uff0c\u5c06\u5176\u4fdd\u5b58\u8d77\u6765\uff0c\u8fd9\u6837\u5c31\u53ef\u4ee5\u91cd\u590d\u4f7f\u7528\uff0c\u65e0\u9700\u91cd\u65b0\u8bad\u7ec3\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code><code>import pandas as pd\nimport numpy as np\nimport yfinance as yf\nimport joblib<\/code>\n<code>Load the trained model\nmodel = joblib.load('trained_model.pkl')\n\u2026\ndef on_button_clicked(b):\nglobal trained_model\nwith output:\nclear_output()\nselected_models = &#91;checkbox.description for checkbox in model_checkboxes if checkbox.value]\nif selected_models:\nprint(f\"Running models: {', '.join(selected_models)}\")\nmae, mse, rmse, r2, mape, y_test, y_pred, trained_model = train_and_evaluate(X, y, selected_models)\nprint(\"\\nModel Evaluation Metrics:\")\nprint(f\"Mean Absolute Error: ${mae:.2f}\")\nprint(f\"Mean Squared Error: ${mse:.2f}\")\nprint(f\"Root Mean Squared Error: ${rmse:.2f}\")\nprint(f\"R^2 Score: {r2:.4f}\")\nprint(f\"Mean Absolute Percentage Error: {mape:.2f}%\")<\/code>\n<code>print(\"\\nSample of predictions vs true values:\")\nresults_df = pd.DataFrame({'True Price': y_test, 'Predicted Price': y_pred})\ndisplay(results_df.head())<\/code>\n<code># Save the trained model\nsave_model(trained_model, 'trained_model.pkl')<\/code>\n<code>else:\nprint(\"Please select at least one model.\")<\/code><\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\"><br><strong>\u7b2c\u2466\u6b65 \u6a21\u578b\u8bc4\u4f30\u6307\u6807<\/strong><\/h3>\n\n\n\n<p>\u8bc4\u4f30\u6a21\u578b\u7684\u6027\u80fd\u5bf9\u4e8e\u4e86\u89e3\u5176\u8fd0\u884c\u72b6\u51b5\u81f3\u5173\u91cd\u8981\u3002\u4ee5\u4e0b\u662f\u4e00\u4e9b\u5e38\u89c1\u7684\u6307\u6807\uff1a<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>\u5e73\u5747\u7edd\u5bf9\u8bef\u5dee (MAE)\uff1a\u9884\u6d4b\u503c\u4e0e\u5b9e\u9645\u503c\u4e4b\u95f4\u7684\u5e73\u5747\u7edd\u5bf9\u8bef\u5dee\u3002<\/li>\n\n\n\n<li>\u5e73\u5747\u5e73\u65b9\u8bef\u5dee (MSE)\uff1a\u9884\u6d4b\u503c\u4e0e\u5b9e\u9645\u503c\u4e4b\u95f4\u7684\u5e73\u5747\u5e73\u65b9\u8bef\u5dee\u3002<\/li>\n\n\n\n<li>\u5747\u65b9\u6839\u8bef\u5dee (RMSE)\uff1a\u5747\u65b9\u6839\u8bef\u5dee\uff08MSE\uff09\u7684\u5e73\u65b9\u6839\uff0c\u8868\u793a\u8bef\u5dee\u5927\u5c0f\u3002<\/li>\n\n\n\n<li>\u5e73\u5747\u7edd\u5bf9\u767e\u5206\u6bd4\u8bef\u5dee (MAPE)\uff1a\u9884\u6d4b\u503c\u4e0e\u5b9e\u9645\u503c\u4e4b\u95f4\u7684\u5e73\u5747\u7edd\u5bf9\u767e\u5206\u6bd4\u8bef\u5dee\u3002<\/li>\n<\/ul>\n\n\n\n<pre class=\"wp-block-code\"><code><code>mae = mean_absolute_error(y_test, y_pred)\nmse = mean_squared_error(y_test, y_pred)\nrmse = np.sqrt(mse)\nr2 = r2_score(y_test, y_pred)\nmape = mean_absolute_percentage_error(y_test, y_pred)<\/code>\n<code>return mae, mse, rmse, r2, mape, y_test, y_pred, model<\/code><\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\"><br><strong>\u7b2c\u2467\u6b65 \u52a0\u8f7d\u6a21\u578b\u548c\u80a1\u7968\u4ef7\u683c\u9884\u6d4b<\/strong><\/h3>\n\n\n\n<p>\u4fdd\u5b58\u5e76\u52a0\u8f7d\u6a21\u578b\u540e\uff0c\u60a8\u5c31\u53ef\u4ee5\u7528\u5b83\u6765\u9884\u6d4b\u80a1\u7968\u4ef7\u683c\u4e86\u3002\u4ee5\u4e0b\u662f\u5982\u4f55\u4f7f\u7528\u8bad\u7ec3\u540e\u7684\u6a21\u578b\u9884\u6d4b\u672a\u6765\u80a1\u7968\u4ef7\u683c\u7684\u65b9\u6cd5\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code><code># Prepare a list to store predictions\npredictions = &#91;]<\/code>\n<code># Check if the recent_data DataFrame has the correct number of columns\nif recent_data.shape&#91;1] != len(expected_features):\n    raise ValueError(f\"Expected {len(expected_features)} features but got {recent_data.shape&#91;1]}\")\n\n# Predict future prices\nfor _ in range(future_days):\n    # Predict the next day's price\n    prediction = model.predict(recent_data)\n    predictions.append(prediction&#91;0])\n\n    # Create a new row for future prediction\n    new_row = recent_data.copy()\n    new_row.loc&#91;0, 'Open'] = prediction&#91;0]  # Update the 'Open' feature for the new row\n\n    # Append new_row to recent_data\n    recent_data = pd.concat(&#91;recent_data&#91;1:], new_row], ignore_index=True)\n\nreturn predictions<\/code><\/code><\/pre>\n\n\n\n<p>\u6700\u540e\uff0c\u60f3\u5c1d\u8bd5\u521b\u5efa\u81ea\u5df1\u7684\u80a1\u4ef7\u9884\u6d4b\u6a21\u578b\u4e86\u5417\uff1f\u6211\u5efa\u7acb\u4e86\u4e00\u4e2a <a href=\"https:\/\/colab.research.google.com\/drive\/1-LnvPHVLzM-sIDSUvyTxQFGQe8cN_PRN?usp=sharing#scrollTo=RQ5XJ9-pIxvx\">Google Colab <\/a>\uff0c\u4f60\u53ef\u4ee5\u5728\u7ebf\u8bd5\u7528\u4ee3\u7801\uff0c\u5e76\u8bfe\u6839\u636e\u81ea\u5df1\u7684\u9700\u8981\u8fdb\u884c\u5b9a\u5236\uff0c\u8fd8\u80fd\u8fdb\u4e00\u6b65\u5728\u81ea\u5df1\u7684\u6a21\u578b\u4e2d\u7528\u4efb\u4f55\u60a8\u611f\u5174\u8da3\u7684\u80a1\u7968\u4ee3\u7801\u66ff\u6362\u73b0\u6709\u7684\u80a1\u7968\u3002<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img decoding=\"async\" src=\"https:\/\/www.laoyulaoyu.com\/wp-content\/uploads\/2024\/10\/1729522325477.png\" alt=\"\" class=\"wp-image-2573\"\/><\/figure>\n\n\n\n<p>Google Colab \u7b14\u8bb0\u672c\u5730\u5740\uff1a<a href=\"https:\/\/colab.research.google.com\/drive\/1-LnvPHVLzM-sIDSUvyTxQFGQe8cN_PRN?usp=sharing#scrollTo=RQ5XJ9-pIxvx\">https:\/\/colab.research.google.com\/drive\/1-LnvPHVLzM-sIDSUvyTxQFGQe8cN_PRN?usp=sharing#scrollTo=RQ5XJ9-pIxvx<\/a><\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>\u4e09\u3001\u89c2\u70b9\u56de\u987e<\/strong><\/h2>\n\n\n\n<p>\u5efa\u7acb\u81ea\u5df1\u7684\u80a1\u4ef7\u9884\u6d4b\u6a21\u578b\u662f\u4e00\u79cd\u975e\u5e38\u6709\u76ca\u7684\u4f53\u9a8c\u3002\u60a8\u53ef\u4ee5\u81ea\u5b9a\u4e49\u6a21\u578b\u7684\u65b9\u65b9\u9762\u9762\uff0c\u4ece\u7279\u5f81\u9009\u62e9\u5230\u4f7f\u7528\u7684\u7b97\u6cd5\u3002\u901a\u8fc7\u7075\u6d3b\u7ec4\u5408\u4e0d\u540c\u7684\u6a21\u578b\u548c\u6280\u672f\u6307\u6807\uff0c\u60a8\u53ef\u4ee5\u521b\u5efa\u4e00\u4e2a\u5b8c\u5168\u9002\u5408\u81ea\u5df1\u4ea4\u6613\u98ce\u683c\u7684\u5de5\u5177\u3002<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>\u81ea\u5b9a\u4e49\u6a21\u578b\u7684\u4f18\u52bf<\/strong>\uff1a\u81ea\u5efa\u80a1\u7968\u4ef7\u683c\u9884\u6d4b\u6a21\u578b\u53ef\u4ee5\u8ba9\u7528\u6237\u6839\u636e\u4e2a\u4eba\u9700\u6c42\u548c\u504f\u597d\u8fdb\u884c\u5b9a\u5236\uff0c\u66f4\u597d\u5730\u7406\u89e3\u4e0d\u540c\u56e0\u7d20\u5982\u4f55\u5f71\u54cd\u80a1\u7968\u4ef7\u683c\uff0c\u5e76\u6709\u673a\u4f1a\u5c1d\u8bd5\u521b\u65b0\u7684\u6280\u672f\u3002<\/li>\n\n\n\n<li><strong>\u5fc5\u8981\u7684\u5de5\u5177\u548c\u5e93<\/strong>\uff1a\u4e3a\u4e86\u6784\u5efa\u6a21\u578b\uff0c\u9700\u8981\u638c\u63e1Python\u7f16\u7a0b\u8bed\u8a00\uff0c\u5e76\u4e14\u719f\u7ec3\u4f7f\u7528\u6570\u636e\u5904\u7406\u548c\u673a\u5668\u5b66\u4e60\u76f8\u5173\u7684\u5e93\uff0c\u5982Pandas\u3001NumPy\u3001Scikit-learn\u3001XGBoost\u548cLightGBM\u3002<\/li>\n\n\n\n<li><strong>\u6570\u636e\u51c6\u5907\u548c\u7279\u5f81\u5de5\u7a0b\u7684\u91cd\u8981\u6027<\/strong>\uff1a\u52a0\u8f7d\u548c\u51c6\u5907\u6570\u636e\u662f\u5efa\u6a21\u524d\u7684\u5173\u952e\u6b65\u9aa4\uff0c\u7279\u5f81\u5de5\u7a0b\u5982\u6dfb\u52a0\u6280\u672f\u6307\u6807\u53ef\u4ee5\u5e2e\u52a9\u6a21\u578b\u66f4\u597d\u5730\u53cd\u6620\u5e02\u573a\u6761\u4ef6\u3002<\/li>\n\n\n\n<li><strong>\u591a\u6a21\u578b\u96c6\u6210<\/strong>\uff1a\u901a\u8fc7\u7ed3\u5408\u591a\u4e2a\u6a21\u578b\uff0c\u5982\u4f7f\u7528\u6295\u7968\u56de\u5f52\u5668\uff0c\u53ef\u4ee5\u63d0\u9ad8\u6a21\u578b\u7684\u9884\u6d4b\u80fd\u529b\u548c\u9c81\u68d2\u6027\u3002<\/li>\n\n\n\n<li><strong>\u6a21\u578b\u8bc4\u4f30\u6307\u6807<\/strong>\uff1a\u4f7f\u7528MAE\u3001MSE\u3001RMSE\u3001R\u00b2\u5206\u6570\u548cMAPE\u7b49\u8bc4\u4f30\u6307\u6807\u6765\u8861\u91cf\u6a21\u578b\u7684\u6027\u80fd\uff0c\u5e2e\u52a9\u7528\u6237\u4e86\u89e3\u6a21\u578b\u7684\u4f18\u52bf\u548c\u4e0d\u8db3\u3002<\/li>\n\n\n\n<li><strong>\u5b9e\u8df5\u548c\u5b9a\u5236<\/strong>\uff1a\u63d0\u4f9b\u4e86\u5b9e\u9645\u7684\u4ee3\u7801\u793a\u4f8b\u548cGoogle Colab\u7b14\u8bb0\u672c\uff0c\u9f13\u52b1\u8bfb\u8005\u52a8\u624b\u5b9e\u8df5\uff0c\u5e76\u6839\u636e\u81ea\u5df1\u7684\u4ea4\u6613\u98ce\u683c\u8c03\u6574\u6a21\u578b\u3002<\/li>\n<\/ul>\n\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\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<\/mark><\/strong><strong><mark style=\"background-color:#ffffff\" class=\"has-inline-color has-cyan-bluish-gray-color\">\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\n\n\n<p class=\"has-text-align-center\"><strong><mark style=\"background-color:#ffffff\" class=\"has-inline-color has-cyan-bluish-gray-color\">\u8f6c\u53d1\u8bf7\u6ce8\u660e\u539f\u4f5c\u8005\u548c\u51fa\u5904\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\/11\/13\/%e4%bb%85%e9%9c%80%e5%85%ab%e6%ad%a5%ef%bc%8c%e6%89%93%e9%80%a0%e7%a7%81%e4%ba%ba%e4%b8%93%e5%b1%9e%e8%82%a1%e7%a5%a8%e9%a2%84%e6%b5%8b%e6%a8%a1%e5%9e%8b\/\">Continue reading<span class=\"screen-reader-text\">\u4ec5\u9700\u516b\u6b65\uff0c\u6253\u9020\u79c1\u4eba\u4e13\u5c5e\u80a1\u7968\u9884\u6d4b\u6a21\u578b<\/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":[5,6],"class_list":["post-1625","post","type-post","status-publish","format-standard","hentry","category-aiinvest","tag-ai","tag-6","entry"],"_links":{"self":[{"href":"https:\/\/www.laoyulaoyu.com\/index.php\/wp-json\/wp\/v2\/posts\/1625","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=1625"}],"version-history":[{"count":1,"href":"https:\/\/www.laoyulaoyu.com\/index.php\/wp-json\/wp\/v2\/posts\/1625\/revisions"}],"predecessor-version":[{"id":1626,"href":"https:\/\/www.laoyulaoyu.com\/index.php\/wp-json\/wp\/v2\/posts\/1625\/revisions\/1626"}],"wp:attachment":[{"href":"https:\/\/www.laoyulaoyu.com\/index.php\/wp-json\/wp\/v2\/media?parent=1625"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.laoyulaoyu.com\/index.php\/wp-json\/wp\/v2\/categories?post=1625"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.laoyulaoyu.com\/index.php\/wp-json\/wp\/v2\/tags?post=1625"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}