{"id":1734,"date":"2024-12-23T07:28:00","date_gmt":"2024-12-22T23:28:00","guid":{"rendered":"https:\/\/blog.laoyulaoyu.top\/?p=1734"},"modified":"2024-11-29T09:46:21","modified_gmt":"2024-11-29T01:46:21","slug":"%e6%b6%a8%e8%b7%8c%e4%b8%8d%e5%86%8d%e9%9a%be%e9%a2%84%e6%b5%8b%ef%bc%81%e8%82%a1%e4%bb%b7%e9%a2%84%e6%b5%8b%e6%96%b0%e6%96%b9%e6%b3%95%ef%bc%9a%e5%af%b9%e6%95%b0%e5%9f%9fransac%e7%ba%bf%e6%80%a7","status":"publish","type":"post","link":"https:\/\/laoyulaoyu.com\/index.php\/2024\/12\/23\/%e6%b6%a8%e8%b7%8c%e4%b8%8d%e5%86%8d%e9%9a%be%e9%a2%84%e6%b5%8b%ef%bc%81%e8%82%a1%e4%bb%b7%e9%a2%84%e6%b5%8b%e6%96%b0%e6%96%b9%e6%b3%95%ef%bc%9a%e5%af%b9%e6%95%b0%e5%9f%9fransac%e7%ba%bf%e6%80%a7\/","title":{"rendered":"\u6da8\u8dcc\u4e0d\u518d\u96be\u9884\u6d4b\uff01\u80a1\u4ef7\u9884\u6d4b\u65b0\u65b9\u6cd5\uff1a\u5bf9\u6570\u57dfRANSAC\u7ebf\u6027\u56de\u5f52"},"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\/112901.png\" alt=\"\" class=\"wp-image-3168\"\/><\/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>\u4eca\u5929\u6211\u60f3\u5e26\u9886\u5927\u5bb6\u63a2\u7d22\u4e00\u79cd\u7528\u4e8e\u9884\u6d4b\u80a1\u7968\u4ef7\u683c\u7684\u7a33\u5065\u6280\u672f\uff1a\u5bf9\u6570\u57dfRANSAC\u7ebf\u6027\u56de\u5f52\u3002\u672c\u6587\u4f1a\u8be6\u7ec6\u9610\u8ff0\u5982\u4f55\u901a\u8fc7\u5bf9\u6570\u53d8\u6362\u548cRANSAC\u7b97\u6cd5\u6765\u63d0\u9ad8\u9884\u6d4b\u7684\u51c6\u786e\u6027\u548c\u7a33\u5065\u6027\uff0c\u7279\u522b\u662f\u5728\u5904\u7406\u975e\u7ebf\u6027\u5173\u7cfb\u548c\u6b63\u6001\u5316\u5206\u5e03\u65b9\u9762\u7684\u4f18\u52bf\u3002\u6211\u4eec\u4e0d\u4ec5\u4f1a\u8ba8\u8bba\u7406\u8bba\uff0c\u8fd8\u4f1a\u5c55\u793a\u5982\u4f55\u7528Python\u5b9e\u73b0\u8fd9\u4e00\u6a21\u578b\u9884\u6d4bAMZN\u80a1\u7968\u4ef7\u683c\u3002<mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-vivid-cyan-blue-color\">\u5982\u679c\u4f60\u5bf9\u91d1\u878d\u6570\u636e\u5206\u6790\u611f\u5174\u8da3\uff0c\u6216\u8005\u60f3\u4e86\u89e3\u5982\u4f55\u5c06\u673a\u5668\u5b66\u4e60\u5e94\u7528\u4e8e\u6295\u8d44\u9886\u57df\uff0c\u90a3\u4e48\u8fd9\u7bc7\u6587\u7ae0\u7edd\u5bf9\u4e0d\u5e94\u9519\u8fc7\u3002<\/mark><\/pre>\n<\/blockquote>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>\u4e00\u3001\u76ee\u6807\u3001\u6311\u6218\u4e0e\u65b9\u6cd5<\/strong><\/h2>\n\n\n\n<p>\u201cGiven a 10% chance of a 100 times payoff, you should take that bet every time.\u201d \u2014<a href=\"https:\/\/equito.co\/the-best-investing-quotes\/\">&nbsp;Jeff Bezos<\/a><br>&#8220;\u5982\u679c\u670910%\u7684\u673a\u4f1a\u83b7\u5f97100\u500d\u7684\u56de\u62a5\uff0c\u4f60\u6bcf\u6b21\u90fd\u5e94\u8be5\u4e0b\u8fd9\u4e2a\u8d4c\u6ce8&#8221;\u3002- \u6770\u592b-\u8d1d\u7d22\u65af<\/p>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>1.1 \u76ee\u6807<\/strong><\/h3>\n\n\n\n<p>\u6211\u4eec\u7684\u6700\u7ec8\u76ee\u6807\u662f\u5f00\u53d1\u51fa\u4e00\u4e9b\u7b80\u5355\u3001\u7a33\u5065\uff08\u5c3d\u7ba1\u5e76\u4e0d\u5b8c\u5168\u51c6\u786e\uff09\u4e14\u5177\u6709\u826f\u597d\u9884\u6d4b\u80fd\u529b\u7684\u65f6\u95f4\u5e8f\u5217\u9884\u6d4b\uff08TSF\uff09\u6a21\u578b\uff0c\u5e2e\u52a9\u6295\u8d44\u8005\u4ece\u5386\u53f2\u80a1\u7968\u6570\u636e\u4e2d\u89e3\u8bfb\u6a21\u5f0f\uff0c\u5e76\u5229\u7528\u5b83\u4eec\u5f62\u6210\u8f83\u4e3a\u53ef\u9760\u7684\u6570\u636e\u9a71\u52a8\u51b3\u7b56\u7b56\u7565\u3002<\/p>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>1.2 \u6311\u6218<\/strong><\/h3>\n\n\n\n<p>\u7531\u4e8e\u73b0\u5b9e\u91d1\u878d\u5e02\u573a\u7684\u4e0d\u786e\u5b9a\u6027\uff0c\u4f1a\u8ba9\u6570\u636e\u5982\u8fc7\u5c71\u8f66\u822c\u8d77\u4f0f\u4e0d\u5b9a\u3002\u90a3\u4e9b\u7a81\u5982\u5176\u6765\u7684\u6ce2\u52a8\u3001\u4ee4\u4eba\u63aa\u624b\u4e0d\u53ca\u7684\u5cf0\u503c\uff0c\u4ee5\u53ca\u8ba9\u4eba\u6478\u4e0d\u7740\u5934\u8111\u7684\u8d8b\u52bf\u8f6c\u53d8\uff0c\u90fd\u8ba9\u6211\u4eec\u7684\u8001\u670b\u53cb\u2014\u2014\u4f20\u7edf\u7684\u65f6\u95f4\u5e8f\u5217\u5206\u6790\uff08TSF\uff09\u6280\u672f\u663e\u5f97\u6709\u4e9b\u529b\u4e0d\u4ece\u5fc3\u3002\u5728\u8fd9\u4e2a\u5145\u6ee1\u53d8\u6570\u7684\u91d1\u878d\u821e\u53f0\u4e0a\uff0c\u6211\u4eec\u9700\u8981\u66f4\u5f3a\u5927\u7684\u5de5\u5177\u6765\u6d1e\u5bdf\u6570\u636e\u7684\u771f\u8c1b\u3002<\/p>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>1.3 \u65b9\u6cd5<\/strong><\/h3>\n\n\n\n<p>\u5728\u6574\u4e2a\u8fc7\u7a0b\u4e2d\uff0c\u6211\u4eec\u5c06\u6d4b\u8bd5\u548c\u8bc4\u4f30 Python \u4e2d\u7684\u5bf9\u6570\u57df RANSAC \u7ebf\u6027\u56de\u5f52\uff0c\u4ee5\u9884\u6d4b AMZN \u7684\u5386\u53f2\u4ef7\u683c\u3002<\/p>\n\n\n\n<p><strong>\u8981\u70b9 1\uff1a<\/strong>\u9996\u5148\uff0c\u6211\u4eec\u5f3a\u8c03\u5bf9\u6570\u7ebf\u6027\u56de\u5f52\u5728\u6295\u8d44 TSF \u4e2d\u7684\u5de8\u5927\u5546\u4e1a\u4ef7\u503c\u3002<\/p>\n\n\n\n<p>\u4e8b\u5b9e\u4e0a\uff0c\u5728 TSF \u6a21\u578b\u4e2d\u5bf9\u53d8\u91cf\u8fdb\u884c\u5bf9\u6570\u53d8\u6362\u662f\u5904\u7406\u975e\u7ebf\u6027\u5173\u7cfb\u548c\u5c06\u9ad8\u5ea6\u504f\u659c\u5206\u5e03\u8f6c\u5316\u4e3a\u66f4\u63a5\u8fd1\u6b63\u6001\u5206\u5e03\u7684\u4e00\u79cd\u975e\u5e38\u5e38\u89c1\u7684\u65b9\u6cd5\u3002<\/p>\n\n\n\n<p><strong>\u8981\u70b9 2\uff1a<\/strong>\u5176\u6b21\uff0c\u6211\u4eec\u91c7\u7528\u9c81\u68d2\u5171\u8bc6\u7b97\u6cd5 \uff0c\u5b83\u53ef\u4ee5\u53ea\u4f7f\u7528\u79bb\u7fa4\u503c\u6765\u8bad\u7ec3\u56de\u5f52\u6a21\u578b\uff0c\u540c\u65f6\u68c0\u6d4b\u5e76\u5254\u9664\u79bb\u7fa4\u503c\uff08\u5206\u522b\u4e0e\u6a21\u578b\u62df\u5408\u826f\u597d\u6216\u4e0d\u62df\u5408\u7684\u6570\u636e\u70b9\uff09\u3002<\/p>\n\n\n\n<p>\u5177\u4f53\u6765\u8bf4\uff0c\u6211\u4eec\u5173\u6ce8\u7684\u662f\u968f\u673a\u6837\u672c\u5171\u8bc6\uff08RANSAC\uff09\uff1a\u8fd9\u662f\u4e00\u79cd\u8fed\u4ee3\u76d1\u7763\u5f0f ML \u7b97\u6cd5\uff0c\u901a\u8fc7\u5728\u8bad\u7ec3\u8fc7\u7a0b\u4e2d\u6392\u9664\u5f02\u5e38\u503c\uff0c\u5c06\u7ebf\u6027\u56de\u5f52\u7b97\u6cd5\u63d0\u5347\u5230\u4e00\u4e2a\u65b0\u7684\u6c34\u5e73\u3002<\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>\u4e8c\u3001<strong>\u65b9\u6cd5<\/strong>\u5b9e\u73b0<\/strong><\/h2>\n\n\n\n<p><\/p>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>2.1 \u6570\u636e\u51c6\u5907<\/strong><\/h3>\n\n\n\n<p>\u9996\u5148\u8fd8\u662f\u8bfb\u53d6\u5e76\u7ed8\u5236 AMZN \u80a1\u7968\u6570\u636e\u3002<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>import numpy as np\nimport matplotlib.pyplot as plt\nimport warnings\nwarnings.filterwarnings('ignore')\nimport pandas as pd\n\nimport seaborn as sns\nfrom matplotlib import pyplot as plt\n\ndf = pd.read_csv('AMZN_2006-01-01_to_2018-01-01.csv')\n\ndf.tail()\n\n     Date       Open     High    Low    Close    Volume Name\n3014 2017-12-22 1172.08 1174.62 1167.83 1168.36 1585054 AMZN\n3015 2017-12-26 1168.36 1178.32 1160.55 1176.76 2005187 AMZN\n3016 2017-12-27 1179.91 1187.29 1175.61 1182.26 1867208 AMZN\n3017 2017-12-28 1189.00 1190.10 1184.38 1186.10 1841676 AMZN\n3018 2017-12-29 1182.35 1184.00 1167.50 1169.47 2688391 AMZN\n\ndf&#91;'Close'].plot()\nplt.title('AMZN Close Price')\nplt.ylabel('Price USD')\nplt.xlabel('Day Number')\nplt.grid()\nplt.show()<\/code><\/pre>\n\n\n\n<p>\u4e0b\u56fe\u662f AMZN \u7684\u6536\u76d8\u4ef7\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\/11\/image-149.png\" alt=\"\" class=\"wp-image-3169\"\/><\/figure>\n\n\n\n<p>\u63a5\u7740\u8fdb\u884c\u6570\u636e\u51c6\u5907\u548c\u5bf9\u6570\u8f6c\u6362\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>df1=df.reset_index(drop=False)\ndf2=df1.rename(columns={\"index\": \"Days\", \"Close\": \"Price\"}, errors=\"raise\")\n\n# Calculate the logarithm of the price and add it as a new column 'Log_Price'\ndf2&#91;'Log_Price'] = np.log10(df2&#91;'Price'])\n\n# drop first 10 rows\ndf3=df2.iloc&#91;10:, :]<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>2.2 RANSAC \u7ebf\u6027\u56de\u5f52<\/strong><\/h3>\n\n\n\n<p>\u5b9e\u65bd RANSAC \u7ebf\u6027\u56de\u5f52\u7b97\u6cd5\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>#The RANSAC Model\n# Import relevant libraries and modules\nfrom sklearn.linear_model import RANSACRegressor\nfrom sklearn.linear_model import LinearRegression\nfrom sklearn.metrics import r2_score\n\n# Instantiate the RANSAC Regressor with 'residual_threshold' = 0.1 and fit the model\nransacReg = RANSACRegressor(LinearRegression(), residual_threshold = 0.1, random_state = 0)\nmodel4 = ransacReg.fit(df2&#91;&#91;'Days']], df2&#91;'Log_Price'])\n\n# Label the inliers and add them as a column in a new dataframe 'data_ransac'\ninlier = ransacReg.inlier_mask_\ndata_ransac = df2.copy(deep=True)\ndata_ransac&#91;'Inlier_Ransac']= inlier\n\n# Drop the outliers from the 'data_ransac' dataframe\ndata_ransac.drop(data_ransac&#91;data_ransac&#91;'Inlier_Ransac'] == False].index, axis=0, inplace=True)\n\n# Calculate the ratio of inliers after RANSAC regression\nprint('Ratio inliers vs total after RANSAC regression: ', len(data_ransac)\/len(df2))\n\n# Predict the model and calculate the R2 score\npred_model4 = ransacReg.predict(data_ransac&#91;&#91;'Days']])\nprint ('R2 score after RANSAC regression: ', r2_score(data_ransac&#91;'Log_Price'], pred_model4))\n\nRatio inliers vs total after RANSAC regression:  0.7373302418019212\nR2 score after RANSAC regression:  0.9866383665012699<\/code><\/pre>\n\n\n\n<p>\u7ed8\u5236\u53bb\u9664 RANSAC \u79bb\u7fa4\u503c\u540e\u7684 AMZN \u5386\u53f2\u4ef7\u683c\u6570\u636e\u56fe\u3002<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code># Plot the data\nplt.figure(figsize=(6,4))\nplt.scatter(data_ransac&#91;'Days'],data_ransac&#91;'Log_Price'], color = 'k', s=1)\nplt.xlabel('Days')\nplt.ylabel('Log price')\nplt.grid()\nplt.title('Historical price data of AMZN after RANSAC');<\/code><\/pre>\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-150.png\" alt=\"\" class=\"wp-image-3170\"\/><\/figure>\n\n\n\n<p>\u53ef\u4ee5\u770b\u5230\uff0c\u5728\u53bb\u9664 RANSAC \u5f02\u5e38\u503c\u540e\u7684 AMZN \u5386\u53f2\u4ef7\u683c\u6570\u636e\u4e2d\uff0cRANSAC \u6a21\u578b\u68c0\u6d4b\u5230\u4e86\u5f02\u5e38\u503c\u5e76\u5c06\u5176\u5ffd\u7565\u3002<\/p>\n\n\n\n<p>\u63a5\u4e0b\u6765\u8ba9\u6211\u4eec\u5c06\u4f20\u7edf\u7684 scikit-learn \u7ebf\u6027\u56de\u5f52\u5e94\u7528\u4e8e\u4e0a\u8ff0\u6570\u636e\u96c6\u3002<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code># Import relevant libraries and modules\nfrom sklearn import linear_model\nfrom sklearn.model_selection import train_test_split\nfrom sklearn import metrics\n\n# Define X and y and split the data into 75% train and 25% test\nX_ransac=data_ransac&#91;&#91;'Days']]\ny_ransac=data_ransac&#91;'Log_Price']\nX_train_ransac,X_test_ransac,y_train_ransac,y_test_ransac = train_test_split(X_ransac,y_ransac,test_size = 0.25, random_state = 1)\n\n# Instantiate the model and fit the training data\nreg_ransac = linear_model.LinearRegression()\nresult_ransac = reg_ransac.fit(X_train_ransac,y_train_ransac)\n\n# Calculate the coefficients and intercept\ncoefficients = reg_ransac.coef_\nprint(f'slope: {coefficients}')\ninterception = reg_ransac.intercept_\nprint(f'intercept: {interception}')\n\n# Validate the model comparing the test data with the predicted data and calculate the R2 score\ny_pred_ransac = reg_ransac.predict(X_test_ransac)\nprint('R2 score RANSAC Model:', metrics.r2_score(y_pred_ransac,y_test_ransac))\n\n# Plot the model\nplt.figure(figsize=(6,4))\nplt.scatter(X_ransac,y_ransac, color = 'k', label='Historical AMZN price after RANSAC regression', s=1)\nplt.plot(X_test_ransac,y_pred_ransac, color = 'b', label = 'RANSAC Model')\nplt.xlabel('Days')\nplt.ylabel('Log price')\nplt.grid()\nplt.legend();\n\nslope: &#91;0.00047224]\nintercept: 1.5990502549514787\nR2 score RANSAC Model: 0.9865737820332889<\/code><\/pre>\n\n\n\n<p>\u4e0b\u56fe\u662fRANSAC \u56de\u5f52\u540e\u7684 AMZN \u5386\u53f2\u4ef7\u683c\u4e0e RANSAC \u7ebf\u6027\u56de\u5f52\u6a21\u578b\u5bf9\u6bd4\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\/11\/image-151.png\" alt=\"\" class=\"wp-image-3171\"\/><\/figure>\n\n\n\n<p>\u63a5\u7740\u6211\u4eec\u6765\u5236\u4f5c\u53cd\u5bf9\u6570\u53d8\u6362\u540e\u7684 AMZN \u4ef7\u683c\u4e0e RANSAC \u9884\u6d4b\u503c\u5bf9\u6bd4\u56fe<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">pred_ransac_model = ransacReg.predict(df2[['Days']])\ndf2['Hist_Pred_Log_Price_Ransac_Model']=pred_ransac_model\n\n# Calculate back the predicted normal price.\ndf2['Hist_Pred_Price_Ransac_Model']=10**(df2['Hist_Pred_Log_Price_Ransac_Model'])\n\nplt.plot(df2[['Days']],df2['Hist_Pred_Price_Ransac_Model'],label='RANSAC Prediction')\nplt.plot(df2[['Days']],df2['Price'],label='AMZN Price')\nplt.xlabel('Days')\nplt.ylabel('Price USD')\nplt.grid()\nplt.legend();<\/pre>\n\n\n\n<p>\u4e0b\u56fe\u662f\u53cd\u5bf9\u6570\u53d8\u6362\u540e\u7684 AMZN \u4ef7\u683c\u4e0e RANSAC \u9884\u6d4b\u503c\u5bf9\u6bd4\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\/11\/image-152.png\" alt=\"\" class=\"wp-image-3172\"\/><\/figure>\n\n\n\n<p><\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>\u4e09\u3001\u5bf9\u6570\u8f6c\u6362\u7684\u5f71\u54cd\u5206\u6790<\/strong><\/h2>\n\n\n\n<p>\u6211\u4eec\u53ef\u4ee5\u901a\u8fc7\u5b9e\u4f8b\u5316\u7edf\u8ba1\u6a21\u578b OLS \u56de\u5f52 [1] \u6765\u8bc4\u4f30\u5bf9\u6570\u53d8\u6362 (LT) \u7684\u5f71\u54cd\u3002<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code># Import relevant libraries and modules\nimport statsmodels.api as sm\nfrom statsmodels.formula.api import ols<\/code><\/pre>\n\n\n\n<p>\u5728 LT \u4e4b\u524d\u62df\u5408 OLS \u516c\u5f0f ols_formula = &#8216;Price ~ Days&#8217; (\u4ef7\u683c ~ \u5929\u6570)<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>ols_formula = 'Price ~ Days'\nOLS = ols(formula = ols_formula, data = df2)\nmodel = OLS.fit()\nmodel_results = model.summary()\nprint(model_results)\n\n OLS Regression Results                            \n=============================================================================\nDep. Variable:                  Price   R-squared:                       0.795\nModel:                            OLS   Adj. R-squared:                  0.794\nMethod:                 Least Squares   F-statistic:                 1.167e+04\nDate:                Mon, 25 Nov 2024   Prob (F-statistic):               0.00\nTime:                        12:17:38   Log-Likelihood:                -18906.\nNo. Observations:                3019   AIC:                         3.782e+04\nDf Residuals:                    3017   BIC:                         3.783e+04\nDf Model:                           1                                         \nCovariance Type:            nonrobust                                         \n=============================================================================\n                 coef    std err          t      P&gt;|t|      &#91;0.025      0.975]\n------------------------------------------------------------------------------\nIntercept   -132.6695      4.619    -28.722      0.000    -141.726    -123.613\nDays           0.2863      0.003    108.014      0.000       0.281       0.292\n=============================================================================\nOmnibus:                      346.632   Durbin-Watson:                   0.003\nProb(Omnibus):                  0.000   Jarque-Bera (JB):              478.601\nSkew:                           0.906   Prob(JB):                    1.18e-104\nKurtosis:                       3.723   Cond. No.                     3.48e+03\n=============================================================================<\/code><\/pre>\n\n\n\n<p>\u5728 LT \u4e4b\u540e\u62df\u5408 OLS \u516c\u5f0f ols_formula = &#8220;\u4ef7\u683c ~ \u5929\u6570<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>ols_formula2 = 'Log_Price ~ Days'\nOLS2 = ols(formula = ols_formula2, data = df2)\nmodel2 = OLS2.fit()\nmodel_results2 = model2.summary()\nprint(model_results2)\n\n OLS Regression Results                            \n=============================================================================\nDep. Variable:              Log_Price   R-squared:                       0.964\nModel:                            OLS   Adj. R-squared:                  0.964\nMethod:                 Least Squares   F-statistic:                 8.141e+04\nDate:                Mon, 25 Nov 2024   Prob (F-statistic):               0.00\nTime:                        12:17:49   Log-Likelihood:                 3284.7\nNo. Observations:                3019   AIC:                            -6565.\nDf Residuals:                    3017   BIC:                            -6553.\nDf Model:                           1                                         \nCovariance Type:            nonrobust                                         \n=============================================================================\n                 coef    std err          t      P&gt;|t|      &#91;0.025      0.975]\n------------------------------------------------------------------------------\nIntercept      1.5478      0.003    521.574      0.000       1.542       1.554\nDays           0.0005    1.7e-06    285.316      0.000       0.000       0.000\n=============================================================================\nOmnibus:                      109.395   Durbin-Watson:                   0.018\nProb(Omnibus):                  0.000   Jarque-Bera (JB):              136.849\nSkew:                          -0.404   Prob(JB):                     1.92e-30\nKurtosis:                       3.659   Cond. No.                     3.48e+03\n=============================================================================<\/code><\/pre>\n\n\n\n<p><strong>\u63a8\u8bba\uff1a<\/strong><\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>F-Statistic (after LT) \/ F-Statistic (before LT) ~ 7.3\u3002\u8fd9\u610f\u5473\u7740 LT \u540e\u7684 OLS \u5728\u7edf\u8ba1\u610f\u4e49\u4e0a\u6bd4 LT \u524d\u7684 OLS \u66f4\u663e\u8457\u3002<\/li>\n\n\n\n<li>F-Statistic (before LT) \/ F-Statistic (after LT) | ~ 2.2\u3002\u8fd9\u610f\u5473\u7740 LT \u540e\u7684 OLS \u6b8b\u5dee\u6bd4 LT \u524d\u7684\u6b8b\u5dee\u504f\u659c\u7a0b\u5ea6\u5c0f\u4e24\u500d\u3002<\/li>\n\n\n\n<li>\u6807\u51c6\u5dee\u8bef\u5dee\uff08LT \u524d\uff09\/\u6807\u51c6\u5dee\u8bef\u5dee\uff08LT \u540e\uff09~ 1540\u3002\u6807\u51c6\u504f\u5dee\u8d8a\u5c0f\uff0c\u8bf4\u660e\u6211\u4eec\u7684\u6570\u636e\u70b9\u8d8a\u63a5\u8fd1\u56de\u5f52\u7ebf\uff0c\u8868\u660e\u6211\u4eec\u7684\u6a21\u578b\u62df\u5408\u5ea6\u8d8a\u9ad8\u3002<\/li>\n\n\n\n<li>R2\uff08LT \u540e\uff09- R2\uff08LT \u524d\uff09~ 0.169\u3002\u56de\u60f3\u4e00\u4e0b\uff0cR2\uff08R \u5e73\u65b9\uff09\u8868\u793a\u56e0\u53d8\u91cf\u4e2d\u53ef\u7531\u81ea\u53d8\u91cf\u89e3\u91ca\u7684\u65b9\u5dee\u6bd4\u4f8b\u3002\u6211\u4eec\u53ef\u4ee5\u770b\u5230\uff0cLT \u540e\u7684\u89e3\u91ca\u53d8\u5f02\u6bd4\u4f8b\u6bd4 LT \u524d\u9ad8 17%\u3002<\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>\u56db\u3001\u89c2\u70b9\u603b\u7ed3<\/strong><\/h2>\n\n\n\n<p>\u5728\u672c\u6587\u4e2d\uff0c\u6211\u4eec\u4f7f\u7528\u5bf9\u6570\u57df RANSAC \u7ebf\u6027\u56de\u5f52\u6765\u9884\u6d4b AMZN \u7684\u4ef7\u683c\u8d70\u52bf\u3002\u9996\u5148\uff0c\u6211\u4eec\u8bc1\u660e\u4e86 RANSAC \u53ef\u4ee5\u5e2e\u52a9\u8bc6\u522b\u548c\u5904\u7406\u56de\u5f52\u4e2d\u7684\u5f02\u5e38\u503c\u3002\u5728\u5904\u7406\u6709\u566a\u58f0\u7684\u80a1\u7968\u6570\u636e\u65f6\uff0c\u5b83\u662f\u4e00\u79cd\u57fa\u7840\u7b97\u6cd5\u3002<\/p>\n\n\n\n<p>\u5176\u6b21\uff0c\u6211\u4eec\u5df2\u7ecf\u8bc1\u660e\uff0c\u4f7f\u7528\u80a1\u7968\u4ef7\u683c\u7684\u5bf9\u6570\u800c\u4e0d\u662f\u5b9e\u9645\u4ef7\u683c\u503c\u662f\u5408\u9002\u7684\u3002\u5bf9\u6570\u53d8\u6362\u662f\u4e00\u79cd\u65b9\u4fbf\u7684\u65b9\u6cd5\uff0c\u53ef\u4ee5\u5c06\u9ad8\u5ea6\u504f\u659c\u7684\u53d8\u91cf\u8f6c\u6362\u4e3a\u66f4\u52a0\u6b63\u5e38\u5316\u7684\u6570\u636e\u96c6\u3002\u5b83\u7528\u4e8e\u4ece\u7ebf\u6027\u56de\u5f52\u6a21\u578b\u4e2d\u5f97\u51fa\u66f4\u597d\u7684\u9884\u6d4b\u7ed3\u679c\u3002<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>\u5bf9\u6570\u53d8\u6362\u80fd\u591f\u6709\u6548\u5730\u5c06\u9ad8\u5ea6\u504f\u659c\u7684\u80a1\u7968\u4ef7\u683c\u6570\u636e\u8f6c\u6362\u4e3a\u66f4\u63a5\u8fd1\u6b63\u6001\u5206\u5e03\u7684\u6570\u636e\u96c6\uff0c\u4ece\u800c\u63d0\u9ad8\u4e86\u7ebf\u6027\u56de\u5f52\u6a21\u578b\u7684\u62df\u5408\u5ea6\u548c\u9884\u6d4b\u51c6\u786e\u6027\u3002<\/li>\n\n\n\n<li>RANSAC \u7b97\u6cd5\u662f\u4e00\u79cd\u9c81\u68d2\u7684\u5171\u8bc6\u7b97\u6cd5\uff0c\u5b83\u80fd\u591f\u901a\u8fc7\u8bc6\u522b\u548c\u6392\u9664\u5f02\u5e38\u503c\u6765\u63d0\u9ad8\u6a21\u578b\u7684\u6cdb\u5316\u80fd\u529b\uff0c\u7279\u522b\u662f\u5728\u5904\u7406\u6709\u566a\u58f0\u7684\u91d1\u878d\u65f6\u95f4\u5e8f\u5217\u6570\u636e\u65f6\u3002<\/li>\n\n\n\n<li>\u901a\u8fc7\u6bd4\u8f83 LT \u524d\u540e\u7684 OLS \u56de\u5f52\u6a21\u578b\u7684 F-Statistic\u3001STD Error \u548c R2 \u503c\uff0c\u672c\u6587\u8bc1\u660e\u4e86\u5bf9\u6570\u53d8\u6362\u5728\u6539\u5584\u6a21\u578b\u7edf\u8ba1\u6027\u80fd\u65b9\u9762\u7684\u663e\u8457\u4f5c\u7528\u3002<\/li>\n\n\n\n<li>\u901a\u8fc7\u672c\u6587\u8bc1\u660e\u4e86 RANSAC \u56de\u5f52\u5728\u8fd9\u4e00\u9886\u57df\u4e2d\u7684\u5e94\u7528\u6f5c\u529b\u3002\u800c\u4e14\u5728\u5b9e\u9645\u6295\u8d44\u9884\u6d4b\u4e2d\u4f7f\u7528\u591a\u79cd\u673a\u5668\u5b66\u4e60\u65b9\u6cd5\u7684\u5f88\u91cd\u8981\u3002<\/li>\n<\/ul>\n\n\n\n<p><em>\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<\/em><\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<p class=\"has-text-align-center\" id=\"a1c6\">\u672c\u6587\u5185\u5bb9\u4ec5\u9650\u6280\u672f\u63a2\u8ba8\u548c\u5b66\u4e60\uff0c\u4e0d\u6784\u6210\u4efb\u4f55\u6295\u8d44\u5efa\u8bae\u3002<\/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:\/\/laoyulaoyu.com\/index.php\/2024\/12\/23\/%e6%b6%a8%e8%b7%8c%e4%b8%8d%e5%86%8d%e9%9a%be%e9%a2%84%e6%b5%8b%ef%bc%81%e8%82%a1%e4%bb%b7%e9%a2%84%e6%b5%8b%e6%96%b0%e6%96%b9%e6%b3%95%ef%bc%9a%e5%af%b9%e6%95%b0%e5%9f%9fransac%e7%ba%bf%e6%80%a7\/\">Continue reading<span class=\"screen-reader-text\">\u6da8\u8dcc\u4e0d\u518d\u96be\u9884\u6d4b\uff01\u80a1\u4ef7\u9884\u6d4b\u65b0\u65b9\u6cd5\uff1a\u5bf9\u6570\u57dfRANSAC\u7ebf\u6027\u56de\u5f52<\/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-1734","post","type-post","status-publish","format-standard","hentry","category-aiinvest","tag-ai","tag-6","entry"],"_links":{"self":[{"href":"https:\/\/laoyulaoyu.com\/index.php\/wp-json\/wp\/v2\/posts\/1734","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/laoyulaoyu.com\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/laoyulaoyu.com\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/laoyulaoyu.com\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/laoyulaoyu.com\/index.php\/wp-json\/wp\/v2\/comments?post=1734"}],"version-history":[{"count":2,"href":"https:\/\/laoyulaoyu.com\/index.php\/wp-json\/wp\/v2\/posts\/1734\/revisions"}],"predecessor-version":[{"id":1736,"href":"https:\/\/laoyulaoyu.com\/index.php\/wp-json\/wp\/v2\/posts\/1734\/revisions\/1736"}],"wp:attachment":[{"href":"https:\/\/laoyulaoyu.com\/index.php\/wp-json\/wp\/v2\/media?parent=1734"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/laoyulaoyu.com\/index.php\/wp-json\/wp\/v2\/categories?post=1734"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/laoyulaoyu.com\/index.php\/wp-json\/wp\/v2\/tags?post=1734"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}