{"id":97236,"date":"2022-02-21T14:15:09","date_gmt":"2022-02-21T06:15:09","guid":{"rendered":"http:\/\/www.zhushiyao.com\/?p=97236"},"modified":"2022-02-21T14:15:50","modified_gmt":"2022-02-21T06:15:50","slug":"884a548a3c","status":"publish","type":"post","link":"http:\/\/www.zhushiyao.com\/?p=97236","title":{"rendered":"Python+\u673a\u5668\u5b66\u4e60\u5bfb\u627e\u80a1\u7968\u4ea4\u6613\u4fe1\u53f7"},"content":{"rendered":"<div class=\"bpp-post-content\">\n<section style=\"white-space: normal;\">\n<section style=\"white-space: normal;\">\n<section style=\"white-space: normal;\">\n<section style=\"white-space: normal;\">\n<section style=\"white-space: normal;\">\n<section style=\"white-space: normal;\">\n<section style=\"white-space: normal;\"><\/section>\n<\/section>\n<\/section>\n<\/section>\n<\/section>\n<p style=\"white-space: normal;\">\n<section style=\"white-space: normal;\">\n<section>\n<section>\n<section style=\"margin: 10px auto;\">\n<section style=\"display: flex; justify-content: center;\">\n<section>\n<section style=\"display: flex;\">\n<section style=\"padding-right: 6px; padding-left: 6px; color: white; background-color: #3b5cf4; line-height: 1.75em; letter-spacing: 1px; font-size: 16px;\">0\u00a0<span title=\"\">1<\/span><\/section>\n<section style=\"padding-right: 8px; padding-left: 8px; color: #3b5cf4; letter-spacing: 1.5px; line-height: 1.75em; font-size: 16px;\">\u5f15\u8a00<\/section>\n<\/section>\n<section style=\"margin-top: 3px; display: flex; justify-content: center; align-items: center;\">\n<section style=\"width: 60.9375px; height: 2px; background: #3b5cf4; overflow: hidden;\"><\/section>\n<section style=\"width: 26.1172px; height: 2px; background: #ffc756; overflow: hidden;\"><\/section>\n<\/section>\n<\/section>\n<\/section>\n<\/section>\n<\/section>\n<p><span style=\"font-size: 15px;\">\u8fd1\u5e74\u6765<\/span><span style=\"font-family: mp-quote, -apple-system-font, BlinkMacSystemFont, 'Helvetica Neue', 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei UI', 'Microsoft YaHei', Arial, sans-serif; font-size: 15px;\">\uff0c\u968f\u7740\u6280\u672f\u7684\u53d1\u5c55\uff0c\u673a\u5668\u5b66\u4e60\u548c\u6df1\u5ea6\u5b66\u4e60\u5728\u91d1\u878d\u8d44\u4ea7\u91cf\u5316\u7814\u7a76\u4e0a\u7684\u5e94\u7528\u8d8a\u6765\u8d8a\u5e7f\u6cdb\u548c\u6df1\u5165\u3002\u76ee\u524d\uff0c\u5927\u91cf\u6570\u636e\u79d1\u5b66\u5bb6\u5728Kaggle\u7f51\u7ad9\u4e0a\u53d1\u5e03\u4e86\u4f7f\u7528\u673a\u5668\u5b66\u4e60\/\u6df1\u5ea6\u5b66\u4e60\u6a21\u578b\u5bf9\u80a1\u7968\u3001\u671f\u8d27\u3001\u6bd4\u7279\u5e01\u7b49\u91d1\u878d\u8d44\u4ea7\u505a\u9884\u6d4b\u548c\u5206\u6790\u7684\u6587\u7ae0\u3002\u4ece\u91d1\u878d\u6295\u8d44\u7684\u89d2\u5ea6\u770b\uff0c\u8fd9\u4e9b\u6587\u7ae0\u53ef\u80fd\u7f3a\u4e4f\u4e00\u5b9a\u7684\u7406\u8bba\u57fa\u7840\u652f\u6491\uff08\u6216\u4ea4\u6613\u601d\u7ef4\uff09\uff0c\u5927\u90fd\u662f\u57fa\u4e8e\u6570\u636e\u6316\u6398\u3002\u4f46\u4ece\u91cf\u5316\u7684\u89d2\u5ea6\u770b\uff0c\u6709\u5f88\u591a\u503c\u5f97\u6211\u4eec\u5b66\u4e60\u53c2\u8003\u7684\u5730\u65b9\uff0c\u5c24\u5176\u662fPyhton\u7684\u6df1\u5165\u5e94\u7528\u3001\u6570\u636e\u53ef\u89c6\u5316\u548c\u673a\u5668\u5b66\u4e60\u6a21\u578b\u7684\u8bc4\u4f30\u4e0e\u4f18\u5316\u7b49\u3002\u4e0b\u9762\u501f\u9274<\/span><span style=\"font-family: mp-quote, -apple-system-font, BlinkMacSystemFont, 'Helvetica Neue', 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei UI', 'Microsoft YaHei', Arial, sans-serif; caret-color: red; font-size: 15px;\">Kaggle\u4e0a\u7684\u4e00\u7bc7\u6587\u7ae0\u300a<\/span><span style=\"font-family: mp-quote, -apple-system-font, BlinkMacSystemFont, 'Helvetica Neue', 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei UI', 'Microsoft YaHei', Arial, sans-serif; caret-color: red; font-size: 15px;\">Building an Asset Trading Strategy<\/span><span style=\"font-family: mp-quote, -apple-system-font, BlinkMacSystemFont, 'Helvetica Neue', 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei UI', 'Microsoft YaHei', Arial, sans-serif; caret-color: red; font-size: 15px;\">\u300b\uff0c\u4ee5\u4e0a\u8bc1\u6307\u6570\u4e3a\u4f8b\uff0c\u6784\u5efa\u53cc\u5747\u7ebf\u4ea4\u6613\u7b56\u7565\uff0c\u4ee5\u4ea4\u6613\u4fe1\u53f7\u4e3a\u76ee\u6807\u53d8\u91cf\uff0c\u4ee5\u6280\u672f\u5206\u6790\u6307\u6807\u4f5c\u4e3a\u9884\u6d4b\u7279\u5f81\u53d8\u91cf\uff0c\u4f7f\u7528\u591a\u79cd\u673a\u5668\u5b66\u4e60\u6a21\u578b\u8fdb\u884c\u5bf9\u6bd4\u8bc4\u4f30\u548c\u4f18\u5316\u3002\u6587\u4e2d\u7684\u7279\u5f81\u53d8\u91cf\u6784\u5efa\u548c\u63d0\u53d6\uff0c\u673a\u5668\u5b66\u4e60\u6a21\u578b\u7684\u5bf9\u6bd4\u8bc4\u4f30\u548c\u7ed3\u679c\u53ef\u89c6\u5316\u90fd\u662f\u5f88\u597d\u7684\u53c2\u8003\u6a21\u677f\u3002<\/span><\/p>\n<\/section>\n<\/section>\n<p style=\"text-align: justify;\"><span style=\"caret-color: red; font-size: 15px;\">\u00a0<\/span><\/p>\n<section>\n<section style=\"margin: 10px auto;\">\n<section style=\"display: flex; justify-content: center;\">\n<section>\n<section style=\"display: flex;\">\n<section style=\"color: white; background-color: #3b5cf4; padding-right: 6px; padding-left: 6px; line-height: 1.75em; letter-spacing: 1px; font-size: 16px;\">0<span title=\"\">2<\/span><\/section>\n<section style=\"color: #3b5cf4; padding-right: 8px; padding-left: 8px; letter-spacing: 1.5px; line-height: 1.75em; font-size: 16px;\">\u6570\u636e\u83b7\u53d6\u4e0e\u6307\u6807\u6784\u5efa<\/section>\n<\/section>\n<section style=\"display: flex; justify-content: center; align-items: center; margin-top: 3px;\">\n<section style=\"width: 70%; height: 2px; background: #3b5cf4; overflow: hidden;\"><\/section>\n<section style=\"width: 30%; height: 2px; background: #ffc756; overflow: hidden;\"><\/section>\n<\/section>\n<\/section>\n<\/section>\n<\/section>\n<\/section>\n<p style=\"text-align: justify;\">\n<p style=\"text-align: justify;\"><span style=\"font-size: 15px;\">\u5148\u5f15\u5165\u9700\u8981\u7528\u5230\u7684libraries\uff0c\u8fd9\u662fPython\u8bed\u8a00\u7684\u7a81\u51fa\u7279\u70b9\u4e4b\u4e00\u3002\u8fd9\u4e9b\u6d89\u53ca\u5230\u7684\u5305\u6bd4\u8f83\u591a\uff0c\u5305\u62ec\u5e38\u7528\u7684numpy\u3001pandas\u3001matplotlib\uff0c\u6280\u672f\u5206\u6790talib\uff0c\u673a\u5668\u5b66\u4e60sklearn\u548c\u6570\u636e\u5305tushare\u7b49\u3002<\/span><\/p>\n<section>\n<pre style=\"font-size: inherit; color: inherit; line-height: inherit;\"><code style=\"margin-right: 2px; margin-left: 2px; line-height: 15px; font-size: 11px; word-spacing: -3px; letter-spacing: 0px; border-radius: 0px; color: #a9b7c6; background: #282b2e; padding: 0.5em; font-family: Consolas, Inconsolata, Courier, monospace; overflow-wrap: normal !important; word-break: normal !important; overflow: auto !important; display: -webkit-box !important;\"><span style=\"font-size: inherit; line-height: inherit; color: #808080; overflow-wrap: inherit !important; word-break: inherit !important;\">#\u5148\u5f15\u5165\u540e\u9762\u53ef\u80fd\u7528\u5230\u7684libraries<\/span>\n<span style=\"font-size: inherit; line-height: inherit; color: #f82375; overflow-wrap: inherit !important; word-break: inherit !important;\">import<\/span>\u00a0numpy\u00a0<span style=\"font-size: inherit; line-height: inherit; color: #f82375; overflow-wrap: inherit !important; word-break: inherit !important;\">as<\/span>\u00a0np\n<span style=\"font-size: inherit; line-height: inherit; color: #f82375; overflow-wrap: inherit !important; word-break: inherit !important;\">import<\/span>\u00a0pandas\u00a0<span style=\"font-size: inherit; line-height: inherit; color: #f82375; overflow-wrap: inherit !important; word-break: inherit !important;\">as<\/span>\u00a0pd\u00a0\u00a0\n<span style=\"font-size: inherit; line-height: inherit; color: #f82375; overflow-wrap: inherit !important; word-break: inherit !important;\">import<\/span>\u00a0tushare\u00a0<span style=\"font-size: inherit; line-height: inherit; color: #f82375; overflow-wrap: inherit !important; word-break: inherit !important;\">as<\/span>\u00a0ts\n<span style=\"font-size: inherit; line-height: inherit; color: #808080; overflow-wrap: inherit !important; word-break: inherit !important;\">#\u6280\u672f\u6307\u6807<\/span>\n<span style=\"font-size: inherit; line-height: inherit; color: #f82375; overflow-wrap: inherit !important; word-break: inherit !important;\">import<\/span>\u00a0talib\u00a0<span style=\"font-size: inherit; line-height: inherit; color: #f82375; overflow-wrap: inherit !important; word-break: inherit !important;\">as<\/span>\u00a0ta\n<span style=\"font-size: inherit; line-height: inherit; color: #808080; overflow-wrap: inherit !important; word-break: inherit !important;\">#\u673a\u5668\u5b66\u4e60\u6a21\u5757<\/span>\n<span style=\"font-size: inherit; line-height: inherit; color: #f82375; overflow-wrap: inherit !important; word-break: inherit !important;\">from<\/span>\u00a0sklearn.linear_model\u00a0<span style=\"font-size: inherit; line-height: inherit; color: #f82375; overflow-wrap: inherit !important; word-break: inherit !important;\">import<\/span>\u00a0LogisticRegression\n<span style=\"font-size: inherit; line-height: inherit; color: #f82375; overflow-wrap: inherit !important; word-break: inherit !important;\">from<\/span>\u00a0sklearn.discriminant_analysis\u00a0<span style=\"font-size: inherit; line-height: inherit; color: #f82375; overflow-wrap: inherit !important; word-break: inherit !important;\">import<\/span>\u00a0LinearDiscriminantAnalysis\n<span style=\"font-size: inherit; line-height: inherit; color: #f82375; overflow-wrap: inherit !important; word-break: inherit !important;\">from<\/span>\u00a0sklearn.neighbors\u00a0<span style=\"font-size: inherit; line-height: inherit; color: #f82375; overflow-wrap: inherit !important; word-break: inherit !important;\">import<\/span>\u00a0KNeighborsClassifier\n<span style=\"font-size: inherit; line-height: inherit; color: #f82375; overflow-wrap: inherit !important; word-break: inherit !important;\">from<\/span>\u00a0sklearn.tree\u00a0<span style=\"font-size: inherit; line-height: inherit; color: #f82375; overflow-wrap: inherit !important; word-break: inherit !important;\">import<\/span>\u00a0DecisionTreeClassifier\n<span style=\"font-size: inherit; line-height: inherit; color: #f82375; overflow-wrap: inherit !important; word-break: inherit !important;\">from<\/span>\u00a0sklearn.naive_bayes\u00a0<span style=\"font-size: inherit; line-height: inherit; color: #f82375; overflow-wrap: inherit !important; word-break: inherit !important;\">import<\/span>\u00a0GaussianNB\n<span style=\"font-size: inherit; line-height: inherit; color: #f82375; overflow-wrap: inherit !important; word-break: inherit !important;\">from<\/span>\u00a0sklearn.ensemble\u00a0<span style=\"font-size: inherit; line-height: inherit; color: #f82375; overflow-wrap: inherit !important; word-break: inherit !important;\">import<\/span>\u00a0GradientBoostingClassifier\n<span style=\"font-size: inherit; line-height: inherit; color: #f82375; overflow-wrap: inherit !important; word-break: inherit !important;\">from<\/span>\u00a0xgboost\u00a0<span style=\"font-size: inherit; line-height: inherit; color: #f82375; overflow-wrap: inherit !important; word-break: inherit !important;\">import<\/span>\u00a0XGBClassifier,XGBRegressor\n<span style=\"font-size: inherit; line-height: inherit; color: #f82375; overflow-wrap: inherit !important; word-break: inherit !important;\">from<\/span>\u00a0catboost\u00a0<span style=\"font-size: inherit; line-height: inherit; color: #f82375; overflow-wrap: inherit !important; word-break: inherit !important;\">import<\/span>\u00a0CatBoostClassifier,CatBoostRegressor\n<span style=\"font-size: inherit; line-height: inherit; color: #f82375; overflow-wrap: inherit !important; word-break: inherit !important;\">from<\/span>\u00a0sklearn.ensemble\u00a0<span style=\"font-size: inherit; line-height: inherit; color: #f82375; overflow-wrap: inherit !important; word-break: inherit !important;\">import<\/span>\u00a0RandomForestClassifier,RandomForestRegressor\n<span style=\"font-size: inherit; line-height: inherit; color: #f82375; overflow-wrap: inherit !important; word-break: inherit !important;\">from<\/span>\u00a0sklearn.model_selection\u00a0<span style=\"font-size: inherit; line-height: inherit; color: #f82375; overflow-wrap: inherit !important; word-break: inherit !important;\">import<\/span>\u00a0train_test_split,KFold,cross_val_score\n<span style=\"font-size: inherit; line-height: inherit; color: #f82375; overflow-wrap: inherit !important; word-break: inherit !important;\">from<\/span>\u00a0sklearn.metrics\u00a0<span style=\"font-size: inherit; line-height: inherit; color: #f82375; overflow-wrap: inherit !important; word-break: inherit !important;\">import<\/span>\u00a0accuracy_score\n<span style=\"font-size: inherit; line-height: inherit; color: #f82375; overflow-wrap: inherit !important; word-break: inherit !important;\">import<\/span>\u00a0shap\n<span style=\"font-size: inherit; line-height: inherit; color: #f82375; overflow-wrap: inherit !important; word-break: inherit !important;\">from<\/span>\u00a0sklearn.feature_selection\u00a0<span style=\"font-size: inherit; line-height: inherit; color: #f82375; overflow-wrap: inherit !important; word-break: inherit !important;\">import<\/span>\u00a0SelectKBest,f_regression\n<span style=\"font-size: inherit; line-height: inherit; color: #f82375; overflow-wrap: inherit !important; word-break: inherit !important;\">from<\/span>\u00a0sklearn\u00a0<span style=\"font-size: inherit; line-height: inherit; color: #f82375; overflow-wrap: inherit !important; word-break: inherit !important;\">import<\/span>\u00a0preprocessing\n<span style=\"font-size: inherit; line-height: inherit; color: #808080; overflow-wrap: inherit !important; word-break: inherit !important;\">#\u753b\u56fe<\/span>\n<span style=\"font-size: inherit; line-height: inherit; color: #f82375; overflow-wrap: inherit !important; word-break: inherit !important;\">import<\/span>\u00a0seaborn\u00a0<span style=\"font-size: inherit; line-height: inherit; color: #f82375; overflow-wrap: inherit !important; word-break: inherit !important;\">as<\/span>\u00a0sns\n<span style=\"font-size: inherit; line-height: inherit; color: #f82375; overflow-wrap: inherit !important; word-break: inherit !important;\">import<\/span>\u00a0matplotlib.pyplot\u00a0<span style=\"font-size: inherit; line-height: inherit; color: #f82375; overflow-wrap: inherit !important; word-break: inherit !important;\">as<\/span>\u00a0plt\n<span style=\"font-size: inherit; line-height: inherit; color: #f82375; overflow-wrap: inherit !important; word-break: inherit !important;\">import<\/span>\u00a0plotly.graph_objects\u00a0<span style=\"font-size: inherit; line-height: inherit; color: #f82375; overflow-wrap: inherit !important; word-break: inherit !important;\">as<\/span>\u00a0go\n<span style=\"font-size: inherit; line-height: inherit; color: #f82375; overflow-wrap: inherit !important; word-break: inherit !important;\">import<\/span>\u00a0plotly.express\u00a0<span style=\"font-size: inherit; line-height: inherit; color: #f82375; overflow-wrap: inherit !important; word-break: inherit !important;\">as<\/span>\u00a0px\n\n%matplotlib\u00a0inline\u00a0\u00a0\u00a0\n<span style=\"font-size: inherit; line-height: inherit; color: #808080; overflow-wrap: inherit !important; word-break: inherit !important;\">#\u6b63\u5e38\u663e\u793a\u753b\u56fe\u65f6\u51fa\u73b0\u7684\u4e2d\u6587\u548c\u8d1f\u53f7<\/span>\n<span style=\"font-size: inherit; line-height: inherit; color: #f82375; overflow-wrap: inherit !important; word-break: inherit !important;\">from<\/span>\u00a0pylab\u00a0<span style=\"font-size: inherit; line-height: inherit; color: #f82375; overflow-wrap: inherit !important; word-break: inherit !important;\">import<\/span>\u00a0mpl\nmpl.rcParams[<span style=\"font-size: inherit; line-height: inherit; color: #eedc70; overflow-wrap: inherit !important; word-break: inherit !important;\">'font.sans-serif'<\/span>]=[<span style=\"font-size: inherit; line-height: inherit; color: #eedc70; overflow-wrap: inherit !important; word-break: inherit !important;\">'SimHei'<\/span>]\nmpl.rcParams[<span style=\"font-size: inherit; line-height: inherit; color: #eedc70; overflow-wrap: inherit !important; word-break: inherit !important;\">'axes.unicode_minus'<\/span>]=<span style=\"font-size: inherit; line-height: inherit; color: #f82375; overflow-wrap: inherit !important; word-break: inherit !important;\">False<\/span>\n<\/code><\/pre>\n<h2 style=\"font-weight: bold; line-height: 1.6;\"><\/h2>\n<h2 style=\"font-weight: bold; line-height: 1.6;\"><strong><span style=\"font-size: 15px;\">\u6570\u636e\u83b7\u53d6<\/span><\/strong><\/h2>\n<p><span style=\"font-size: 15px;\">\u7528tushare\u83b7\u53d6\u4e0a\u8bc1\u884c\u60c5\u6570\u636e\u4f5c\u4e3a\u5206\u6790\u6837\u672c\u3002<\/span><\/p>\n<pre style=\"font-size: inherit; color: inherit; line-height: inherit;\"><code style=\"margin-right: 2px; margin-left: 2px; line-height: 15px; font-size: 11px; word-spacing: -3px; letter-spacing: 0px; border-radius: 0px; color: #a9b7c6; background: #282b2e; padding: 0.5em; font-family: Consolas, Inconsolata, Courier, monospace; overflow-wrap: normal !important; word-break: normal !important; overflow: auto !important; display: -webkit-box !important;\"><span style=\"font-size: inherit; line-height: inherit; color: #808080; overflow-wrap: inherit !important; word-break: inherit !important;\">#\u9ed8\u8ba4\u4ee5\u4e0a\u8bc1\u6307\u6570\u4ea4\u6613\u6570\u636e\u4e3a\u4f8b<\/span>\n<span style=\"font-size: inherit; line-height: inherit; color: #f82375; overflow-wrap: inherit !important; word-break: inherit !important;\"><span style=\"font-size: inherit; line-height: inherit; overflow-wrap: inherit !important; word-break: inherit !important;\">def<\/span>\u00a0<span style=\"font-size: inherit; line-height: inherit; color: #a5da2d; overflow-wrap: inherit !important; word-break: inherit !important;\">get_data<\/span><span style=\"font-size: inherit; line-height: inherit; color: #ff9823; overflow-wrap: inherit !important; word-break: inherit !important;\">(code=<span style=\"font-size: inherit; line-height: inherit; color: #eedc70; overflow-wrap: inherit !important; word-break: inherit !important;\">'sh'<\/span>,start=<span style=\"font-size: inherit; line-height: inherit; color: #eedc70; overflow-wrap: inherit !important; word-break: inherit !important;\">'2000-01-01'<\/span>,end=<span style=\"font-size: inherit; line-height: inherit; color: #eedc70; overflow-wrap: inherit !important; word-break: inherit !important;\">'2021-03-02'<\/span>)<\/span>:<\/span>\n\u00a0\u00a0\u00a0\u00a0df=ts.get_k_data(<span style=\"font-size: inherit; line-height: inherit; color: #eedc70; overflow-wrap: inherit !important; word-break: inherit !important;\">'sh'<\/span>,start=<span style=\"font-size: inherit; line-height: inherit; color: #eedc70; overflow-wrap: inherit !important; word-break: inherit !important;\">'2005'<\/span>)\n\u00a0\u00a0\u00a0\u00a0df.index=pd.to_datetime(df.date)\n\u00a0\u00a0\u00a0\u00a0df=df[[<span style=\"font-size: inherit; line-height: inherit; color: #eedc70; overflow-wrap: inherit !important; word-break: inherit !important;\">'open'<\/span>,<span style=\"font-size: inherit; line-height: inherit; color: #eedc70; overflow-wrap: inherit !important; word-break: inherit !important;\">'high'<\/span>,<span style=\"font-size: inherit; line-height: inherit; color: #eedc70; overflow-wrap: inherit !important; word-break: inherit !important;\">'low'<\/span>,<span style=\"font-size: inherit; line-height: inherit; color: #eedc70; overflow-wrap: inherit !important; word-break: inherit !important;\">'close'<\/span>,<span style=\"font-size: inherit; line-height: inherit; color: #eedc70; overflow-wrap: inherit !important; word-break: inherit !important;\">'volume'<\/span>]]\n\u00a0\u00a0\u00a0\u00a0<span style=\"font-size: inherit; line-height: inherit; color: #f82375; overflow-wrap: inherit !important; word-break: inherit !important;\">return<\/span>\u00a0df\n<\/code><\/pre>\n<pre style=\"font-size: inherit; color: inherit; line-height: inherit;\"><code style=\"margin-right: 2px; margin-left: 2px; line-height: 15px; font-size: 11px; word-spacing: -3px; letter-spacing: 0px; border-radius: 0px; color: #a9b7c6; background: #282b2e; padding: 0.5em; font-family: Consolas, Inconsolata, Courier, monospace; overflow-wrap: normal !important; word-break: normal !important; overflow: auto !important; display: -webkit-box !important;\">df=get_data()\ndf_train,df_test=df.loc[:<span style=\"font-size: inherit; line-height: inherit; color: #eedc70; overflow-wrap: inherit !important; word-break: inherit !important;\">'2017'<\/span>],df.loc[<span style=\"font-size: inherit; line-height: inherit; color: #eedc70; overflow-wrap: inherit !important; word-break: inherit !important;\">'2018'<\/span>:]<\/code><\/pre>\n<h2 style=\"font-weight: bold; line-height: 1.6;\"><\/h2>\n<h2 style=\"font-weight: bold; line-height: 1.6;\"><span style=\"font-size: 15px; font-family: \u5fae\u8f6f\u96c5\u9ed1, 'Microsoft YaHei';\">\u6784\u5efa\u76ee\u6807\u53d8\u91cf<span style=\"color: #000000; caret-color: #ff0000;\">\uff08target variable\uff09<\/span><\/span><\/h2>\n<p style=\"text-align: justify;\"><span style=\"font-size: 15px; font-family: \u5fae\u8f6f\u96c5\u9ed1, 'Microsoft YaHei';\">\u4ee5\u4ea4\u6613\u4fe1\u53f7\u4f5c\u4e3a\u76ee\u6807\u53d8\u91cf\uff0c\u4f7f\u7528\u4ef7\u683c\u4fe1\u606f\u548c\u6280\u672f\u6307\u6807\u4f5c\u4e3a\u7279\u5f81\u53d8\u91cf\u8fdb\u884c\u9884\u6d4b\u5206\u6790\u3002\u4ee5\u53cc\u5747\u7ebf\u4ea4\u6613\u7b56\u7565\u4e3a\u4f8b\uff0c\u5f53\u77ed\u671f\u5747\u7ebf\u5411\u4e0a\u7a81\u7834\u957f\u671f\u5747\u7ebf\u65f6\u5f62\u6210\u4e70\u5165\u4fe1\u53f7\uff08\u8bbe\u5b9a\u4e3a1\uff09\uff0c\u5f53\u77ed\u671f\u5747\u7ebf\u5411\u4e0b\u8dcc\u7834\u957f\u671f\u5747\u7ebf\u65f6\u53d1\u51fa\u5356\u51fa\u4fe1\u53f7\uff08\u8bbe\u5b9a\u4e3a0\uff09\uff0c\u7136\u540e\u518d\u4f7f\u7528\u673a\u5668\u5b66\u4e60\u6a21\u578b\u8fdb\u884c\u9884\u6d4b\u548c\u8bc4\u4f30\u3002\u8fd9\u91cc\u5c06\u77ed\u671f\u79fb\u52a8\u5e73\u5747\u503c(SMA1)\u548c\u957f\u671f\u79fb\u52a8\u5e73\u5747\u503c(SMA2)\u7684\u53c2\u6570\u5206\u522b\u8bbe\u7f6e\u4e3a10\u548c60\uff0c\u4e8c\u8005\u7684\u8bbe\u5b9a\u5177\u6709\u4e00\u5b9a\u7684\u4efb\u610f\u6027\uff0c\u53c2\u6570\u7684\u9009\u62e9\u4f1a\u5f71\u54cd\u540e\u7eed\u7ed3\u679c\uff0c\u6240\u4ee5\u7406\u60f3\u60c5\u51b5\u4e0b\u9700\u8981\u8fdb\u884c\u53c2\u6570\u4f18\u5316\u6765\u627e\u5230\u6700\u4f18\u503c\u3002<\/span><\/p>\n<p style=\"text-align: justify;\">\n<pre style=\"font-size: inherit; color: inherit; line-height: inherit;\"><code style=\"margin-right: 2px; margin-left: 2px; line-height: 15px; font-size: 11px; word-spacing: -3px; letter-spacing: 0px; border-radius: 0px; color: #a9b7c6; background: #282b2e; padding: 0.5em; font-family: Consolas, Inconsolata, Courier, monospace; overflow-wrap: normal !important; word-break: normal !important; overflow: auto !important; display: -webkit-box !important;\"><span style=\"font-size: inherit; line-height: inherit; color: #f82375; overflow-wrap: inherit !important; word-break: inherit !important;\"><span style=\"font-size: inherit; line-height: inherit; overflow-wrap: inherit !important; word-break: inherit !important;\">def<\/span>\u00a0<span style=\"font-size: inherit; line-height: inherit; color: #a5da2d; overflow-wrap: inherit !important; word-break: inherit !important;\">trade_signal<\/span><span style=\"font-size: inherit; line-height: inherit; color: #ff9823; overflow-wrap: inherit !important; word-break: inherit !important;\">(data,short=<span style=\"font-size: inherit; line-height: inherit; color: #ae87fa; overflow-wrap: inherit !important; word-break: inherit !important;\">10<\/span>,long=<span style=\"font-size: inherit; line-height: inherit; color: #ae87fa; overflow-wrap: inherit !important; word-break: inherit !important;\">60<\/span>,tr_id=False)<\/span>:<\/span>\n\u00a0\u00a0\u00a0\u00a0data[<span style=\"font-size: inherit; line-height: inherit; color: #eedc70; overflow-wrap: inherit !important; word-break: inherit !important;\">'SMA1'<\/span>]\u00a0=\u00a0data.close.rolling(short).mean()\n\u00a0\u00a0\u00a0\u00a0data[<span style=\"font-size: inherit; line-height: inherit; color: #eedc70; overflow-wrap: inherit !important; word-break: inherit !important;\">'SMA2'<\/span>]\u00a0=\u00a0data.close.rolling(long).mean()\u00a0\n\u00a0\u00a0\u00a0\u00a0data[<span style=\"font-size: inherit; line-height: inherit; color: #eedc70; overflow-wrap: inherit !important; word-break: inherit !important;\">'signal'<\/span>]\u00a0=\u00a0np.where(data[<span style=\"font-size: inherit; line-height: inherit; color: #eedc70; overflow-wrap: inherit !important; word-break: inherit !important;\">'SMA1'<\/span>]\u00a0&gt;data[<span style=\"font-size: inherit; line-height: inherit; color: #eedc70; overflow-wrap: inherit !important; word-break: inherit !important;\">'SMA2'<\/span>],\u00a0<span style=\"font-size: inherit; line-height: inherit; color: #ae87fa; overflow-wrap: inherit !important; word-break: inherit !important;\">1.0<\/span>,\u00a0<span style=\"font-size: inherit; line-height: inherit; color: #ae87fa; overflow-wrap: inherit !important; word-break: inherit !important;\">0.0<\/span>)\u00a0\n\u00a0\u00a0\u00a0\u00a0<span style=\"font-size: inherit; line-height: inherit; color: #f82375; overflow-wrap: inherit !important; word-break: inherit !important;\">if<\/span>(tr_id\u00a0<span style=\"font-size: inherit; line-height: inherit; color: #f82375; overflow-wrap: inherit !important; word-break: inherit !important;\">is<\/span>\u00a0<span style=\"font-size: inherit; line-height: inherit; color: #f82375; overflow-wrap: inherit !important; word-break: inherit !important;\">not<\/span>\u00a0<span style=\"font-size: inherit; line-height: inherit; color: #f82375; overflow-wrap: inherit !important; word-break: inherit !important;\">True<\/span>):\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0display(data[<span style=\"font-size: inherit; line-height: inherit; color: #eedc70; overflow-wrap: inherit !important; word-break: inherit !important;\">'signal'<\/span>].value_counts())\n\ndf_tr1\u00a0=\u00a0df_train.copy(deep=<span style=\"font-size: inherit; line-height: inherit; color: #f82375; overflow-wrap: inherit !important; word-break: inherit !important;\">True<\/span>)\u00a0\u00a0\ndf_te1\u00a0=\u00a0df_test.copy(deep=<span style=\"font-size: inherit; line-height: inherit; color: #f82375; overflow-wrap: inherit !important; word-break: inherit !important;\">True<\/span>)\u00a0\ntrade_signal(df_tr1)\u00a0\u00a0<span style=\"font-size: inherit; line-height: inherit; color: #808080; overflow-wrap: inherit !important; word-break: inherit !important;\">#<\/span>\ntrade_signal(df_te1,tr_id=<span style=\"font-size: inherit; line-height: inherit; color: #f82375; overflow-wrap: inherit !important; word-break: inherit !important;\">True<\/span>)\u00a0\u00a0<\/code><\/pre>\n<pre style=\"font-size: inherit; color: inherit; line-height: inherit;\"><code style=\"margin-right: 2px; margin-left: 2px; line-height: 15px; font-size: 11px; word-spacing: -3px; letter-spacing: 0px; border-radius: 0px; color: #a9b7c6; background: #282b2e; padding: 0.5em; font-family: Consolas, Inconsolata, Courier, monospace; overflow-wrap: normal !important; word-break: normal !important; overflow: auto !important; display: -webkit-box !important;\">plt.figure(figsize=(<span style=\"font-size: inherit; line-height: inherit; color: #ae87fa; overflow-wrap: inherit !important; word-break: inherit !important;\">14<\/span>,<span style=\"font-size: inherit; line-height: inherit; color: #ae87fa; overflow-wrap: inherit !important; word-break: inherit !important;\">12<\/span>),\u00a0dpi=<span style=\"font-size: inherit; line-height: inherit; color: #ae87fa; overflow-wrap: inherit !important; word-break: inherit !important;\">80<\/span>)\nax1\u00a0=\u00a0plt.subplot(<span style=\"font-size: inherit; line-height: inherit; color: #ae87fa; overflow-wrap: inherit !important; word-break: inherit !important;\">211<\/span>)\nplt.plot(df_tr1.close,color=<span style=\"font-size: inherit; line-height: inherit; color: #eedc70; overflow-wrap: inherit !important; word-break: inherit !important;\">'b'<\/span>)\nplt.title(<span style=\"font-size: inherit; line-height: inherit; color: #eedc70; overflow-wrap: inherit !important; word-break: inherit !important;\">'\u4e0a\u8bc1\u6307\u6570\u8d70\u52bf'<\/span>,size=<span style=\"font-size: inherit; line-height: inherit; color: #ae87fa; overflow-wrap: inherit !important; word-break: inherit !important;\">15<\/span>)\nplt.xlabel(<span style=\"font-size: inherit; line-height: inherit; color: #eedc70; overflow-wrap: inherit !important; word-break: inherit !important;\">''<\/span>)\nax2\u00a0=\u00a0plt.subplot(<span style=\"font-size: inherit; line-height: inherit; color: #ae87fa; overflow-wrap: inherit !important; word-break: inherit !important;\">212<\/span>)\nplt.plot(df_tr1.signal,color=<span style=\"font-size: inherit; line-height: inherit; color: #eedc70; overflow-wrap: inherit !important; word-break: inherit !important;\">'r'<\/span>)\nplt.title(<span style=\"font-size: inherit; line-height: inherit; color: #eedc70; overflow-wrap: inherit !important; word-break: inherit !important;\">'\u4ea4\u6613\u4fe1\u53f7'<\/span>,size=<span style=\"font-size: inherit; line-height: inherit; color: #ae87fa; overflow-wrap: inherit !important; word-break: inherit !important;\">15<\/span>)\nplt.xlabel(<span style=\"font-size: inherit; line-height: inherit; color: #eedc70; overflow-wrap: inherit !important; word-break: inherit !important;\">''<\/span>)\nplt.show()\n<\/code><\/pre>\n<figure style=\"font-size: inherit; color: inherit; line-height: inherit;\"><figcaption style=\"line-height: inherit; margin-top: 10px; text-align: center; color: #999999; font-size: 0.7em;\"><img decoding=\"async\" class=\"rich_pages wxw-img\" style=\"box-sizing: border-box; width: 'auto';\" title=\"Python+\u673a\u5668\u5b66\u4e60\u5bfb\u627e\u80a1\u7968\u4ea4\u6613\u4fe1\u53f7\" src=\"http:\/\/www.zhushiyao.com\/wp-content\/uploads\/2022\/02\/10-1645424110.png\" alt=\"Python+\u673a\u5668\u5b66\u4e60\u5bfb\u627e\u80a1\u7968\u4ea4\u6613\u4fe1\u53f7\" \/><\/figcaption><\/figure>\n<pre style=\"font-size: inherit; color: inherit; line-height: inherit;\"><code style=\"margin-right: 2px; margin-left: 2px; line-height: 15px; font-size: 11px; word-spacing: -3px; letter-spacing: 0px; border-radius: 0px; color: #a9b7c6; background: #282b2e; padding: 0.5em; font-family: Consolas, Inconsolata, Courier, monospace; overflow-wrap: normal !important; word-break: normal !important; overflow: auto !important; display: -webkit-box !important;\">df_tr1[[<span style=\"font-size: inherit; line-height: inherit; color: #eedc70; overflow-wrap: inherit !important; word-break: inherit !important;\">'SMA1'<\/span>,<span style=\"font-size: inherit; line-height: inherit; color: #eedc70; overflow-wrap: inherit !important; word-break: inherit !important;\">'SMA2'<\/span>,<span style=\"font-size: inherit; line-height: inherit; color: #eedc70; overflow-wrap: inherit !important; word-break: inherit !important;\">'signal'<\/span>]].iloc[<span style=\"font-size: inherit; line-height: inherit; color: #ae87fa; overflow-wrap: inherit !important; word-break: inherit !important;\">-250<\/span>:].plot(figsize=(<span style=\"font-size: inherit; line-height: inherit; color: #ae87fa; overflow-wrap: inherit !important; word-break: inherit !important;\">14<\/span>,<span style=\"font-size: inherit; line-height: inherit; color: #ae87fa; overflow-wrap: inherit !important; word-break: inherit !important;\">6<\/span>),secondary_y=[<span style=\"font-size: inherit; line-height: inherit; color: #eedc70; overflow-wrap: inherit !important; word-break: inherit !important;\">'signal'<\/span>])\nplt.show()\n<\/code><\/pre>\n<figure style=\"font-size: inherit; color: inherit; line-height: inherit;\"><figcaption style=\"line-height: inherit; margin-top: 10px; text-align: center; color: #999999; font-size: 0.7em;\"><img decoding=\"async\" class=\"rich_pages wxw-img\" style=\"box-sizing: border-box; width: 'auto';\" title=\"Python+\u673a\u5668\u5b66\u4e60\u5bfb\u627e\u80a1\u7968\u4ea4\u6613\u4fe1\u53f7\" src=\"http:\/\/www.zhushiyao.com\/wp-content\/uploads\/2022\/02\/8-1645424110.png\" alt=\"Python+\u673a\u5668\u5b66\u4e60\u5bfb\u627e\u80a1\u7968\u4ea4\u6613\u4fe1\u53f7\" \/><\/figcaption><figcaption style=\"line-height: inherit; margin-top: 10px; text-align: center; color: #999999; font-size: 0.7em;\"><\/figcaption><\/figure>\n<pre style=\"font-size: inherit; color: inherit; line-height: inherit;\"><code style=\"margin-right: 2px; margin-left: 2px; line-height: 15px; font-size: 11px; word-spacing: -3px; letter-spacing: 0px; border-radius: 0px; color: #a9b7c6; background: #282b2e; padding: 0.5em; font-family: Consolas, Inconsolata, Courier, monospace; overflow-wrap: normal !important; word-break: normal !important; overflow: auto !important; display: -webkit-box !important;\"><span style=\"font-size: inherit; line-height: inherit; color: #808080; overflow-wrap: inherit !important; word-break: inherit !important;\">#\u5220\u9664\u5747\u7ebf\u53d8\u91cf<\/span>\ndf_tr1=df_tr1.drop([<span style=\"font-size: inherit; line-height: inherit; color: #eedc70; overflow-wrap: inherit !important; word-break: inherit !important;\">'SMA1'<\/span>,<span style=\"font-size: inherit; line-height: inherit; color: #eedc70; overflow-wrap: inherit !important; word-break: inherit !important;\">'SMA2'<\/span>],\u00a0axis=<span style=\"font-size: inherit; line-height: inherit; color: #ae87fa; overflow-wrap: inherit !important; word-break: inherit !important;\">1<\/span>)\ndf_te1=df_te1.drop([<span style=\"font-size: inherit; line-height: inherit; color: #eedc70; overflow-wrap: inherit !important; word-break: inherit !important;\">'SMA1'<\/span>,<span style=\"font-size: inherit; line-height: inherit; color: #eedc70; overflow-wrap: inherit !important; word-break: inherit !important;\">'SMA2'<\/span>],\u00a0axis=<span style=\"font-size: inherit; line-height: inherit; color: #ae87fa; overflow-wrap: inherit !important; word-break: inherit !important;\">1<\/span>)\n<\/code><\/pre>\n<pre style=\"font-size: inherit; color: inherit; line-height: inherit;\"><code style=\"margin-right: 2px; margin-left: 2px; line-height: 15px; font-size: 11px; word-spacing: -3px; letter-spacing: 0px; border-radius: 0px; color: #a9b7c6; background: #282b2e; padding: 0.5em; font-family: Consolas, Inconsolata, Courier, monospace; overflow-wrap: normal !important; word-break: normal !important; overflow: auto !important; display: -webkit-box !important;\">#\u753b\u76ee\u6807\u53d8\u91cf\u4e0e\u5176\u4ed6\u53d8\u91cf\u4e4b\u95f4\u7684\u76f8\u5173\u7cfb\u6570\u56fe\ncmap\u00a0=\u00a0sns.diverging_palette(<span style=\"font-size: inherit; line-height: inherit; color: #ae87fa; overflow-wrap: inherit !important; word-break: inherit !important;\">220<\/span>,\u00a0<span style=\"font-size: inherit; line-height: inherit; color: #ae87fa; overflow-wrap: inherit !important; word-break: inherit !important;\">10<\/span>,\u00a0as_cmap=<span style=\"font-size: inherit; line-height: inherit; color: #f82375; overflow-wrap: inherit !important; word-break: inherit !important;\">True<\/span>)\n<span style=\"font-size: inherit; line-height: inherit; color: #f82375; overflow-wrap: inherit !important; word-break: inherit !important;\"><span style=\"font-size: inherit; line-height: inherit; overflow-wrap: inherit !important; word-break: inherit !important;\">def<\/span>\u00a0<span style=\"font-size: inherit; line-height: inherit; color: #a5da2d; overflow-wrap: inherit !important; word-break: inherit !important;\">corrMat<\/span><span style=\"font-size: inherit; line-height: inherit; color: #ff9823; overflow-wrap: inherit !important; word-break: inherit !important;\">(df,target=<span style=\"font-size: inherit; line-height: inherit; color: #eedc70; overflow-wrap: inherit !important; word-break: inherit !important;\">'demand'<\/span>,figsize=<span style=\"font-size: inherit; line-height: inherit; overflow-wrap: inherit !important; word-break: inherit !important;\">(<span style=\"font-size: inherit; line-height: inherit; color: #ae87fa; overflow-wrap: inherit !important; word-break: inherit !important;\">9<\/span>,<span style=\"font-size: inherit; line-height: inherit; color: #ae87fa; overflow-wrap: inherit !important; word-break: inherit !important;\">0.5<\/span>)<\/span>,ret_id=False)<\/span>:<\/span>\n\n\u00a0\u00a0\u00a0\u00a0corr_mat\u00a0=\u00a0df.corr().round(<span style=\"font-size: inherit; line-height: inherit; color: #ae87fa; overflow-wrap: inherit !important; word-break: inherit !important;\">2<\/span>);shape\u00a0=\u00a0corr_mat.shape[<span style=\"font-size: inherit; line-height: inherit; color: #ae87fa; overflow-wrap: inherit !important; word-break: inherit !important;\">0<\/span>]\n\u00a0\u00a0\u00a0\u00a0corr_mat\u00a0=\u00a0corr_mat.transpose()\n\u00a0\u00a0\u00a0\u00a0corr\u00a0=\u00a0corr_mat.loc[:,\u00a0df.columns\u00a0==\u00a0target].transpose().copy()\n\n\u00a0\u00a0\u00a0\u00a0<span style=\"font-size: inherit; line-height: inherit; color: #f82375; overflow-wrap: inherit !important; word-break: inherit !important;\">if<\/span>(ret_id\u00a0<span style=\"font-size: inherit; line-height: inherit; color: #f82375; overflow-wrap: inherit !important; word-break: inherit !important;\">is<\/span>\u00a0<span style=\"font-size: inherit; line-height: inherit; color: #f82375; overflow-wrap: inherit !important; word-break: inherit !important;\">False<\/span>):\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0f,\u00a0ax\u00a0=\u00a0plt.subplots(figsize=figsize)\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0sns.heatmap(corr,vmin=<span style=\"font-size: inherit; line-height: inherit; color: #ae87fa; overflow-wrap: inherit !important; word-break: inherit !important;\">-0.3<\/span>,vmax=<span style=\"font-size: inherit; line-height: inherit; color: #ae87fa; overflow-wrap: inherit !important; word-break: inherit !important;\">0.3<\/span>,center=<span style=\"font-size: inherit; line-height: inherit; color: #ae87fa; overflow-wrap: inherit !important; word-break: inherit !important;\">0<\/span>,\u00a0\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0cmap=cmap,square=<span style=\"font-size: inherit; line-height: inherit; color: #f82375; overflow-wrap: inherit !important; word-break: inherit !important;\">False<\/span>,lw=<span style=\"font-size: inherit; line-height: inherit; color: #ae87fa; overflow-wrap: inherit !important; word-break: inherit !important;\">2<\/span>,annot=<span style=\"font-size: inherit; line-height: inherit; color: #f82375; overflow-wrap: inherit !important; word-break: inherit !important;\">True<\/span>,cbar=<span style=\"font-size: inherit; line-height: inherit; color: #f82375; overflow-wrap: inherit !important; word-break: inherit !important;\">False<\/span>)\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0plt.title(<span style=\"font-size: inherit; line-height: inherit; color: #eedc70; overflow-wrap: inherit !important; word-break: inherit !important;\">f'Feature\u00a0Correlation\u00a0to\u00a0<span style=\"font-size: inherit; color: inherit; line-height: inherit; overflow-wrap: inherit !important; word-break: inherit !important;\">{target}<\/span>'<\/span>)\n\n\u00a0\u00a0\u00a0\u00a0<span style=\"font-size: inherit; line-height: inherit; color: #f82375; overflow-wrap: inherit !important; word-break: inherit !important;\">if<\/span>(ret_id):\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0<span style=\"font-size: inherit; line-height: inherit; color: #f82375; overflow-wrap: inherit !important; word-break: inherit !important;\">return<\/span>\u00a0corr\n<\/code><\/pre>\n<pre style=\"font-size: inherit; color: inherit; line-height: inherit;\"><code style=\"margin-right: 2px; margin-left: 2px; line-height: 15px; font-size: 11px; word-spacing: -3px; letter-spacing: 0px; border-radius: 0px; color: #a9b7c6; background: #282b2e; padding: 0.5em; font-family: Consolas, Inconsolata, Courier, monospace; overflow-wrap: normal !important; word-break: normal !important; overflow: auto !important; display: -webkit-box !important;\">corrMat(df_tr1,<span style=\"font-size: inherit; line-height: inherit; color: #eedc70; overflow-wrap: inherit !important; word-break: inherit !important;\">'signal'<\/span>,figsize=(<span style=\"font-size: inherit; line-height: inherit; color: #ae87fa; overflow-wrap: inherit !important; word-break: inherit !important;\">7<\/span>,<span style=\"font-size: inherit; line-height: inherit; color: #ae87fa; overflow-wrap: inherit !important; word-break: inherit !important;\">0.5<\/span>))\n<\/code><\/pre>\n<p><span style=\"font-size: 15px; font-family: \u5fae\u8f6f\u96c5\u9ed1, 'Microsoft YaHei';\"><img decoding=\"async\" class=\"rich_pages wxw-img\" style=\"box-sizing: border-box; width: 'auto';\" title=\"Python+\u673a\u5668\u5b66\u4e60\u5bfb\u627e\u80a1\u7968\u4ea4\u6613\u4fe1\u53f7\" src=\"http:\/\/www.zhushiyao.com\/wp-content\/uploads\/2022\/02\/3-1645424110.png\" alt=\"Python+\u673a\u5668\u5b66\u4e60\u5bfb\u627e\u80a1\u7968\u4ea4\u6613\u4fe1\u53f7\" \/><\/span><\/p>\n<p><span style=\"font-size: 15px; font-family: \u5fae\u8f6f\u96c5\u9ed1, 'Microsoft YaHei';\">\u5f53\u524d\u7684\u7279\u5f81open\u3001high\u3001low\u3001close\u3001volumes\u4e0e\u76ee\u6807\u53d8\u91cf\u7684\u7ebf\u6027\u76f8\u5173\u503c\u975e\u5e38\u5c0f\uff0c\u8fd9\u53ef\u80fd\u610f\u5473\u7740\u5b58\u5728\u9ad8\u975e\u7ebf\u6027\uff0c\u76f8\u5bf9\u5e73\u7a33\u503c\u7684\u7a33\u5b9a\u632f\u8361(\u5706\u5f62\u6563\u5c04)\uff0c\u6216\u8005\u4e5f\u8bb8\u5b83\u4eec\u4e0d\u662f\u7406\u60f3\u7684\u9884\u6d4b\u7279\u5f81\u53d8\u91cf\uff0c\u6240\u4ee5\u4e0b\u9762\u9700\u8981\u8fdb\u884c\u7279\u5f81\u6784\u5efa\u548c\u9009\u53d6\u3002<\/span><\/p>\n<h2 style=\"font-weight: bold; line-height: 1.6;\"><strong><span style=\"font-size: 15px; font-family: \u5fae\u8f6f\u96c5\u9ed1, 'Microsoft YaHei';\">\u6280\u672f\u6307\u6807\u7279\u5f81\u6784\u5efa<\/span><\/strong><\/h2>\n<p style=\"text-align: justify; font-size: inherit; color: inherit; line-height: inherit; margin-top: 1.5em; margin-bottom: 1.5em;\"><span style=\"font-size: 15px; font-family: \u5fae\u8f6f\u96c5\u9ed1, 'Microsoft YaHei';\">\u4e3a\u65b9\u4fbf\u5206\u6790\uff0c\u4e0b\u9762\u4ee5\u5e38\u89c1\u7684\u51e0\u4e2a\u6280\u672f\u6307\u6807\u4f5c\u4e3a\u7279\u5f81\u5f15\u5165\u7279\u5f81\u77e9\u9635\uff0c\u5177\u4f53\u6307\u6807\u6709\uff1a<\/span><\/p>\n<section>\n<ul class=\"list-paddingleft-2\" style=\"padding-left: 30px;\">\n<li>\n<p style=\"text-align: justify;\"><span style=\"color: inherit; line-height: inherit; font-size: 15px; font-family: \u5fae\u8f6f\u96c5\u9ed1, 'Microsoft YaHei';\">\u79fb\u52a8\u5e73\u5747\u7ebf:\u79fb\u52a8\u5e73\u5747\u7ebf\u901a\u8fc7\u51cf\u5c11\u566a\u97f3\u6765\u6307\u793a\u4ef7\u683c\u7684\u8fd0\u52a8\u8d8b\u52bf\u3002<\/span><\/p>\n<\/li>\n<li>\n<p style=\"text-align: justify;\"><span style=\"color: inherit; line-height: inherit; font-size: 15px; font-family: \u5fae\u8f6f\u96c5\u9ed1, 'Microsoft YaHei';\">\u968f\u673a\u632f\u8361\u5668%K\u548c%D:\u968f\u673a\u632f\u8361\u5668\u662f\u4e00\u4e2a\u52a8\u91cf\u6307\u793a\u5668\uff0c\u6bd4\u8f83\u7279\u5b9a\u7684\u8bc1\u5238\u6536\u76d8\u4ef7\u548c\u4e00\u5b9a\u65f6\u671f\u5185\u7684\u4ef7\u683c\u8303\u56f4\u3002%K\u3001%D\u5206\u522b\u4e3a\u6162\u3001\u5feb\u6307\u6807\u3002<\/span><\/p>\n<\/li>\n<li>\n<p style=\"text-align: justify;\"><span style=\"color: inherit; line-height: inherit; font-size: 15px; font-family: \u5fae\u8f6f\u96c5\u9ed1, 'Microsoft YaHei';\">\u76f8\u5bf9\u5f3a\u5f31\u6307\u6570(RSI):\u52a8\u91cf\u6307\u6807\uff0c\u8861\u91cf\u6700\u8fd1\u4ef7\u683c\u53d8\u5316\u7684\u5e45\u5ea6\uff0c\u4ee5\u8bc4\u4f30\u80a1\u7968\u6216\u5176\u4ed6\u8d44\u4ea7\u7684\u4ef7\u683c\u8d85\u4e70\u6216\u8d85\u5356\u60c5\u51b5\u3002<\/span><\/p>\n<\/li>\n<li>\n<p style=\"text-align: justify;\"><span style=\"color: inherit; line-height: inherit; font-size: 15px; font-family: \u5fae\u8f6f\u96c5\u9ed1, 'Microsoft YaHei';\">\u53d8\u5316\u7387(ROC):\u52a8\u91cf\u632f\u8361\u5668\uff0c\u6d4b\u91cf\u5f53\u524d\u4ef7\u683c\u548cn\u671f\u8fc7\u53bb\u4ef7\u683c\u4e4b\u95f4\u7684\u767e\u5206\u6bd4\u53d8\u5316\u3002ROC\u503c\u8d8a\u9ad8\u8d8a\u6709\u53ef\u80fd\u8d85\u4e70\uff0c\u8d8a\u4f4e\u53ef\u80fd\u8d85\u5356\u3002<\/span><\/p>\n<\/li>\n<li>\n<p style=\"text-align: justify;\"><span style=\"color: inherit; line-height: inherit; font-size: 15px; font-family: \u5fae\u8f6f\u96c5\u9ed1, 'Microsoft YaHei';\">\u52a8\u91cf(MOM):\u8bc1\u5238\u4ef7\u683c\u6216\u6210\u4ea4\u91cf\u52a0\u901f\u7684\u901f\u5ea6;\u4ef7\u683c\u53d8\u5316\u7684\u901f\u5ea6\u3002<\/span><\/p>\n<p style=\"text-align: justify;\">\n<\/li>\n<\/ul>\n<\/section>\n<pre style=\"font-size: inherit; color: inherit; line-height: inherit;\"><code style=\"margin-right: 2px; margin-left: 2px; line-height: 15px; font-size: 11px; word-spacing: -3px; letter-spacing: 0px; border-radius: 0px; color: #a9b7c6; background: #282b2e; padding: 0.5em; font-family: Consolas, Inconsolata, Courier, monospace; overflow-wrap: normal !important; word-break: normal !important; overflow: auto !important; display: -webkit-box !important;\"><span style=\"font-size: inherit; line-height: inherit; color: #808080; overflow-wrap: inherit !important; word-break: inherit !important;\">#\u590d\u5236\u4e4b\u524d\u7684\u6570\u636e<\/span>\ndf_tr2=df_tr1.copy(deep=<span style=\"font-size: inherit; line-height: inherit; color: #f82375; overflow-wrap: inherit !important; word-break: inherit !important;\">True<\/span>)\ndf_te2=df_te1.copy(deep=<span style=\"font-size: inherit; line-height: inherit; color: #f82375; overflow-wrap: inherit !important; word-break: inherit !important;\">True<\/span>)\n<\/code><\/pre>\n<p style=\"font-size: 15px; font-family: \u5fae\u8f6f\u96c5\u9ed1, 'Microsoft YaHei';\">\n<h2 style=\"font-weight: bold; line-height: 1.6;\"><strong><span style=\"font-size: 15px; font-family: \u5fae\u8f6f\u96c5\u9ed1, 'Microsoft YaHei';\">\u8ba1\u7b97\u6280\u672f\u6307\u6807<\/span><\/strong><\/h2>\n<pre style=\"font-size: inherit; color: inherit; line-height: inherit;\"><code style=\"margin-right: 2px; margin-left: 2px; line-height: 15px; font-size: 11px; word-spacing: -3px; letter-spacing: 0px; border-radius: 0px; color: #a9b7c6; background: #282b2e; padding: 0.5em; font-family: Consolas, Inconsolata, Courier, monospace; overflow-wrap: normal !important; word-break: normal !important; overflow: auto !important; display: -webkit-box !important;\"><span style=\"font-size: inherit; line-height: inherit; color: #808080; overflow-wrap: inherit !important; word-break: inherit !important;\">#\u4f7f\u7528talib\u6a21\u5757\u76f4\u63a5\u8ba1\u7b97\u76f8\u5173\u6280\u672f\u6307\u6807<\/span>\n<span style=\"font-size: inherit; line-height: inherit; color: #808080; overflow-wrap: inherit !important; word-break: inherit !important;\">#\u4e0b\u9762\u53c2\u6570\u7684\u9009\u53d6\u5177\u6709\u4e3b\u89c2\u6027<\/span>\n<span style=\"font-size: inherit; line-height: inherit; color: #f82375; overflow-wrap: inherit !important; word-break: inherit !important;\"><span style=\"font-size: inherit; line-height: inherit; overflow-wrap: inherit !important; word-break: inherit !important;\">def<\/span>\u00a0<span style=\"font-size: inherit; line-height: inherit; color: #a5da2d; overflow-wrap: inherit !important; word-break: inherit !important;\">indicators<\/span><span style=\"font-size: inherit; line-height: inherit; color: #ff9823; overflow-wrap: inherit !important; word-break: inherit !important;\">(data)<\/span>:<\/span>\n\u00a0\u00a0\u00a0\u00a0data[<span style=\"font-size: inherit; line-height: inherit; color: #eedc70; overflow-wrap: inherit !important; word-break: inherit !important;\">'MA13'<\/span>]=ta.MA(data.close,timeperiod=<span style=\"font-size: inherit; line-height: inherit; color: #ae87fa; overflow-wrap: inherit !important; word-break: inherit !important;\">13<\/span>)\n\u00a0\u00a0\u00a0\u00a0data[<span style=\"font-size: inherit; line-height: inherit; color: #eedc70; overflow-wrap: inherit !important; word-break: inherit !important;\">'MA34'<\/span>]=ta.MA(data.close,timeperiod=<span style=\"font-size: inherit; line-height: inherit; color: #ae87fa; overflow-wrap: inherit !important; word-break: inherit !important;\">34<\/span>)\n\u00a0\u00a0\u00a0\u00a0data[<span style=\"font-size: inherit; line-height: inherit; color: #eedc70; overflow-wrap: inherit !important; word-break: inherit !important;\">'MA89'<\/span>]=ta.MA(data.close,timeperiod=<span style=\"font-size: inherit; line-height: inherit; color: #ae87fa; overflow-wrap: inherit !important; word-break: inherit !important;\">89<\/span>)\n\u00a0\u00a0\u00a0\u00a0data[<span style=\"font-size: inherit; line-height: inherit; color: #eedc70; overflow-wrap: inherit !important; word-break: inherit !important;\">'EMA10'<\/span>]=ta.EMA(data.close,timeperiod=<span style=\"font-size: inherit; line-height: inherit; color: #ae87fa; overflow-wrap: inherit !important; word-break: inherit !important;\">10<\/span>)\n\u00a0\u00a0\u00a0\u00a0data[<span style=\"font-size: inherit; line-height: inherit; color: #eedc70; overflow-wrap: inherit !important; word-break: inherit !important;\">'EMA30'<\/span>]=ta.EMA(data.close,timeperiod=<span style=\"font-size: inherit; line-height: inherit; color: #ae87fa; overflow-wrap: inherit !important; word-break: inherit !important;\">30<\/span>)\n\u00a0\u00a0\u00a0\u00a0data[<span style=\"font-size: inherit; line-height: inherit; color: #eedc70; overflow-wrap: inherit !important; word-break: inherit !important;\">'EMA200'<\/span>]=ta.EMA(data.close,timeperiod=<span style=\"font-size: inherit; line-height: inherit; color: #ae87fa; overflow-wrap: inherit !important; word-break: inherit !important;\">200<\/span>)\n\u00a0\u00a0\u00a0\u00a0data[<span style=\"font-size: inherit; line-height: inherit; color: #eedc70; overflow-wrap: inherit !important; word-break: inherit !important;\">'MOM10'<\/span>]=ta.MOM(data.close,timeperiod=<span style=\"font-size: inherit; line-height: inherit; color: #ae87fa; overflow-wrap: inherit !important; word-break: inherit !important;\">10<\/span>)\n\u00a0\u00a0\u00a0\u00a0data[<span style=\"font-size: inherit; line-height: inherit; color: #eedc70; overflow-wrap: inherit !important; word-break: inherit !important;\">'MOM30'<\/span>]=ta.MOM(data.close,timeperiod=<span style=\"font-size: inherit; line-height: inherit; color: #ae87fa; overflow-wrap: inherit !important; word-break: inherit !important;\">30<\/span>)\n\u00a0\u00a0\u00a0\u00a0data[<span style=\"font-size: inherit; line-height: inherit; color: #eedc70; overflow-wrap: inherit !important; word-break: inherit !important;\">'RSI10'<\/span>]=ta.RSI(data.close,timeperiod=<span style=\"font-size: inherit; line-height: inherit; color: #ae87fa; overflow-wrap: inherit !important; word-break: inherit !important;\">10<\/span>)\n\u00a0\u00a0\u00a0\u00a0data[<span style=\"font-size: inherit; line-height: inherit; color: #eedc70; overflow-wrap: inherit !important; word-break: inherit !important;\">'RSI30'<\/span>]=ta.RSI(data.close,timeperiod=<span style=\"font-size: inherit; line-height: inherit; color: #ae87fa; overflow-wrap: inherit !important; word-break: inherit !important;\">30<\/span>)\n\u00a0\u00a0\u00a0\u00a0data[<span style=\"font-size: inherit; line-height: inherit; color: #eedc70; overflow-wrap: inherit !important; word-break: inherit !important;\">'RS200'<\/span>]=ta.RSI(data.close,timeperiod=<span style=\"font-size: inherit; line-height: inherit; color: #ae87fa; overflow-wrap: inherit !important; word-break: inherit !important;\">200<\/span>)\n\u00a0\u00a0\u00a0\u00a0data[<span style=\"font-size: inherit; line-height: inherit; color: #eedc70; overflow-wrap: inherit !important; word-break: inherit !important;\">'K10'<\/span>],data[<span style=\"font-size: inherit; line-height: inherit; color: #eedc70; overflow-wrap: inherit !important; word-break: inherit !important;\">'D10'<\/span>]=ta.STOCH(data.high,data.low,data.close,\u00a0fastk_period=<span style=\"font-size: inherit; line-height: inherit; color: #ae87fa; overflow-wrap: inherit !important; word-break: inherit !important;\">10<\/span>)\n\u00a0\u00a0\u00a0\u00a0data[<span style=\"font-size: inherit; line-height: inherit; color: #eedc70; overflow-wrap: inherit !important; word-break: inherit !important;\">'K30'<\/span>],data[<span style=\"font-size: inherit; line-height: inherit; color: #eedc70; overflow-wrap: inherit !important; word-break: inherit !important;\">'D30'<\/span>]=ta.STOCH(data.high,data.low,data.close,\u00a0fastk_period=<span style=\"font-size: inherit; line-height: inherit; color: #ae87fa; overflow-wrap: inherit !important; word-break: inherit !important;\">30<\/span>)\n\u00a0\u00a0\u00a0\u00a0data[<span style=\"font-size: inherit; line-height: inherit; color: #eedc70; overflow-wrap: inherit !important; word-break: inherit !important;\">'K20'<\/span>],data[<span style=\"font-size: inherit; line-height: inherit; color: #eedc70; overflow-wrap: inherit !important; word-break: inherit !important;\">'D200'<\/span>]=ta.STOCH(data.high,data.low,data.close,\u00a0fastk_period=<span style=\"font-size: inherit; line-height: inherit; color: #ae87fa; overflow-wrap: inherit !important; word-break: inherit !important;\">200<\/span>)\n<\/code><\/pre>\n<pre style=\"font-size: inherit; color: inherit; line-height: inherit;\"><code style=\"margin-right: 2px; margin-left: 2px; line-height: 15px; font-size: 11px; word-spacing: -3px; letter-spacing: 0px; border-radius: 0px; color: #a9b7c6; background: #282b2e; padding: 0.5em; font-family: Consolas, Inconsolata, Courier, monospace; overflow-wrap: normal !important; word-break: normal !important; overflow: auto !important; display: -webkit-box !important;\">indicators(df_tr2)\nindicators(df_te2)\n<\/code><\/pre>\n<pre style=\"font-size: inherit; color: inherit; line-height: inherit;\"><code style=\"margin-right: 2px; margin-left: 2px; line-height: 15px; font-size: 11px; word-spacing: -3px; letter-spacing: 0px; border-radius: 0px; color: #a9b7c6; background: #282b2e; padding: 0.5em; font-family: Consolas, Inconsolata, Courier, monospace; overflow-wrap: normal !important; word-break: normal !important; overflow: auto !important; display: -webkit-box !important;\">corrMat(df_tr2,<span style=\"font-size: inherit; line-height: inherit; color: #eedc70; overflow-wrap: inherit !important; word-break: inherit !important;\">'signal'<\/span>,figsize=(<span style=\"font-size: inherit; line-height: inherit; color: #ae87fa; overflow-wrap: inherit !important; word-break: inherit !important;\">15<\/span>,<span style=\"font-size: inherit; line-height: inherit; color: #ae87fa; overflow-wrap: inherit !important; word-break: inherit !important;\">0.5<\/span>))\n<\/code><\/pre>\n<p style=\"text-align: justify;\">\n<p style=\"text-align: justify;\"><span style=\"font-size: 15px; font-family: \u5fae\u8f6f\u96c5\u9ed1, 'Microsoft YaHei';\"><img decoding=\"async\" class=\"rich_pages wxw-img\" style=\"box-sizing: border-box; width: 'auto';\" title=\"Python+\u673a\u5668\u5b66\u4e60\u5bfb\u627e\u80a1\u7968\u4ea4\u6613\u4fe1\u53f7\" src=\"http:\/\/www.zhushiyao.com\/wp-content\/uploads\/2022\/02\/8-1645424110-1.png\" alt=\"Python+\u673a\u5668\u5b66\u4e60\u5bfb\u627e\u80a1\u7968\u4ea4\u6613\u4fe1\u53f7\" \/><\/span><\/p>\n<p style=\"text-align: justify;\">\n<p style=\"text-align: justify;\"><span style=\"font-size: 15px; font-family: \u5fae\u8f6f\u96c5\u9ed1, 'Microsoft YaHei';\">\u4e0a\u56fe\u53ef\u4ee5\u770b\u5230\u660e\u663e\u7ebf\u6027\u76f8\u5173\u7684\u4e00\u7ec4\u7279\u5f81\u662f\u4f5c\u4e3a\u7279\u5f81\u5de5\u7a0b\u7684\u7ed3\u679c\u521b\u5efa\u7684\u3002\u5982\u679c\u5728\u7279\u5f81\u77e9\u9635\u4e2d\u4f7f\u7528\u57fa\u672c\u6570\u636e\u96c6\u7279\u5f81\uff0c\u5f88\u53ef\u80fd\u5bf9\u76ee\u6807\u53d8\u91cf\u7684\u53d8\u5316\u5f71\u54cd\u5f88\u5c0f\u6216\u6ca1\u6709\u5f71\u54cd\u3002\u53e6\u4e00\u65b9\u9762\uff0c\u65b0\u521b\u5efa\u7684\u7279\u5f81\u5177\u6709\u76f8\u5f53\u5bbd\u7684\u76f8\u5173\u503c\u8303\u56f4\uff0c\u8fd9\u662f\u76f8\u5f53\u91cd\u8981\u7684;\u4e0e\u76ee\u6807\u53d8\u91cf\uff08\u4ea4\u6613\u4fe1\u53f7\uff09\u7684\u76f8\u5173\u6027\u4e0d\u7b97\u7279\u522b\u9ad8\u3002<\/span><\/p>\n<p style=\"text-align: justify;\">\n<pre style=\"font-size: inherit; color: inherit; line-height: inherit;\"><code style=\"margin-right: 2px; margin-left: 2px; line-height: 15px; font-size: 11px; word-spacing: -3px; letter-spacing: 0px; border-radius: 0px; color: #a9b7c6; background: #282b2e; padding: 0.5em; font-family: Consolas, Inconsolata, Courier, monospace; overflow-wrap: normal !important; word-break: normal !important; overflow: auto !important; display: -webkit-box !important;\"><span style=\"font-size: inherit; line-height: inherit; color: #808080; overflow-wrap: inherit !important; word-break: inherit !important;\">#\u5220\u9664\u7f3a\u5931\u503c<\/span>\ndf_tr2\u00a0=\u00a0df_tr2.dropna()\u00a0\ndf_te2\u00a0=\u00a0df_te2.dropna()\n<\/code><\/pre>\n<p style=\"font-size: 15px; font-family: \u5fae\u8f6f\u96c5\u9ed1, 'Microsoft YaHei';\">\n<p style=\"font-size: 15px; font-family: \u5fae\u8f6f\u96c5\u9ed1, 'Microsoft YaHei';\">\n<p style=\"font-size: 15px; font-family: \u5fae\u8f6f\u96c5\u9ed1, 'Microsoft YaHei';\">\n<section>\n<section style=\"margin: 10px auto;\">\n<section style=\"display: flex; justify-content: center;\">\n<section>\n<section style=\"display: flex;\">\n<section style=\"color: white; background-color: #3b5cf4; padding-right: 6px; padding-left: 6px; line-height: 1.75em; letter-spacing: 1px; font-size: 16px;\">0<span title=\"\">3<\/span><\/section>\n<section style=\"color: #3b5cf4; padding-right: 8px; padding-left: 8px; letter-spacing: 1.5px; line-height: 1.75em; font-size: 16px;\">\u6a21\u578b\u9884\u6d4b\u4e0e\u8bc4\u4f30<\/section>\n<\/section>\n<section style=\"display: flex; justify-content: center; align-items: center; margin-top: 3px;\">\n<section style=\"width: 70%; height: 2px; background: #3b5cf4; overflow: hidden;\"><\/section>\n<section style=\"width: 30%; height: 2px; background: #ffc756; overflow: hidden;\"><\/section>\n<\/section>\n<\/section>\n<\/section>\n<\/section>\n<\/section>\n<p><span style=\"font-size: 15px; font-family: \u5fae\u8f6f\u96c5\u9ed1, 'Microsoft YaHei';\">\u4e0b\u9762\u4f7f\u7528\u5e38\u7528\u7684\u673a\u5668\u5b66\u4e60\u7b97\u6cd5\u5206\u522b\u5bf9\u6570\u636e\u8fdb\u884c\u62df\u5408\u548c\u4ea4\u53c9\u9a8c\u8bc1\u8bc4\u4f30\u3002<\/span><\/p>\n<p style=\"font-size: inherit; color: inherit; line-height: inherit;\"><code style=\"white-space: pre-wrap; margin-right: 2px; margin-left: 2px; line-height: 15px; font-size: 11px; word-spacing: -3px; letter-spacing: 0px; border-radius: 0px; color: #a9b7c6; background: #282b2e; padding: 0.5em; font-family: Consolas, Inconsolata, Courier, monospace; overflow-wrap: normal !important; word-break: normal !important; overflow: auto !important; display: -webkit-box !important;\">models.append((<span style=\"font-size: inherit; line-height: inherit; color: #eedc70; overflow-wrap: inherit !important; word-break: inherit !important;\">'RF'<\/span>,\u00a0RandomForestClassifier(n_estimators=<span style=\"font-size: inherit; line-height: inherit; color: #ae87fa; overflow-wrap: inherit !important; word-break: inherit !important;\">25<\/span>)))<\/code><\/p>\n<pre><code style=\"margin-right: 2px; margin-left: 2px; line-height: 15px; font-size: 11px; word-spacing: -3px; letter-spacing: 0px; border-radius: 0px; color: #a9b7c6; background: #282b2e; padding: 0.5em; font-family: Consolas, Inconsolata, Courier, monospace; overflow-wrap: normal !important; word-break: normal !important; overflow: auto !important; display: -webkit-box !important;\">models\u00a0=\u00a0[]\n<span style=\"font-size: inherit; line-height: inherit; color: #808080; overflow-wrap: inherit !important; word-break: inherit !important;\">#\u8f7b\u91cf\u7ea7\u6a21\u578b\u00a0<\/span>\n<span style=\"font-size: inherit; line-height: inherit; color: #808080; overflow-wrap: inherit !important; word-break: inherit !important;\">#\u7ebf\u6027\u76d1\u7763\u6a21\u578b<\/span>\nmodels.append((<span style=\"font-size: inherit; line-height: inherit; color: #eedc70; overflow-wrap: inherit !important; word-break: inherit !important;\">'LR'<\/span>,\u00a0LogisticRegression(n_jobs=<span style=\"font-size: inherit; line-height: inherit; color: #ae87fa; overflow-wrap: inherit !important; word-break: inherit !important;\">-1<\/span>)))\nmodels.append((<span style=\"font-size: inherit; line-height: inherit; color: #eedc70; overflow-wrap: inherit !important; word-break: inherit !important;\">'TREE'<\/span>,\u00a0DecisionTreeClassifier()))\u00a0\n<span style=\"font-size: inherit; line-height: inherit; color: #808080; overflow-wrap: inherit !important; word-break: inherit !important;\">#\u975e\u76d1\u7763\u6a21\u578b<\/span>\nmodels.append((<span style=\"font-size: inherit; line-height: inherit; color: #eedc70; overflow-wrap: inherit !important; word-break: inherit !important;\">'LDA'<\/span>,\u00a0LinearDiscriminantAnalysis()))\u00a0\nmodels.append((<span style=\"font-size: inherit; line-height: inherit; color: #eedc70; overflow-wrap: inherit !important; word-break: inherit !important;\">'KNN'<\/span>,\u00a0KNeighborsClassifier()))\u00a0\nmodels.append((<span style=\"font-size: inherit; line-height: inherit; color: #eedc70; overflow-wrap: inherit !important; word-break: inherit !important;\">'NB'<\/span>,\u00a0GaussianNB()))\u00a0\n<span style=\"font-size: inherit; line-height: inherit; color: #808080; overflow-wrap: inherit !important; word-break: inherit !important;\">#\u9ad8\u7ea7\u6a21\u578b<\/span>\nmodels.append((<span style=\"font-size: inherit; line-height: inherit; color: #eedc70; overflow-wrap: inherit !important; word-break: inherit !important;\">'GBM'<\/span>,\u00a0GradientBoostingClassifier(n_estimators=<span style=\"font-size: inherit; line-height: inherit; color: #ae87fa; overflow-wrap: inherit !important; word-break: inherit !important;\">25<\/span>)))\nmodels.append((<span style=\"font-size: inherit; line-height: inherit; color: #eedc70; overflow-wrap: inherit !important; word-break: inherit !important;\">'XGB'<\/span>,XGBClassifier(n_estimators=<span style=\"font-size: inherit; line-height: inherit; color: #ae87fa; overflow-wrap: inherit !important; word-break: inherit !important;\">25<\/span>,use_label_encoder=<span style=\"font-size: inherit; line-height: inherit; color: #f82375; overflow-wrap: inherit !important; word-break: inherit !important;\">False<\/span>)))\nmodels.append((<span style=\"font-size: inherit; line-height: inherit; color: #eedc70; overflow-wrap: inherit !important; word-break: inherit !important;\">'CAT'<\/span>,CatBoostClassifier(silent=<span style=\"font-size: inherit; line-height: inherit; color: #f82375; overflow-wrap: inherit !important; word-break: inherit !important;\">True<\/span>,n_estimators=<span style=\"font-size: inherit; line-height: inherit; color: #ae87fa; overflow-wrap: inherit !important; word-break: inherit !important;\">25<\/span>)))\n<\/code><\/pre>\n<p><span style=\"font-size: 15px; font-family: \u5fae\u8f6f\u96c5\u9ed1, 'Microsoft YaHei';\">\u6784\u5efa\u6a21\u578b\u8bc4\u4f30\u51fd\u6570<\/span><\/p>\n<pre style=\"font-size: inherit; color: inherit; line-height: inherit;\"><code style=\"margin-right: 2px; margin-left: 2px; line-height: 15px; font-size: 11px; word-spacing: -3px; letter-spacing: 0px; border-radius: 0px; color: #a9b7c6; background: #282b2e; padding: 0.5em; font-family: Consolas, Inconsolata, Courier, monospace; overflow-wrap: normal !important; word-break: normal !important; overflow: auto !important; display: -webkit-box !important;\"><span style=\"font-size: inherit; line-height: inherit; color: #f82375; overflow-wrap: inherit !important; word-break: inherit !important;\"><span style=\"font-size: inherit; line-height: inherit; overflow-wrap: inherit !important; word-break: inherit !important;\">def<\/span>\u00a0<span style=\"font-size: inherit; line-height: inherit; color: #a5da2d; overflow-wrap: inherit !important; word-break: inherit !important;\">modelEval<\/span><span style=\"font-size: inherit; line-height: inherit; color: #ff9823; overflow-wrap: inherit !important; word-break: inherit !important;\">(ldf,feature=<span style=\"font-size: inherit; line-height: inherit; color: #eedc70; overflow-wrap: inherit !important; word-break: inherit !important;\">'signal'<\/span>,split_id=[None,None],eval_id=[True,True,True,True],\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0n_fold=<span style=\"font-size: inherit; line-height: inherit; color: #ae87fa; overflow-wrap: inherit !important; word-break: inherit !important;\">5<\/span>,scoring=<span style=\"font-size: inherit; line-height: inherit; color: #eedc70; overflow-wrap: inherit !important; word-break: inherit !important;\">'accuracy'<\/span>,cv_yrange=None,hm_vvals=[<span style=\"font-size: inherit; line-height: inherit; color: #ae87fa; overflow-wrap: inherit !important; word-break: inherit !important;\">0.5<\/span>,<span style=\"font-size: inherit; line-height: inherit; color: #ae87fa; overflow-wrap: inherit !important; word-break: inherit !important;\">1.0<\/span>,<span style=\"font-size: inherit; line-height: inherit; color: #ae87fa; overflow-wrap: inherit !important; word-break: inherit !important;\">0.75<\/span>])<\/span>:<\/span>\n\n\u00a0\u00a0\u00a0\u00a0<span style=\"font-size: inherit; line-height: inherit; color: #eedc70; overflow-wrap: inherit !important; word-break: inherit !important;\">'''\u00a0Split\u00a0Train\/Evaluation\u00a0&lt;DataFrame&gt;\u00a0Set\u00a0Split\u00a0'''<\/span>\n\n\u00a0\u00a0\u00a0\u00a0<span style=\"font-size: inherit; line-height: inherit; color: #808080; overflow-wrap: inherit !important; word-break: inherit !important;\">#\u00a0split_id\u00a0:\u00a0Train\/Test\u00a0split\u00a0[%,timestamp],\u00a0whichever\u00a0is\u00a0not\u00a0None<\/span>\n\u00a0\u00a0\u00a0\u00a0<span style=\"font-size: inherit; line-height: inherit; color: #808080; overflow-wrap: inherit !important; word-break: inherit !important;\">#\u00a0test_id\u00a0:\u00a0Evaluate\u00a0trained\u00a0model\u00a0on\u00a0test\u00a0set\u00a0only<\/span>\n\n\u00a0\u00a0\u00a0\u00a0<span style=\"font-size: inherit; line-height: inherit; color: #f82375; overflow-wrap: inherit !important; word-break: inherit !important;\">if<\/span>(split_id[<span style=\"font-size: inherit; line-height: inherit; color: #ae87fa; overflow-wrap: inherit !important; word-break: inherit !important;\">0<\/span>]\u00a0<span style=\"font-size: inherit; line-height: inherit; color: #f82375; overflow-wrap: inherit !important; word-break: inherit !important;\">is<\/span>\u00a0<span style=\"font-size: inherit; line-height: inherit; color: #f82375; overflow-wrap: inherit !important; word-break: inherit !important;\">not<\/span>\u00a0<span style=\"font-size: inherit; line-height: inherit; color: #f82375; overflow-wrap: inherit !important; word-break: inherit !important;\">None<\/span>):\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0train_df,eval_df\u00a0=\u00a0train_test_split(ldf,test_size=split_id[<span style=\"font-size: inherit; line-height: inherit; color: #ae87fa; overflow-wrap: inherit !important; word-break: inherit !important;\">0<\/span>],shuffle=<span style=\"font-size: inherit; line-height: inherit; color: #f82375; overflow-wrap: inherit !important; word-break: inherit !important;\">False<\/span>)\n\u00a0\u00a0\u00a0\u00a0<span style=\"font-size: inherit; line-height: inherit; color: #f82375; overflow-wrap: inherit !important; word-break: inherit !important;\">elif<\/span>(split_id[<span style=\"font-size: inherit; line-height: inherit; color: #ae87fa; overflow-wrap: inherit !important; word-break: inherit !important;\">1<\/span>]\u00a0<span style=\"font-size: inherit; line-height: inherit; color: #f82375; overflow-wrap: inherit !important; word-break: inherit !important;\">is<\/span>\u00a0<span style=\"font-size: inherit; line-height: inherit; color: #f82375; overflow-wrap: inherit !important; word-break: inherit !important;\">not<\/span>\u00a0<span style=\"font-size: inherit; line-height: inherit; color: #f82375; overflow-wrap: inherit !important; word-break: inherit !important;\">None<\/span>):\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0train_df\u00a0=\u00a0df.loc[:split_id[<span style=\"font-size: inherit; line-height: inherit; color: #ae87fa; overflow-wrap: inherit !important; word-break: inherit !important;\">1<\/span>]];\u00a0eval_df\u00a0=\u00a0df.loc[split_id[<span style=\"font-size: inherit; line-height: inherit; color: #ae87fa; overflow-wrap: inherit !important; word-break: inherit !important;\">1<\/span>]:]\u00a0\n\u00a0\u00a0\u00a0\u00a0<span style=\"font-size: inherit; line-height: inherit; color: #f82375; overflow-wrap: inherit !important; word-break: inherit !important;\">else<\/span>:\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0print(<span style=\"font-size: inherit; line-height: inherit; color: #eedc70; overflow-wrap: inherit !important; word-break: inherit !important;\">'Choose\u00a0One\u00a0Splitting\u00a0Method\u00a0Only'<\/span>)\n\n\u00a0\u00a0\u00a0\u00a0<span style=\"font-size: inherit; line-height: inherit; color: #eedc70; overflow-wrap: inherit !important; word-break: inherit !important;\">'''\u00a0Train\/Test\u00a0Feature\u00a0Matrices\u00a0+\u00a0Target\u00a0Variables\u00a0Split'''<\/span>\n\u00a0\u00a0\u00a0\u00a0y_train\u00a0=\u00a0train_df[feature]\n\u00a0\u00a0\u00a0\u00a0X_train\u00a0=\u00a0train_df.loc[:,\u00a0train_df.columns\u00a0!=\u00a0feature]\n\u00a0\u00a0\u00a0\u00a0y_eval\u00a0=\u00a0eval_df[feature]\n\u00a0\u00a0\u00a0\u00a0X_eval\u00a0=\u00a0eval_df.loc[:,\u00a0eval_df.columns\u00a0!=\u00a0feature]\n\u00a0\u00a0\u00a0\u00a0X_one\u00a0=\u00a0pd.concat([X_train,X_eval],axis=<span style=\"font-size: inherit; line-height: inherit; color: #ae87fa; overflow-wrap: inherit !important; word-break: inherit !important;\">0<\/span>)\n\u00a0\u00a0\u00a0\u00a0y_one\u00a0=\u00a0pd.concat([y_train,y_eval],axis=<span style=\"font-size: inherit; line-height: inherit; color: #ae87fa; overflow-wrap: inherit !important; word-break: inherit !important;\">0<\/span>)\n\n\u00a0\u00a0\u00a0\u00a0<span style=\"font-size: inherit; line-height: inherit; color: #eedc70; overflow-wrap: inherit !important; word-break: inherit !important;\">'''\u00a0Cross\u00a0Validation,\u00a0Training\/Evaluation,\u00a0one\u00a0evaluation'''<\/span>\n\u00a0\u00a0\u00a0\u00a0lst_res\u00a0=\u00a0[];\u00a0names\u00a0=\u00a0[];\u00a0lst_train\u00a0=\u00a0[];\u00a0lst_eval\u00a0=\u00a0[];\u00a0lst_one\u00a0=\u00a0[];\u00a0lst_res_mean\u00a0=\u00a0[]\n\u00a0\u00a0\u00a0\u00a0<span style=\"font-size: inherit; line-height: inherit; color: #f82375; overflow-wrap: inherit !important; word-break: inherit !important;\">if<\/span>(any(eval_id)):\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0<span style=\"font-size: inherit; line-height: inherit; color: #f82375; overflow-wrap: inherit !important; word-break: inherit !important;\">for<\/span>\u00a0name,\u00a0model\u00a0<span style=\"font-size: inherit; line-height: inherit; color: #f82375; overflow-wrap: inherit !important; word-break: inherit !important;\">in<\/span>\u00a0models:\u00a0\u00a0\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0names.append(name)\n\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0<span style=\"font-size: inherit; line-height: inherit; color: #808080; overflow-wrap: inherit !important; word-break: inherit !important;\">#\u00a0Cross\u00a0Validation\u00a0Model\u00a0on\u00a0Training\u00a0Se<\/span>\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0<span style=\"font-size: inherit; line-height: inherit; color: #f82375; overflow-wrap: inherit !important; word-break: inherit !important;\">if<\/span>(eval_id[<span style=\"font-size: inherit; line-height: inherit; color: #ae87fa; overflow-wrap: inherit !important; word-break: inherit !important;\">0<\/span>]):\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0kfold\u00a0=\u00a0KFold(n_splits=n_fold,\u00a0shuffle=<span style=\"font-size: inherit; line-height: inherit; color: #f82375; overflow-wrap: inherit !important; word-break: inherit !important;\">True<\/span>)\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0cv_res\u00a0=\u00a0cross_val_score(model,X_train,y_train,\u00a0cv=kfold,\u00a0scoring=scoring)\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0lst_res.append(cv_res)\n\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0<span style=\"font-size: inherit; line-height: inherit; color: #808080; overflow-wrap: inherit !important; word-break: inherit !important;\">#\u00a0Evaluate\u00a0Fit\u00a0Model\u00a0on\u00a0Training\u00a0Data<\/span>\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0<span style=\"font-size: inherit; line-height: inherit; color: #f82375; overflow-wrap: inherit !important; word-break: inherit !important;\">if<\/span>(eval_id[<span style=\"font-size: inherit; line-height: inherit; color: #ae87fa; overflow-wrap: inherit !important; word-break: inherit !important;\">1<\/span>]):\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0res\u00a0=\u00a0model.fit(X_train,y_train)\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0train_res\u00a0=\u00a0accuracy_score(res.predict(X_train),y_train);\u00a0lst_train.append(train_res)\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0<span style=\"font-size: inherit; line-height: inherit; color: #f82375; overflow-wrap: inherit !important; word-break: inherit !important;\">if<\/span>(eval_id[<span style=\"font-size: inherit; line-height: inherit; color: #ae87fa; overflow-wrap: inherit !important; word-break: inherit !important;\">2<\/span>]):\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0<span style=\"font-size: inherit; line-height: inherit; color: #f82375; overflow-wrap: inherit !important; word-break: inherit !important;\">if<\/span>(eval_id[<span style=\"font-size: inherit; line-height: inherit; color: #ae87fa; overflow-wrap: inherit !important; word-break: inherit !important;\">1<\/span>]\u00a0<span style=\"font-size: inherit; line-height: inherit; color: #f82375; overflow-wrap: inherit !important; word-break: inherit !important;\">is<\/span>\u00a0<span style=\"font-size: inherit; line-height: inherit; color: #f82375; overflow-wrap: inherit !important; word-break: inherit !important;\">False<\/span>):\u00a0\u00a0<span style=\"font-size: inherit; line-height: inherit; color: #808080; overflow-wrap: inherit !important; word-break: inherit !important;\">#\u00a0If\u00a0training\u00a0hasn't\u00a0been\u00a0called\u00a0yet<\/span>\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0res\u00a0=\u00a0model.fit(X_train,y_train)\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0eval_res\u00a0=\u00a0accuracy_score(res.predict(X_eval),y_eval);\u00a0lst_eval.append(eval_res)\n\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0<span style=\"font-size: inherit; line-height: inherit; color: #808080; overflow-wrap: inherit !important; word-break: inherit !important;\">#\u00a0Evaluate\u00a0model\u00a0on\u00a0entire\u00a0dataset<\/span>\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0<span style=\"font-size: inherit; line-height: inherit; color: #f82375; overflow-wrap: inherit !important; word-break: inherit !important;\">if<\/span>(eval_id[<span style=\"font-size: inherit; line-height: inherit; color: #ae87fa; overflow-wrap: inherit !important; word-break: inherit !important;\">3<\/span>]):\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0res\u00a0=\u00a0model.fit(X_one,y_one)\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0one_res\u00a0=\u00a0accuracy_score(res.predict(X_one),y_one);\u00a0lst_one.append(one_res)\n\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0<span style=\"font-size: inherit; line-height: inherit; color: #eedc70; overflow-wrap: inherit !important; word-break: inherit !important;\">'''\u00a0[out]\u00a0Verbal\u00a0Outputs\u00a0'''<\/span>\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0lst_res_mean.append(cv_res.mean())\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0fn1\u00a0=\u00a0cv_res.mean()\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0fn2\u00a0=\u00a0cv_res.std();\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0fn3\u00a0=\u00a0train_res\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0fn4\u00a0=\u00a0eval_res\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0fn5\u00a0=\u00a0one_res\n\n\u00a0\u00a0\u00a0\u00a0s0\u00a0=\u00a0pd.Series(np.array(lst_res_mean),index=names)\n\u00a0\u00a0\u00a0\u00a0s1\u00a0=\u00a0pd.Series(np.array(lst_train),index=names)\n\u00a0\u00a0\u00a0\u00a0s2\u00a0=\u00a0pd.Series(np.array(lst_eval),index=names)\n\u00a0\u00a0\u00a0\u00a0s3\u00a0=\u00a0pd.Series(np.array(lst_one),index=names)\n\u00a0\u00a0\u00a0\u00a0pdf\u00a0=\u00a0pd.concat([s0,s1,s2,s3],axis=<span style=\"font-size: inherit; line-height: inherit; color: #ae87fa; overflow-wrap: inherit !important; word-break: inherit !important;\">1<\/span>)\n\u00a0\u00a0\u00a0\u00a0pdf.columns\u00a0=\u00a0[<span style=\"font-size: inherit; line-height: inherit; color: #eedc70; overflow-wrap: inherit !important; word-break: inherit !important;\">'cv_average'<\/span>,<span style=\"font-size: inherit; line-height: inherit; color: #eedc70; overflow-wrap: inherit !important; word-break: inherit !important;\">'train'<\/span>,<span style=\"font-size: inherit; line-height: inherit; color: #eedc70; overflow-wrap: inherit !important; word-break: inherit !important;\">'test'<\/span>,<span style=\"font-size: inherit; line-height: inherit; color: #eedc70; overflow-wrap: inherit !important; word-break: inherit !important;\">'all'<\/span>]\n\n\u00a0\u00a0\u00a0\u00a0<span style=\"font-size: inherit; line-height: inherit; color: #eedc70; overflow-wrap: inherit !important; word-break: inherit !important;\">'''\u00a0Visual\u00a0Ouputs\u00a0'''<\/span>\n\u00a0\u00a0\u00a0\u00a0sns.set(style=<span style=\"font-size: inherit; line-height: inherit; color: #eedc70; overflow-wrap: inherit !important; word-break: inherit !important;\">\"whitegrid\"<\/span>)\n\u00a0\u00a0\u00a0\u00a0fig,ax\u00a0=\u00a0plt.subplots(<span style=\"font-size: inherit; line-height: inherit; color: #ae87fa; overflow-wrap: inherit !important; word-break: inherit !important;\">1<\/span>,<span style=\"font-size: inherit; line-height: inherit; color: #ae87fa; overflow-wrap: inherit !important; word-break: inherit !important;\">2<\/span>,figsize=(<span style=\"font-size: inherit; line-height: inherit; color: #ae87fa; overflow-wrap: inherit !important; word-break: inherit !important;\">15<\/span>,<span style=\"font-size: inherit; line-height: inherit; color: #ae87fa; overflow-wrap: inherit !important; word-break: inherit !important;\">4<\/span>))\n\u00a0\u00a0\u00a0\u00a0ax[<span style=\"font-size: inherit; line-height: inherit; color: #ae87fa; overflow-wrap: inherit !important; word-break: inherit !important;\">0<\/span>].set_title(<span style=\"font-size: inherit; line-height: inherit; color: #eedc70; overflow-wrap: inherit !important; word-break: inherit !important;\">f'<span style=\"font-size: inherit; color: inherit; line-height: inherit; overflow-wrap: inherit !important; word-break: inherit !important;\">{n_fold}<\/span>\u00a0Cross\u00a0Validation\u00a0Results'<\/span>)\n\u00a0\u00a0\u00a0\u00a0sns.boxplot(data=lst_res,\u00a0ax=ax[<span style=\"font-size: inherit; line-height: inherit; color: #ae87fa; overflow-wrap: inherit !important; word-break: inherit !important;\">0<\/span>],\u00a0orient=<span style=\"font-size: inherit; line-height: inherit; color: #eedc70; overflow-wrap: inherit !important; word-break: inherit !important;\">\"v\"<\/span>,width=<span style=\"font-size: inherit; line-height: inherit; color: #ae87fa; overflow-wrap: inherit !important; word-break: inherit !important;\">0.3<\/span>)\n\u00a0\u00a0\u00a0\u00a0ax[<span style=\"font-size: inherit; line-height: inherit; color: #ae87fa; overflow-wrap: inherit !important; word-break: inherit !important;\">0<\/span>].set_xticklabels(names)\n\u00a0\u00a0\u00a0\u00a0sns.stripplot(data=lst_res,ax=ax[<span style=\"font-size: inherit; line-height: inherit; color: #ae87fa; overflow-wrap: inherit !important; word-break: inherit !important;\">0<\/span>],\u00a0orient=<span style=\"font-size: inherit; line-height: inherit; color: #eedc70; overflow-wrap: inherit !important; word-break: inherit !important;\">'v'<\/span>,color=<span style=\"font-size: inherit; line-height: inherit; color: #eedc70; overflow-wrap: inherit !important; word-break: inherit !important;\">\".3\"<\/span>,linewidth=<span style=\"font-size: inherit; line-height: inherit; color: #ae87fa; overflow-wrap: inherit !important; word-break: inherit !important;\">1<\/span>)\n\u00a0\u00a0\u00a0\u00a0ax[<span style=\"font-size: inherit; line-height: inherit; color: #ae87fa; overflow-wrap: inherit !important; word-break: inherit !important;\">0<\/span>].set_xticklabels(names)\n\u00a0\u00a0\u00a0\u00a0ax[<span style=\"font-size: inherit; line-height: inherit; color: #ae87fa; overflow-wrap: inherit !important; word-break: inherit !important;\">0<\/span>].xaxis.grid(<span style=\"font-size: inherit; line-height: inherit; color: #f82375; overflow-wrap: inherit !important; word-break: inherit !important;\">True<\/span>)\n\u00a0\u00a0\u00a0\u00a0ax[<span style=\"font-size: inherit; line-height: inherit; color: #ae87fa; overflow-wrap: inherit !important; word-break: inherit !important;\">0<\/span>].set(xlabel=<span style=\"font-size: inherit; line-height: inherit; color: #eedc70; overflow-wrap: inherit !important; word-break: inherit !important;\">\"\"<\/span>)\n\u00a0\u00a0\u00a0\u00a0<span style=\"font-size: inherit; line-height: inherit; color: #f82375; overflow-wrap: inherit !important; word-break: inherit !important;\">if<\/span>(cv_yrange\u00a0<span style=\"font-size: inherit; line-height: inherit; color: #f82375; overflow-wrap: inherit !important; word-break: inherit !important;\">is<\/span>\u00a0<span style=\"font-size: inherit; line-height: inherit; color: #f82375; overflow-wrap: inherit !important; word-break: inherit !important;\">not<\/span>\u00a0<span style=\"font-size: inherit; line-height: inherit; color: #f82375; overflow-wrap: inherit !important; word-break: inherit !important;\">None<\/span>):\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0ax[<span style=\"font-size: inherit; line-height: inherit; color: #ae87fa; overflow-wrap: inherit !important; word-break: inherit !important;\">0<\/span>].set_ylim(cv_yrange)\n\u00a0\u00a0\u00a0\u00a0sns.despine(trim=<span style=\"font-size: inherit; line-height: inherit; color: #f82375; overflow-wrap: inherit !important; word-break: inherit !important;\">True<\/span>,\u00a0left=<span style=\"font-size: inherit; line-height: inherit; color: #f82375; overflow-wrap: inherit !important; word-break: inherit !important;\">True<\/span>)\n\u00a0\u00a0\u00a0\u00a0sns.heatmap(pdf,vmin=hm_vvals[<span style=\"font-size: inherit; line-height: inherit; color: #ae87fa; overflow-wrap: inherit !important; word-break: inherit !important;\">0<\/span>],vmax=hm_vvals[<span style=\"font-size: inherit; line-height: inherit; color: #ae87fa; overflow-wrap: inherit !important; word-break: inherit !important;\">1<\/span>],center=hm_vvals[<span style=\"font-size: inherit; line-height: inherit; color: #ae87fa; overflow-wrap: inherit !important; word-break: inherit !important;\">2<\/span>],\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0ax=ax[<span style=\"font-size: inherit; line-height: inherit; color: #ae87fa; overflow-wrap: inherit !important; word-break: inherit !important;\">1<\/span>],square=<span style=\"font-size: inherit; line-height: inherit; color: #f82375; overflow-wrap: inherit !important; word-break: inherit !important;\">False<\/span>,lw=<span style=\"font-size: inherit; line-height: inherit; color: #ae87fa; overflow-wrap: inherit !important; word-break: inherit !important;\">2<\/span>,annot=<span style=\"font-size: inherit; line-height: inherit; color: #f82375; overflow-wrap: inherit !important; word-break: inherit !important;\">True<\/span>,fmt=<span style=\"font-size: inherit; line-height: inherit; color: #eedc70; overflow-wrap: inherit !important; word-break: inherit !important;\">'.3f'<\/span>,cmap=<span style=\"font-size: inherit; line-height: inherit; color: #eedc70; overflow-wrap: inherit !important; word-break: inherit !important;\">'Blues'<\/span>)\n\u00a0\u00a0\u00a0\u00a0ax[<span style=\"font-size: inherit; line-height: inherit; color: #ae87fa; overflow-wrap: inherit !important; word-break: inherit !important;\">1<\/span>].set_title(<span style=\"font-size: inherit; line-height: inherit; color: #eedc70; overflow-wrap: inherit !important; word-break: inherit !important;\">'Accuracy\u00a0Scores'<\/span>)\n\u00a0\u00a0\u00a0\u00a0plt.show()\n<\/code><\/pre>\n<h3 style=\"font-weight: bold; line-height: 1.6;\"><\/h3>\n<h3 style=\"font-weight: bold; line-height: 1.6;\"><span style=\"font-size: 15px;\">\u57fa\u51c6\u6a21\u578b\uff1a\u4f7f\u7528\u539f\u59cb\u884c\u60c5\u6570\u636e\u4f5c\u4e3a\u7279\u5f81<\/span><\/h3>\n<pre style=\"font-size: inherit; color: inherit; line-height: inherit;\"><code style=\"margin-right: 2px; margin-left: 2px; line-height: 15px; font-size: 11px; word-spacing: -3px; letter-spacing: 0px; border-radius: 0px; color: #a9b7c6; background: #282b2e; padding: 0.5em; font-family: Consolas, Inconsolata, Courier, monospace; overflow-wrap: normal !important; word-break: normal !important; overflow: auto !important; display: -webkit-box !important;\">modelEval(df_tr1,split_id=[<span style=\"font-size: inherit; line-height: inherit; color: #ae87fa; overflow-wrap: inherit !important; word-break: inherit !important;\">0.2<\/span>,<span style=\"font-size: inherit; line-height: inherit; color: #f82375; overflow-wrap: inherit !important; word-break: inherit !important;\">None<\/span>])\n<\/code><\/pre>\n<figure style=\"font-size: inherit; color: inherit; line-height: inherit;\"><figcaption style=\"line-height: inherit; margin-top: 10px; text-align: center; color: #999999; font-size: 0.7em;\"><img decoding=\"async\" class=\"rich_pages wxw-img\" style=\"box-sizing: border-box; width: 'auto';\" title=\"Python+\u673a\u5668\u5b66\u4e60\u5bfb\u627e\u80a1\u7968\u4ea4\u6613\u4fe1\u53f7\" src=\"http:\/\/www.zhushiyao.com\/wp-content\/uploads\/2022\/02\/3-1645424110-1.png\" alt=\"Python+\u673a\u5668\u5b66\u4e60\u5bfb\u627e\u80a1\u7968\u4ea4\u6613\u4fe1\u53f7\" \/><\/figcaption><\/figure>\n<p><span style=\"font-size: 15px; font-family: \u5fae\u8f6f\u96c5\u9ed1, 'Microsoft YaHei';\">\u7ed3\u679c\u663e\u793a\uff0ccross_val_score\u5f98\u5f8a\u5728\u51c6\u786e\u5ea6= 0.5\u7684\u533a\u57df\uff0c\u8fd9\u8868\u660e\u4ec5\u4f7f\u7528\u6307\u6570\/\u80a1\u7968\u7684\u4ef7\u683c\u6570\u636e\uff08\u5f00\u76d8\u3001\u6700\u9ad8\u3001\u6700\u4f4e\u3001\u6210\u4ea4\u91cf\u3001\u6536\u76d8\uff09\u5f88\u96be\u51c6\u786e\u9884\u6d4b\u4ef7\u683c\u53d8\u52a8\u7684\u65b9\u5411\u6027\u3002<\/span><span style=\"font-size: 15px; caret-color: red; font-family: \u5fae\u8f6f\u96c5\u9ed1, 'Microsoft YaHei';\">\u5927\u591a\u6570\u6a21\u578b\u7684\u8bad\u7ec3\u5f97\u5206\u5f80\u5f80\u9ad8\u4e8e\u4ea4\u53c9\u9a8c\u8bc1\u5f97\u5206\u3002\u6709\u610f\u601d\u7684\u662f\uff0c<\/span><span style=\"font-size: 15px; caret-color: red; font-family: \u5fae\u8f6f\u96c5\u9ed1, 'Microsoft YaHei';\">DecisionTreeClassifier &amp; RandomForest\u5373\u4f7f\u5f88\u5c11\u4f30\u8ba1\u53ef\u4ee5\u8fbe\u5230\u975e\u5e38\u9ad8\u7684\u5206\u6570\uff0c\u4f46\u4ea4\u53c9\u9a8c\u8bc1\u7684\u5f97\u5206\u5374\u5f88\u4f4e\uff0c\u8868\u660e\u5bf9\u8bad\u7ec3\u6570\u636e\u53ef\u80fd\u5b58\u5728\u8fc7\u5ea6\u62df\u5408\u4e86\u3002<\/span><\/p>\n<h3 style=\"font-weight: bold; line-height: 1.6;\"><strong><span style=\"font-size: 15px; font-family: \u5fae\u8f6f\u96c5\u9ed1, 'Microsoft YaHei';\">\u52a0\u5165\u6280\u672f\u6307\u6807\u7279\u5f81<\/span><\/strong><\/h3>\n<pre style=\"font-size: inherit; color: inherit; line-height: inherit;\"><code style=\"margin-right: 2px; margin-left: 2px; line-height: 15px; font-size: 11px; word-spacing: -3px; letter-spacing: 0px; border-radius: 0px; color: #a9b7c6; background: #282b2e; padding: 0.5em; font-family: Consolas, Inconsolata, Courier, monospace; overflow-wrap: normal !important; word-break: normal !important; overflow: auto !important; display: -webkit-box !important;\">modelEval(df_tr2,split_id=[<span style=\"font-size: inherit; line-height: inherit; color: #ae87fa; overflow-wrap: inherit !important; word-break: inherit !important;\">0.2<\/span>,<span style=\"font-size: inherit; line-height: inherit; color: #f82375; overflow-wrap: inherit !important; word-break: inherit !important;\">None<\/span>],cv_yrange=(<span style=\"font-size: inherit; line-height: inherit; color: #ae87fa; overflow-wrap: inherit !important; word-break: inherit !important;\">0.8<\/span>,<span style=\"font-size: inherit; line-height: inherit; color: #ae87fa; overflow-wrap: inherit !important; word-break: inherit !important;\">1.0<\/span>),hm_vvals=[<span style=\"font-size: inherit; line-height: inherit; color: #ae87fa; overflow-wrap: inherit !important; word-break: inherit !important;\">0.8<\/span>,<span style=\"font-size: inherit; line-height: inherit; color: #ae87fa; overflow-wrap: inherit !important; word-break: inherit !important;\">1.0<\/span>,<span style=\"font-size: inherit; line-height: inherit; color: #ae87fa; overflow-wrap: inherit !important; word-break: inherit !important;\">0.9<\/span>])\n<\/code><\/pre>\n<p style=\"text-align: justify;\"><span style=\"font-size: 15px; font-family: \u5fae\u8f6f\u96c5\u9ed1, 'Microsoft YaHei';\"><img decoding=\"async\" class=\"rich_pages wxw-img\" style=\"box-sizing: border-box; width: 'auto';\" title=\"Python+\u673a\u5668\u5b66\u4e60\u5bfb\u627e\u80a1\u7968\u4ea4\u6613\u4fe1\u53f7\" src=\"http:\/\/www.zhushiyao.com\/wp-content\/uploads\/2022\/02\/6-1645424110.png\" alt=\"Python+\u673a\u5668\u5b66\u4e60\u5bfb\u627e\u80a1\u7968\u4ea4\u6613\u4fe1\u53f7\" \/><\/span><\/p>\n<p style=\"text-align: justify;\">\n<p style=\"text-align: justify;\"><span style=\"font-size: 15px; font-family: \u5fae\u8f6f\u96c5\u9ed1, 'Microsoft YaHei';\">\u7ed3\u679c\u8868\u660e\uff0c\u4e0e\u57fa\u51c6\u6a21\u578b\u76f8\u6bd4\uff0c\u51c6\u786e\u7387\u5f97\u5206\u6709\u4e86\u975e\u5e38\u663e\u8457\u7684\u63d0\u9ad8\u3002<\/span><span style=\"caret-color: red; font-size: 15px; font-family: \u5fae\u8f6f\u96c5\u9ed1, 'Microsoft YaHei';\">\u7ebf\u6027\u5224\u522b\u5206\u6790(LDA)\u7684\u8868\u73b0\u975e\u5e38\u51fa\u8272\uff0c\u4e0d\u4ec5\u5728\u8bad\u7ec3\u96c6\u4e0a\uff0c\u800c\u4e14\u5728\u4ea4\u53c9\u9a8c\u8bc1\u4e2d\uff0c\u5f97\u5206\u663e\u8457\u63d0\u9ad8\u3002<\/span><span style=\"caret-color: red; letter-spacing: 0px; font-size: 15px; font-family: \u5fae\u8f6f\u96c5\u9ed1, 'Microsoft YaHei';\">\u6beb\u65e0\u7591\u95ee\uff0c\u66f4\u590d\u6742\u7684\u6a21\u578bGBM,XGB,CAT,RF\u5728\u5168\u6837\u672c\u4e2d\u8bc4\u4f30\u5f97\u5206\u8f83\u9ad8\u3002<\/span><span style=\"caret-color: red; letter-spacing: 0px; font-size: 15px; font-family: \u5fae\u8f6f\u96c5\u9ed1, 'Microsoft YaHei';\">\u4e0e\u6709\u76d1\u7763\u5b66\u4e60\u6a21\u578b\u76f8\u6bd4\uff0ckNN\u548cGaussianNB\u7684\u65e0\u76d1\u7763\u6a21\u578b\u8868\u73b0\u8f83\u5dee\u3002<\/span><\/p>\n<h3 style=\"font-weight: bold; line-height: 1.6;\"><strong><span style=\"font-size: 15px; font-family: \u5fae\u8f6f\u96c5\u9ed1, 'Microsoft YaHei';\">\u7279\u5f81\u7684\u4f18\u5316<\/span><\/strong><\/h3>\n<pre style=\"font-size: inherit; color: inherit; line-height: inherit;\"><code style=\"margin-right: 2px; margin-left: 2px; line-height: 15px; font-size: 11px; word-spacing: -3px; letter-spacing: 0px; border-radius: 0px; color: #a9b7c6; background: #282b2e; padding: 0.5em; font-family: Consolas, Inconsolata, Courier, monospace; overflow-wrap: normal !important; word-break: normal !important; overflow: auto !important; display: -webkit-box !important;\"><span style=\"font-size: inherit; line-height: inherit; color: #f82375; overflow-wrap: inherit !important; word-break: inherit !important;\"><span style=\"font-size: inherit; line-height: inherit; overflow-wrap: inherit !important; word-break: inherit !important;\">def<\/span>\u00a0<span style=\"font-size: inherit; line-height: inherit; color: #a5da2d; overflow-wrap: inherit !important; word-break: inherit !important;\">feature_importance<\/span><span style=\"font-size: inherit; line-height: inherit; color: #ff9823; overflow-wrap: inherit !important; word-break: inherit !important;\">(ldf,feature=<span style=\"font-size: inherit; line-height: inherit; color: #eedc70; overflow-wrap: inherit !important; word-break: inherit !important;\">'signal'<\/span>,n_est=<span style=\"font-size: inherit; line-height: inherit; color: #ae87fa; overflow-wrap: inherit !important; word-break: inherit !important;\">100<\/span>)<\/span>:<\/span>\n\u00a0\u00a0\u00a0\u00a0<span style=\"font-size: inherit; line-height: inherit; color: #808080; overflow-wrap: inherit !important; word-break: inherit !important;\">#\u00a0Input\u00a0dataframe\u00a0containing\u00a0feature\u00a0&amp;\u00a0target\u00a0variable<\/span>\n\u00a0\u00a0\u00a0\u00a0X\u00a0=\u00a0ldf.copy()\n\u00a0\u00a0\u00a0\u00a0y\u00a0=\u00a0ldf[feature].copy()\n\u00a0\u00a0\u00a0\u00a0<span style=\"font-size: inherit; line-height: inherit; color: #f82375; overflow-wrap: inherit !important; word-break: inherit !important;\">del<\/span>\u00a0X[feature]\n\u00a0\u00a0\u00a0\u00a0<span style=\"font-size: inherit; line-height: inherit; color: #808080; overflow-wrap: inherit !important; word-break: inherit !important;\">#\u00a0CORRELATION<\/span>\n\u00a0\u00a0\u00a0\u00a0imp\u00a0=\u00a0corrMat(ldf,feature,figsize=(<span style=\"font-size: inherit; line-height: inherit; color: #ae87fa; overflow-wrap: inherit !important; word-break: inherit !important;\">15<\/span>,<span style=\"font-size: inherit; line-height: inherit; color: #ae87fa; overflow-wrap: inherit !important; word-break: inherit !important;\">0.5<\/span>),ret_id=<span style=\"font-size: inherit; line-height: inherit; color: #f82375; overflow-wrap: inherit !important; word-break: inherit !important;\">True<\/span>)\n\u00a0\u00a0\u00a0\u00a0<span style=\"font-size: inherit; line-height: inherit; color: #f82375; overflow-wrap: inherit !important; word-break: inherit !important;\">del<\/span>\u00a0imp[feature]\n\u00a0\u00a0\u00a0\u00a0s1\u00a0=\u00a0imp.squeeze(axis=<span style=\"font-size: inherit; line-height: inherit; color: #ae87fa; overflow-wrap: inherit !important; word-break: inherit !important;\">0<\/span>);s1\u00a0=\u00a0abs(s1)\n\u00a0\u00a0\u00a0\u00a0s1.name\u00a0=\u00a0<span style=\"font-size: inherit; line-height: inherit; color: #eedc70; overflow-wrap: inherit !important; word-break: inherit !important;\">'Correlation'<\/span>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\n\u00a0\u00a0\u00a0\u00a0<span style=\"font-size: inherit; line-height: inherit; color: #808080; overflow-wrap: inherit !important; word-break: inherit !important;\">#\u00a0SHAP<\/span>\n\u00a0\u00a0\u00a0\u00a0model\u00a0=\u00a0CatBoostRegressor(silent=<span style=\"font-size: inherit; line-height: inherit; color: #f82375; overflow-wrap: inherit !important; word-break: inherit !important;\">True<\/span>,n_estimators=n_est).fit(X,y)\n\u00a0\u00a0\u00a0\u00a0explainer\u00a0=\u00a0shap.TreeExplainer(model)\n\u00a0\u00a0\u00a0\u00a0shap_values\u00a0=\u00a0explainer.shap_values(X)\n\u00a0\u00a0\u00a0\u00a0shap_sum\u00a0=\u00a0np.abs(shap_values).mean(axis=<span style=\"font-size: inherit; line-height: inherit; color: #ae87fa; overflow-wrap: inherit !important; word-break: inherit !important;\">0<\/span>)\n\u00a0\u00a0\u00a0\u00a0s2\u00a0=\u00a0pd.Series(shap_sum,index=X.columns,name=<span style=\"font-size: inherit; line-height: inherit; color: #eedc70; overflow-wrap: inherit !important; word-break: inherit !important;\">'Cat_SHAP'<\/span>).T\n\u00a0\u00a0\u00a0\u00a0<span style=\"font-size: inherit; line-height: inherit; color: #808080; overflow-wrap: inherit !important; word-break: inherit !important;\">#\u00a0\u00a0RANDOMFOREST<\/span>\n\u00a0\u00a0\u00a0\u00a0model\u00a0=\u00a0RandomForestRegressor(n_est,random_state=<span style=\"font-size: inherit; line-height: inherit; color: #ae87fa; overflow-wrap: inherit !important; word-break: inherit !important;\">0<\/span>,\u00a0n_jobs=<span style=\"font-size: inherit; line-height: inherit; color: #ae87fa; overflow-wrap: inherit !important; word-break: inherit !important;\">-1<\/span>)\n\u00a0\u00a0\u00a0\u00a0fit\u00a0=\u00a0model.fit(X,y)\n\u00a0\u00a0\u00a0\u00a0rf_fi\u00a0=\u00a0pd.DataFrame(model.feature_importances_,index=X.columns,\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0columns=[<span style=\"font-size: inherit; line-height: inherit; color: #eedc70; overflow-wrap: inherit !important; word-break: inherit !important;\">'RandForest'<\/span>]).sort_values(<span style=\"font-size: inherit; line-height: inherit; color: #eedc70; overflow-wrap: inherit !important; word-break: inherit !important;\">'RandForest'<\/span>,ascending=<span style=\"font-size: inherit; line-height: inherit; color: #f82375; overflow-wrap: inherit !important; word-break: inherit !important;\">False<\/span>)\n\u00a0\u00a0\u00a0\u00a0s3\u00a0=\u00a0rf_fi.T.squeeze(axis=<span style=\"font-size: inherit; line-height: inherit; color: #ae87fa; overflow-wrap: inherit !important; word-break: inherit !important;\">0<\/span>)\n\u00a0\u00a0\u00a0\u00a0<span style=\"font-size: inherit; line-height: inherit; color: #808080; overflow-wrap: inherit !important; word-break: inherit !important;\">#\u00a0XGB\u00a0<\/span>\n\u00a0\u00a0\u00a0\u00a0model=XGBRegressor(n_estimators=n_est,learning_rate=<span style=\"font-size: inherit; line-height: inherit; color: #ae87fa; overflow-wrap: inherit !important; word-break: inherit !important;\">0.5<\/span>,verbosity\u00a0=\u00a0<span style=\"font-size: inherit; line-height: inherit; color: #ae87fa; overflow-wrap: inherit !important; word-break: inherit !important;\">0<\/span>)\n\u00a0\u00a0\u00a0\u00a0model.fit(X,y)\n\u00a0\u00a0\u00a0\u00a0data\u00a0=\u00a0model.feature_importances_\n\u00a0\u00a0\u00a0\u00a0s4\u00a0=\u00a0pd.Series(data,index=X.columns,name=<span style=\"font-size: inherit; line-height: inherit; color: #eedc70; overflow-wrap: inherit !important; word-break: inherit !important;\">'XGB'<\/span>).T\n\u00a0\u00a0\u00a0\u00a0<span style=\"font-size: inherit; line-height: inherit; color: #808080; overflow-wrap: inherit !important; word-break: inherit !important;\">#\u00a0KBEST<\/span>\n\u00a0\u00a0\u00a0\u00a0model\u00a0=\u00a0SelectKBest(k=<span style=\"font-size: inherit; line-height: inherit; color: #ae87fa; overflow-wrap: inherit !important; word-break: inherit !important;\">5<\/span>,\u00a0score_func=f_regression)\n\u00a0\u00a0\u00a0\u00a0fit\u00a0=\u00a0model.fit(X,y)\n\u00a0\u00a0\u00a0\u00a0data\u00a0=\u00a0fit.scores_\n\u00a0\u00a0\u00a0\u00a0s5\u00a0=\u00a0pd.Series(data,index=X.columns,name=<span style=\"font-size: inherit; line-height: inherit; color: #eedc70; overflow-wrap: inherit !important; word-break: inherit !important;\">'K_best'<\/span>)\n\u00a0\u00a0\u00a0\u00a0<span style=\"font-size: inherit; line-height: inherit; color: #808080; overflow-wrap: inherit !important; word-break: inherit !important;\">#\u00a0Combine\u00a0Scores<\/span>\n\u00a0\u00a0\u00a0\u00a0df0\u00a0=\u00a0pd.concat([s1,s2,s3,s4,s5],axis=<span style=\"font-size: inherit; line-height: inherit; color: #ae87fa; overflow-wrap: inherit !important; word-break: inherit !important;\">1<\/span>)\n\u00a0\u00a0\u00a0\u00a0df0.rename(columns={<span style=\"font-size: inherit; line-height: inherit; color: #eedc70; overflow-wrap: inherit !important; word-break: inherit !important;\">'target'<\/span>:<span style=\"font-size: inherit; line-height: inherit; color: #eedc70; overflow-wrap: inherit !important; word-break: inherit !important;\">'lin\u00a0corr'<\/span>})\n\u00a0\u00a0\u00a0\u00a0x\u00a0=\u00a0df0.values\u00a0\n\u00a0\u00a0\u00a0\u00a0min_max_scaler\u00a0=\u00a0preprocessing.MinMaxScaler()\n\u00a0\u00a0\u00a0\u00a0x_scaled\u00a0=\u00a0min_max_scaler.fit_transform(x)\n\u00a0\u00a0\u00a0\u00a0df\u00a0=\u00a0pd.DataFrame(x_scaled,index=df0.index,columns=df0.columns)\n\u00a0\u00a0\u00a0\u00a0df\u00a0=\u00a0df.rename_axis(<span style=\"font-size: inherit; line-height: inherit; color: #eedc70; overflow-wrap: inherit !important; word-break: inherit !important;\">'Feature\u00a0Importance\u00a0via'<\/span>,\u00a0axis=<span style=\"font-size: inherit; line-height: inherit; color: #ae87fa; overflow-wrap: inherit !important; word-break: inherit !important;\">1<\/span>)\n\u00a0\u00a0\u00a0\u00a0df\u00a0=\u00a0df.rename_axis(<span style=\"font-size: inherit; line-height: inherit; color: #eedc70; overflow-wrap: inherit !important; word-break: inherit !important;\">'Feature'<\/span>,\u00a0axis=<span style=\"font-size: inherit; line-height: inherit; color: #ae87fa; overflow-wrap: inherit !important; word-break: inherit !important;\">0<\/span>)\n\u00a0\u00a0\u00a0\u00a0pd.options.plotting.backend\u00a0=\u00a0<span style=\"font-size: inherit; line-height: inherit; color: #eedc70; overflow-wrap: inherit !important; word-break: inherit !important;\">\"plotly\"<\/span>\n\u00a0\u00a0\u00a0\u00a0fig\u00a0=\u00a0df.plot(kind=<span style=\"font-size: inherit; line-height: inherit; color: #eedc70; overflow-wrap: inherit !important; word-break: inherit !important;\">'bar'<\/span>,title=<span style=\"font-size: inherit; line-height: inherit; color: #eedc70; overflow-wrap: inherit !important; word-break: inherit !important;\">'Scaled\u00a0Feature\u00a0Importance'<\/span>)\n\u00a0\u00a0\u00a0\u00a0fig.show()\n<\/code><\/pre>\n<pre style=\"font-size: inherit; color: inherit; line-height: inherit;\"><code style=\"margin-right: 2px; margin-left: 2px; line-height: 15px; font-size: 11px; word-spacing: -3px; letter-spacing: 0px; border-radius: 0px; color: #a9b7c6; background: #282b2e; padding: 0.5em; font-family: Consolas, Inconsolata, Courier, monospace; overflow-wrap: normal !important; word-break: normal !important; overflow: auto !important; display: -webkit-box !important;\">feature_importance(df_tr2)\n<\/code><\/pre>\n<section><img decoding=\"async\" class=\"rich_pages wxw-img\" style=\"box-sizing: border-box; width: 'auto';\" title=\"Python+\u673a\u5668\u5b66\u4e60\u5bfb\u627e\u80a1\u7968\u4ea4\u6613\u4fe1\u53f7\" src=\"http:\/\/www.zhushiyao.com\/wp-content\/uploads\/2022\/02\/4-1645424110.png\" alt=\"Python+\u673a\u5668\u5b66\u4e60\u5bfb\u627e\u80a1\u7968\u4ea4\u6613\u4fe1\u53f7\" \/><\/p>\n<p style=\"text-align: justify;\"><span style=\"font-size: 15px; font-family: \u5fae\u8f6f\u96c5\u9ed1, 'Microsoft YaHei';\">\u6ce8\u610f\u5230\uff0c\u5bf9\u4e8e\u5f88\u591a\u7279\u5f81\uff0c\u76f8\u5173\u6027(Pearson\u2019s value)\u5c0f\u7684\u5728\u5176\u4ed6\u65b9\u6cd5\u4e2d\u4e5f\u4f1a\u7ed9\u51fa\u5c0f\u7684\u5f97\u5206\u503c\u3002\u540c\u6837\uff0c\u9ad8\u76f8\u5173\u7684\u7279\u5f81\u5728\u5176\u4ed6\u7279\u5f81\u91cd\u8981\u6027\u65b9\u6cd5\u4e2d\u5f97\u5206\u4e5f\u5f88\u9ad8\u3002\u5f53\u8c08\u5230\u7279\u5f81\u7684\u91cd\u8981\u6027\u65f6\uff0c\u6709\u4e00\u4e9b\u7279\u5f81\u663e\u793a\u51fa\u4e00\u4e9b\u8f7b\u5fae\u7684\u4e0d\u4e00\u81f4\uff0c\u603b\u7684\u6765\u8bf4\uff0c\u5927\u591a\u6570\u65b9\u6cd5\u90fd\u53ef\u4ee5\u89c2\u5bdf\u5230\u7279\u5f81\u8bc4\u5206\u7684\u76f8\u4f3c\u6027\u3002\u5728\u673a\u5668\u5b66\u4e60\u4e2d\uff0c\u67d0\u4e9b\u7279\u5f81\u5bf9\u4e8e\u5927\u591a\u6570\u65b9\u6cd5\u6765\u8bf4\u90fd\u6709\u4e00\u4e2a\u975e\u5e38\u4f4e\u7684\u76f8\u5bf9\u5206\u6570\u503c\uff0c\u56e0\u6b64\u53ef\u80fd\u6ca1\u6709\u4ec0\u4e48\u5f71\u54cd\uff0c\u5373\u4f7f\u628a\u5b83\u4eec\u5220\u9664\uff0c\u4e5f\u4e0d\u4f1a\u964d\u4f4e\u6a21\u578b\u7684\u51c6\u786e\u6027\u3002\u5220\u9664\u53ef\u80fd\u4e0d\u53d7\u5f71\u54cd\u7684\u7279\u6027\u5c06\u4f7f\u6574\u4e2a\u65b9\u6cd5\u66f4\u52a0\u6709\u6548\uff0c\u540c\u65f6\u53ef\u4ee5\u4e13\u6ce8\u4e8e\u66f4\u957f\u548c\u66f4\u6df1\u5165\u7684\u8d85\u53c2\u6570\u7f51\u683c\u641c\u7d22\uff0c\u53ef\u80fd\u5f97\u5230\u6bd4\u539f\u6765\u6a21\u578b\u66f4\u51c6\u786e\u7684\u7ed3\u679c\u3002<\/span><\/p>\n<pre style=\"max-inline-size: 100%; white-space: pre-wrap; color: inherit; font-size: inherit; caret-color: #ff0000; background-color: #ffffff; line-height: inherit; outline: none 0px !important;\"><code style=\"white-space: pre-wrap; max-inline-size: 100%; margin-right: 2px; margin-left: 2px; padding: 0.5em; line-height: 15px; font-size: 11px; word-spacing: -3px; letter-spacing: 0px; border-radius: 0px; color: #a9b7c6; background: #282b2e; font-family: Consolas, Inconsolata, Courier, monospace; outline: none 0px !important; overflow-wrap: normal !important; word-break: normal !important; overflow: auto !important; display: -webkit-box !important;\">df_tr2_FI\u00a0=\u00a0df_tr2.drop(columns=[<span style=\"max-inline-size: 100%; cursor: text; font-size: inherit; line-height: inherit; color: #eedc70; outline: none 0px !important; overflow-wrap: inherit !important; word-break: inherit !important;\">'open'<\/span>,<span style=\"max-inline-size: 100%; cursor: text; font-size: inherit; line-height: inherit; color: #eedc70; outline: none 0px !important; overflow-wrap: inherit !important; word-break: inherit !important;\">'high'<\/span>,<span style=\"max-inline-size: 100%; cursor: text; font-size: inherit; line-height: inherit; color: #eedc70; outline: none 0px !important; overflow-wrap: inherit !important; word-break: inherit !important;\">'low'<\/span>,<span style=\"max-inline-size: 100%; cursor: text; font-size: inherit; line-height: inherit; color: #eedc70; outline: none 0px !important; overflow-wrap: inherit !important; word-break: inherit !important;\">'close'<\/span>,<span style=\"max-inline-size: 100%; cursor: text; font-size: inherit; line-height: inherit; color: #eedc70; outline: none 0px !important; overflow-wrap: inherit !important; word-break: inherit !important;\">'EMA10'<\/span>])<br style=\"max-inline-size: 100%; outline: none 0px !important;\" \/><\/code><\/pre>\n<pre style=\"max-inline-size: 100%; white-space: pre-wrap; color: inherit; font-size: inherit; caret-color: #ff0000; background-color: #ffffff; line-height: inherit; outline: none 0px !important;\"><code style=\"white-space: pre-wrap; max-inline-size: 100%; margin-right: 2px; margin-left: 2px; padding: 0.5em; line-height: 15px; font-size: 11px; word-spacing: -3px; letter-spacing: 0px; border-radius: 0px; color: #a9b7c6; background: #282b2e; font-family: Consolas, Inconsolata, Courier, monospace; outline: none 0px !important; overflow-wrap: normal !important; word-break: normal !important; overflow: auto !important; display: -webkit-box !important;\">modelEval(df_tr2_FI,split_id=[<span style=\"max-inline-size: 100%; cursor: text; font-size: inherit; line-height: inherit; color: #ae87fa; outline: none 0px !important; overflow-wrap: inherit !important; word-break: inherit !important;\">0.2<\/span>,<span style=\"max-inline-size: 100%; cursor: text; font-size: inherit; line-height: inherit; color: #f82375; outline: none 0px !important; overflow-wrap: inherit !important; word-break: inherit !important;\">None<\/span>],cv_yrange=(<span style=\"max-inline-size: 100%; cursor: text; font-size: inherit; line-height: inherit; color: #ae87fa; outline: none 0px !important; overflow-wrap: inherit !important; word-break: inherit !important;\">0.8<\/span>,<span style=\"max-inline-size: 100%; cursor: text; font-size: inherit; line-height: inherit; color: #ae87fa; outline: none 0px !important; overflow-wrap: inherit !important; word-break: inherit !important;\">1.0<\/span>),hm_vvals=[<span style=\"max-inline-size: 100%; cursor: text; font-size: inherit; line-height: inherit; color: #ae87fa; outline: none 0px !important; overflow-wrap: inherit !important; word-break: inherit !important;\">0.8<\/span>,<span style=\"max-inline-size: 100%; cursor: text; font-size: inherit; line-height: inherit; color: #ae87fa; outline: none 0px !important; overflow-wrap: inherit !important; word-break: inherit !important;\">1.0<\/span>,<span style=\"max-inline-size: 100%; cursor: text; font-size: inherit; line-height: inherit; color: #ae87fa; outline: none 0px !important; overflow-wrap: inherit !important; word-break: inherit !important;\">0.9<\/span>])<br style=\"max-inline-size: 100%; outline: none 0px !important;\" \/><\/code><\/pre>\n<p><img decoding=\"async\" class=\"rich_pages wxw-img\" style=\"box-sizing: border-box; width: 'auto';\" title=\"Python+\u673a\u5668\u5b66\u4e60\u5bfb\u627e\u80a1\u7968\u4ea4\u6613\u4fe1\u53f7\" src=\"http:\/\/www.zhushiyao.com\/wp-content\/uploads\/2022\/02\/0-1645424110.png\" alt=\"Python+\u673a\u5668\u5b66\u4e60\u5bfb\u627e\u80a1\u7968\u4ea4\u6613\u4fe1\u53f7\" \/><\/p>\n<p><span style=\"font-size: 15px;\">\u7ed3\u679c\u663e\u793a\uff0c\u5220\u6389\u9884\u6d4b\u80fd\u529b\u8f83\u5f31\u7684\u7279\u5f81\u540e\uff0c\u67d0\u4e9b\u673a\u5668\u5b66\u4e60\u65b9\u6cd5\u7684\u9884\u6d4b\u5f97\u5206\u63d0\u9ad8\u4e86\uff0c\u5982\u7ebf\u6027\u5224\u522b\uff08LDA\uff09\u3001\u51b3\u7b56\u6811\uff08TREE\uff09\u548c\u968f\u673a\u68ee\u6797\uff08RF\uff09\u7b49\u3002<\/span><\/p>\n<section>\n<section style=\"margin: 10px auto;\">\n<section style=\"display: flex; justify-content: center;\">\n<section>\n<section style=\"display: flex;\">\n<section style=\"color: white; background-color: #3b5cf4; padding-right: 6px; padding-left: 6px; line-height: 1.75em; letter-spacing: 1px; font-size: 16px;\">0<span title=\"\">4<\/span><\/section>\n<section style=\"color: #3b5cf4; padding-right: 8px; padding-left: 8px; letter-spacing: 1.5px; line-height: 1.75em; font-size: 16px;\">\u7ed3\u8bed<\/section>\n<\/section>\n<section style=\"display: flex; justify-content: center; align-items: center; margin-top: 3px;\">\n<section style=\"width: 70%; height: 2px; background: #3b5cf4; overflow: hidden;\"><\/section>\n<section style=\"width: 30%; height: 2px; background: #ffc756; overflow: hidden;\"><\/section>\n<\/section>\n<\/section>\n<\/section>\n<\/section>\n<\/section>\n<p><span style=\"font-size: 15px;\">\u672c\u6587\u53ea\u662f\u4ee5\u4e0a\u8bc1\u6307\u6570\u4e3a\u4f8b\uff0c\u4ee5\u6280\u672f\u6307\u6807\u4f5c\u4e3a\u7279\u5f81\uff0c\u4f7f\u7528\u673a\u5668\u5b66\u4e60\u7b97\u6cd5\u5bf9\u80a1\u7968\u4ea4\u6613\u4fe1\u53f7\uff08\u6ce8\u610f\u8fd9\u91cc\u4e0d\u662f\u80a1\u4ef7\u6216\u6536\u76ca\u7387\uff09\u8fdb\u884c\u9884\u6d4b\u8bc4\u4f30\uff0c\u76ee\u7684\u5728\u4e8e\u5411\u8bfb\u8005\u5c55\u793aPython\u673a\u5668\u5b66\u4e60\u5728\u91d1\u878d\u91cf\u5316\u7814\u7a76\u4e0a\u7684\u5e94\u7528\u3002\u4ece\u91d1\u878d\u7ef4\u5ea6\u6765\u770b\uff0c\u5206\u6790\u7684\u6df1\u5ea6\u8f83\u6d45\uff0c\u5b9e\u9645\u4e0a\u5bf9\u80a1\u4ef7\u9884\u6d4b\u6709\u7528\u7684\u7279\u5f81\u6709\u5f88\u591a\uff0c\u5305\u62ec\uff081\uff09\u5916\u5728\u56e0\u7d20\uff0c \u5982\u80a1\u7968\u76f8\u5173\u516c\u53f8\u7684<\/span><span style=\"caret-color: red; font-size: 15px;\">\u7ade\u4e89\u5bf9\u624b\u3001\u5ba2\u6237\u3001\u5168\u7403\u7ecf\u6d4e\u3001\u5730\u7f18\u653f\u6cbb\u5f62\u52bf\u3001\u8d22\u653f\u548c\u8d27\u5e01\u653f\u7b56\u3001\u8d44\u672c\u83b7\u53d6\u7b49\u3002\u56e0\u6b64\uff0c\u516c\u53f8\u80a1\u4ef7\u53ef\u80fd\u4e0d\u4ec5\u4e0e\u5176\u4ed6\u516c\u53f8\u7684\u80a1\u4ef7\u76f8\u5173\uff0c\u8fd8\u4e0e\u5927\u5b97\u5546\u54c1\u3001\u5916\u6c47\u3001\u5e7f\u4e49\u6307\u6570\u3001\u751a\u81f3\u56fa\u5b9a\u6536\u76ca\u8bc1\u5238\u7b49\u5176\u4ed6\u8d44\u4ea7\u76f8\u5173\uff1b\uff082\uff09\u80a1\u4ef7\u5e02\u573a\u56e0\u7d20\uff0c\u5982<\/span><span style=\"caret-color: red; font-size: 15px;\">\u5f88\u591a\u6295\u8d44\u8005\u5173\u6ce8\u6280\u672f\u6307\u6807\u3002\uff083\uff09\u516c\u53f8<\/span><span style=\"caret-color: red; font-size: 15px;\">\u57fa\u672c\u9762\u56e0\u7d20\uff0c\u5982<\/span><span style=\"caret-color: red; font-size: 15px;\">\u516c\u53f8\u7684\u5e74\u5ea6\u548c\u5b63\u5ea6\u62a5\u544a\u53ef\u4ee5\u7528\u6765\u63d0\u53d6\u6216\u786e\u5b9a\u5173\u952e\u6307\u6807\uff0c\u5982\u51c0\u8d44\u4ea7\u6536\u76ca\u7387(ROE)\u548c\u5e02\u76c8\u7387(price -to &#8211; earnings)\u3002\u6b64\u5916\uff0c<\/span><span style=\"caret-color: red; font-size: 15px;\">\u65b0\u95fb\u53ef\u4ee5\u9884\u793a\u5373\u5c06\u53d1\u751f\u7684\u4e8b\u4ef6\uff0c\u8fd9\u4e9b\u4e8b\u4ef6\u53ef\u80fd\u4f1a\u63a8\u52a8\u80a1\u4ef7\u5411\u67d0\u4e2a\u65b9\u5411\u53d1\u5c55\u3002<\/span><span style=\"caret-color: red; font-size: 15px;\">\u5f53\u5173\u6ce8\u80a1\u7968\u4ef7\u683c\u9884\u6d4b\u65f6\uff0c\u6211\u4eec\u53ef\u4ee5\u4f7f\u7528\u7c7b\u4f3c\u7684\u65b9\u6cd5\u6765\u6784\u5efa\u5f71\u54cd\u9884\u6d4b\u53d8\u91cf\u7684\u56e0\u7d20\uff0c\u5e0c\u671b\u672c\u6587\u80fd\u8d77\u5230\u629b\u7816\u5f15\u7389\u7684\u4f5c\u7528\u3002<\/span><\/p>\n<\/section>\n<\/section>\n<p><span style=\"font-size: 15px;\">\u8d44\u6599\u6765\u6e90\uff1a<\/span><\/p>\n<h5 style=\"font-weight: bold; line-height: 1.6;\"><span style=\"font-size: 14px;\">Andrey Shtrauss. &#8216;<em>Building an Asset Trading Strategy<\/em>&#8216;, 2020.<\/span><\/h5>\n<p><span style=\"font-size: 14px;\">https:\/\/www.kaggle.com\/shtrausslearning\/building-an-asset-trading-strategy<\/span><\/p>\n<\/section>\n<section>\n<section style=\"margin-top: 20px; caret-color: #000000; white-space: normal;\"><span style=\"font-size: 15px;\"><span style=\"font-size: 15px; font-family: mp-quote, -apple-system-font, BlinkMacSystemFont, 'Helvetica Neue', 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei UI', 'Microsoft YaHei', Arial, sans-serif;\">\u611f\u8c22<\/span><span style=\"font-size: 15px; font-family: mp-quote, -apple-system-font, BlinkMacSystemFont, 'Helvetica Neue', 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei UI', 'Microsoft YaHei', Arial, sans-serif; color: #ff4c41;\"><strong>\u8f6c\u53d1<\/strong><\/span><span style=\"font-size: 15px; font-family: mp-quote, -apple-system-font, BlinkMacSystemFont, 'Helvetica Neue', 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei UI', 'Microsoft YaHei', Arial, sans-serif;\">\u548c<\/span><span style=\"font-size: 15px; font-family: mp-quote, -apple-system-font, BlinkMacSystemFont, 'Helvetica Neue', 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei UI', 'Microsoft YaHei', Arial, sans-serif; color: #ff4c41;\"><strong>\u70b9\u8d5e<\/strong><\/span><span style=\"font-size: 15px; font-family: mp-quote, -apple-system-font, BlinkMacSystemFont, 'Helvetica Neue', 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei UI', 'Microsoft YaHei', Arial, sans-serif;\">\u7684\u5404\u4f4d~<\/span><\/span><\/section>\n<p style=\"margin-top: 25px;\"><span style=\"font-size: 14px; color: #797baa;\">\u4f5c\u8005\uff1a<span style=\"color: #797baa; font-size: 14px;\">CuteHand<\/span><\/span><\/p>\n<section><span style=\"font-size: 14px; color: #797baa;\">\u6765\u6e90\uff1aPython\u91d1\u878d\u91cf\u5316<\/span><\/section>\n<section><\/section>\n<hr style=\"caret-color: #000000; white-space: normal; border-style: solid; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-color: rgba(0, 0, 0, 0.1); transform-origin: 0px 0px; transform: scale(1, 0.5);\" \/>\n<p style=\"text-align: center;\">\u8f6c\u81ea\uff1ahttps:\/\/mp.weixin.qq.com\/s\/7NP0AAYi4F-v-OQlFQSNtA<\/p>\n<\/section>\n<\/section>\n<\/div>\n","protected":false},"excerpt":{"rendered":"<p>0\u00a01 \u5f15\u8a00 \u8fd1\u5e74\u6765\uff0c\u968f\u7740\u6280\u672f\u7684\u53d1\u5c55\uff0c\u673a\u5668\u5b66\u4e60\u548c\u6df1\u5ea6\u5b66\u4e60\u5728\u91d1\u878d\u8d44\u4ea7\u91cf\u5316\u7814\u7a76\u4e0a\u7684\u5e94\u7528\u8d8a\u6765\u8d8a\u5e7f\u6cdb\u548c\u6df1\u5165\u3002\u76ee\u524d\uff0c\u5927\u91cf &hellip; <a href=\"http:\/\/www.zhushiyao.com\/?p=97236\" class=\"more-link\">\u7ee7\u7eed\u9605\u8bfb<span class=\"screen-reader-text\">\u201cPython+\u673a\u5668\u5b66\u4e60\u5bfb\u627e\u80a1\u7968\u4ea4\u6613\u4fe1\u53f7\u201d<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":[],"categories":[2],"tags":[8],"_links":{"self":[{"href":"http:\/\/www.zhushiyao.com\/index.php?rest_route=\/wp\/v2\/posts\/97236"}],"collection":[{"href":"http:\/\/www.zhushiyao.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/www.zhushiyao.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/www.zhushiyao.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/www.zhushiyao.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=97236"}],"version-history":[{"count":2,"href":"http:\/\/www.zhushiyao.com\/index.php?rest_route=\/wp\/v2\/posts\/97236\/revisions"}],"predecessor-version":[{"id":97248,"href":"http:\/\/www.zhushiyao.com\/index.php?rest_route=\/wp\/v2\/posts\/97236\/revisions\/97248"}],"wp:attachment":[{"href":"http:\/\/www.zhushiyao.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=97236"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.zhushiyao.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=97236"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.zhushiyao.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=97236"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}