{"id":1310,"date":"2023-03-25T10:12:45","date_gmt":"2023-03-25T02:12:45","guid":{"rendered":""},"modified":"2023-03-25T10:12:45","modified_gmt":"2023-03-25T02:12:45","slug":"\u4eba\u5de5\u667a\u80fd\u76d1\u7763\u5b66\u4e60(\u5206\u7c7b)","status":"publish","type":"post","link":"https:\/\/bianchenghao6.com\/1310.html","title":{"rendered":"\u4eba\u5de5\u667a\u80fd\u76d1\u7763\u5b66\u4e60(\u5206\u7c7b)"},"content":{"rendered":"


\n <\/head>
\n <\/p>\n

\n

\u4eba\u5de5\u667a\u80fd\u76d1\u7763\u5b66\u4e60(\u5206\u7c7b)<\/h1>\n

\u4eba\u5de5\u667a\u80fd\u76d1\u7763\u5b66\u4e60(\u5206\u7c7b)\u8be6\u7ec6\u64cd\u4f5c\u6559\u7a0b<\/span>\n <\/div>\n

\n \u5728\u672c\u7ae0\u4e2d\uff0c\u6211\u4eec\u5c06\u91cd\u70b9\u8ba8\u8bba\u76d1\u7763\u5f0f\u5b66\u4e60 -
\n \u5206\u7c7b<\/strong>\u3002\n <\/div>\n
\n \u5206\u7c7b\u6280\u672f\u6216\u6a21\u578b\u8bd5\u56fe\u4ece\u89c2\u6d4b\u503c\u4e2d\u5f97\u51fa\u4e00\u4e9b\u7ed3\u8bba\u3002 \u5728\u5206\u7c7b\u95ee\u9898\u4e2d\uff0c\u6211\u4eec\u6709\u5206\u7c7b\u8f93\u51fa\uff0c\u5982\u201c\u9ed1\u8272\u201d\u6216\u201c\u767d\u8272\u201d\u6216\u201c\u6559\u5b66\u201d\u548c\u201c\u975e\u6559\u5b66\u201d\u3002 \u5728\u6784\u5efa\u5206\u7c7b\u6a21\u578b\u65f6\uff0c\u9700\u8981\u6709\u5305\u542b\u6570\u636e\u70b9\u548c\u76f8\u5e94\u6807\u7b7e\u7684\u8bad\u7ec3\u6570\u636e\u96c6\u3002 \u4f8b\u5982\uff0c\u5982\u679c\u60f3\u68c0\u67e5\u56fe\u50cf\u662f\u5426\u5c5e\u4e8e\u6c7d\u8f66\u3002 \u8981\u5b9e\u73b0\u8fd9\u4e2a\u68c0\u67e5\uff0c\u6211\u4eec\u5c06\u5efa\u7acb\u4e00\u4e2a\u8bad\u7ec3\u6570\u636e\u96c6\uff0c\u5176\u4e2d\u5305\u542b\u4e0e\u201c\u8f66\u201d\u548c\u201c\u65e0\u8f66\u201d\u76f8\u5173\u7684\u4e24\u4e2a\u7c7b\u3002 \u7136\u540e\u9700\u8981\u4f7f\u7528\u8bad\u7ec3\u6837\u672c\u6765\u8bad\u7ec3\u6a21\u578b\u3002 \u5206\u7c7b\u6a21\u578b\u4e3b\u8981\u7528\u4e8e\u4eba\u8138\u8bc6\u522b\uff0c\u5783\u573e\u90ae\u4ef6\u8bc6\u522b\u7b49\u3002\n <\/div>\n

<\/span>\u5728Python\u4e2d\u6784\u5efa\u5206\u7c7b\u5668\u7684\u6b65\u9aa4<\/h2>\n
\n \u4e3a\u4e86\u5728Python\u4e2d\u6784\u5efa\u5206\u7c7b\u5668\uff0c\u5c06\u4f7f\u7528Python 3\u548cScikit-learn\uff0c\u8fd9\u662f\u4e00\u4e2a\u7528\u4e8e\u673a\u5668\u5b66\u4e60\u7684\u5de5\u5177\u3002 \u6309\u7167\u4ee5\u4e0b\u6b65\u9aa4\u5728Python\u4e2d\u6784\u5efa\u5206\u7c7b\u5668 -\n <\/div>\n
\n \u7b2c1\u6b65<\/strong> - \u5bfc\u5165Scikit-learn\u8fd9\u5c06\u662f\u5728Python\u4e2d\u6784\u5efa\u5206\u7c7b\u5668\u7684\u7b2c\u4e00\u6b65\u3002 \u5728\u8fd9\u4e00\u6b65\u4e2d\uff0c\u5c06\u5b89\u88c5\u4e00\u4e2a\u540d\u4e3aScikit-learn\u7684Python\u5305\uff0c\u5b83\u662fPython\u4e2d\u6700\u597d\u7684\u673a\u5668\u5b66\u4e60\u6a21\u5757\u4e4b\u4e00\u3002 \u4ee5\u4e0b\u547d\u4ee4\u5bfc\u5165\u5305 -\n <\/div>\n
\n
 # Filename : example.py<\/span>
# Copyright : 2020 By Lidihuo<\/span>
# Author by : www.lidihuo.com<\/span>
# Date : 2020-08-26<\/span>
import <\/span>sklearn
<\/span><\/code><\/pre>\n<\/p><\/div>\n
\n \u7b2c2\u6b65<\/strong> - \u5bfc\u5165Scikit-learn\u7684\u6570\u636e\u96c6\n <\/div>\n
\n \u5728\u8fd9\u4e00\u6b65\u4e2d\uff0c\u6211\u4eec\u53ef\u4ee5\u5f00\u59cb\u4f7f\u7528\u673a\u5668\u5b66\u4e60\u6a21\u578b\u7684\u6570\u636e\u96c6\u3002 \u5728\u8fd9\u91cc\uff0c\u5c06\u4f7f\u7528
\n \u4e73\u817a\u764c\u5a01\u65af\u5eb7\u661f\u8bca\u65ad\u6570\u636e\u5e93\u3002 \u6570\u636e\u96c6\u5305\u62ec\u6709\u5173\u4e73\u817a\u764c\u80bf\u7624\u7684\u5404\u79cd\u4fe1\u606f\uff0c\u4ee5\u53ca\u6076\u6027\u6216\u826f\u6027\u5206\u7c7b\u6807\u7b7e\u3002 \u8be5\u6570\u636e\u96c6\u5728569\u4e2a\u80bf\u7624\u4e0a\u5177\u6709569\u4e2a\u5b9e\u4f8b\u6216\u6570\u636e\uff0c\u5e76\u4e14\u5305\u62ec\u5173\u4e8e30\u4e2a\u5c5e\u6027\u6216\u7279\u5f81(\u8bf8\u5982\u80bf\u7624\u7684\u534a\u5f84\uff0c\u7eb9\u7406\uff0c\u5149\u6ed1\u5ea6\u548c\u9762\u79ef)\u7684\u4fe1\u606f\u3002 \u501f\u52a9\u4ee5\u4e0b\u547d\u4ee4\uff0c\u5bfc\u5165Scikit-learn\u7684\u4e73\u817a\u764c\u6570\u636e\u96c6 -\n <\/div>\n
\n
 # Filename : example.py<\/span>
# Copyright : 2020 By Lidihuo<\/span>
# Author by : www.lidihuo.com<\/span>
# Date : 2020-08-26<\/span>
from <\/span>sklearn.datasets import <\/span>load_breast_cancer
<\/span><\/code><\/pre>\n<\/p><\/div>\n
\n \u73b0\u5728\uff0c\u4ee5\u4e0b\u547d\u4ee4\u5c06\u52a0\u8f7d\u6570\u636e\u96c6\u3002\n <\/div>\n
\n
 # Filename : example.py<\/span>
# Copyright : 2020 By Lidihuo<\/span>
# Author by : www.lidihuo.com<\/span>
# Date : 2020-08-26<\/span>
data = load_breast_cancer()
<\/span><\/code><\/pre>\n<\/p><\/div>\n
\n \u4ee5\u4e0b\u662f\u5b57\u5178\u952e\u5217\u8868 -\n <\/div>\n

\u5206\u7c7b\u6807\u7b7e\u540d\u79f0(target_names)<\/span>
\n \u5b9e\u9645\u6807\u7b7e(\u76ee\u6807)<\/span>
\n \u5c5e\u6027\/\u529f\u80fd\u540d\u79f0(feature_names)<\/span>
\n \u5c5e\u6027(\u6570\u636e)<\/span> <\/p>\n

\n \u73b0\u5728\uff0c\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\uff0c\u53ef\u4ee5\u4e3a\u6bcf\u4e2a\u91cd\u8981\u4fe1\u606f\u96c6\u521b\u5efa\u65b0\u53d8\u91cf\u5e76\u5206\u914d\u6570\u636e\u3002 \u6362\u53e5\u8bdd\u8bf4\uff0c\u53ef\u4ee5\u7528\u4e0b\u5217\u547d\u4ee4\u7ec4\u7ec7\u6570\u636e -\n <\/div>\n
\n
 # Filename : example.py<\/span>
# Copyright : 2020 By Lidihuo<\/span>
# Author by : www.lidihuo.com<\/span>
# Date : 2020-08-26<\/span>
label_names = data['target_names'<\/span>]
labels = data['target'<\/span>]
feature_names = data['feature_names'<\/span>]
features = data['data'<\/span>]
<\/span><\/code><\/pre>\n<\/p><\/div>\n
\n \u73b0\u5728\uff0c\u4e3a\u4e86\u4f7f\u5b83\u66f4\u6e05\u6670\uff0c\u53ef\u4ee5\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\u6765\u6253\u5370\u7c7b\u6807\u7b7e\uff0c\u7b2c\u4e00\u4e2a\u6570\u636e\u5b9e\u4f8b\u7684\u6807\u7b7e\uff0c\u6211\u4eec\u7684\u529f\u80fd\u540d\u79f0\u548c\u529f\u80fd\u7684\u503c -\n <\/div>\n
\n
 # Filename : example.py<\/span>
# Copyright : 2020 By Lidihuo<\/span>
# Author by : www.lidihuo.com<\/span>
# Date : 2020-08-26<\/span>
print(label_names)
<\/span><\/code><\/pre>\n<\/p><\/div>\n
\n \u4e0a\u8ff0\u547d\u4ee4\u5c06\u5206\u522b\u6253\u5370\u6076\u6027\u548c\u826f\u6027\u7684\u5206\u7c7b\u540d\u79f0\u3002\u8f93\u51fa\u7ed3\u679c\u5982\u4e0b -\n <\/div>\n
\n
 # Filename : example.py<\/span>
# Copyright : 2020 By Lidihuo<\/span>
# Author by : www.lidihuo.com<\/span>
# Date : 2020-08-26<\/span>
['malignant'<\/span> 'benign'<\/span>]
<\/span><\/code><\/pre>\n<\/p><\/div>\n
\n \u73b0\u5728\uff0c\u4e0b\u9762\u7684\u547d\u4ee4\u5c06\u663e\u793a\u5b83\u4eec\u88ab\u6620\u5c04\u5230\u4e8c\u8fdb\u5236\u503c0\u548c1\u3002\u8fd9\u91cc0\u8868\u793a\u6076\u6027\u80bf\u7624\uff0c1\u8868\u793a\u826f\u6027\u764c\u75c7\u3002\u5f97\u5230\u4ee5\u4e0b\u8f93\u51fa -\n <\/div>\n
\n
 # Filename : example.py<\/span>
# Copyright : 2020 By Lidihuo<\/span>
# Author by : www.lidihuo.com<\/span>
# Date : 2020-08-26<\/span>
print(labels[0])
0
<\/span><\/code><\/pre>\n<\/p><\/div>\n
\n \u4e0b\u9762\u7ed9\u51fa\u7684\u4e24\u4e2a\u547d\u4ee4\u5c06\u751f\u6210\u529f\u80fd\u540d\u79f0\u548c\u529f\u80fd\u503c\u3002\n <\/div>\n
\n
 # Filename : example.py<\/span>
# Copyright : 2020 By Lidihuo<\/span>
# Author by : www.lidihuo.com<\/span>
# Date : 2020-08-26<\/span>
print(feature_names[0])
mean radius
print(features[0])
[ 1.79900000e+01 1.03800000e+01 1.22800000e+02 1.00100000e+03
  1.18400000e-01 2.77600000e-01 3.00100000e-01 1.47100000e-01
  2.41900000e-01 7.87100000e-02 1.09500000e+00 9.05300000e-01
  8.58900000e+00 1.53400000e+02 6.39900000e-03 4.90400000e-02
  5.37300000e-02 1.58700000e-02 3.00300000e-02 6.19300000e-03
  2.53800000e+01 1.73300000e+01 1.84600000e+02 2.01900000e+03
  1.62200000e-01 6.65600000e-01 7.11900000e-01 2.65400000e-01
  4.60100000e-01 1.18900000e-01]
<\/span><\/code><\/pre>\n<\/p><\/div>\n
\n \u4ece\u4e0a\u9762\u7684\u8f93\u51fa\u4e2d\uff0c\u53ef\u4ee5\u770b\u5230\u7b2c\u4e00\u4e2a\u6570\u636e\u5b9e\u4f8b\u662f\u4e00\u4e2a\u534a\u5f84\u4e3a1.7990000e + 01\u7684\u6076\u6027\u80bf\u7624\u3002\n <\/div>\n
\n \u7b2c3\u6b65<\/strong> - \u7ec4\u7ec7\u6570\u636e\n <\/div>\n
\n \u5728\u8fd9\u4e00\u6b65\u4e2d\uff0c\u5c06\u628a\u6570\u636e\u5206\u6210\u4e24\u90e8\u5206\uff0c\u5373\u8bad\u7ec3\u96c6\u548c\u6d4b\u8bd5\u96c6\u3002 \u5c06\u6570\u636e\u5206\u5272\u6210\u8fd9\u4e9b\u96c6\u5408\u975e\u5e38\u91cd\u8981\uff0c\u56e0\u4e3a\u5fc5\u987b\u5728\u672a\u770b\u5230\u7684\u6570\u636e\u4e0a\u6d4b\u8bd5\u6a21\u578b\u3002\u8981\u5c06\u6570\u636e\u5206\u6210\u96c6\u5408\uff0csklearn\u6709\u4e00\u4e2a\u53eb\u505atrain_test_split()\u51fd\u6570\u7684\u51fd\u6570\u3002 \u5728\u4ee5\u4e0b\u547d\u4ee4\u7684\u5e2e\u52a9\u4e0b\uff0c\u53ef\u4ee5\u5206\u5272\u8fd9\u4e9b\u96c6\u5408\u4e2d\u7684\u6570\u636e -\n <\/div>\n
\n
 # Filename : example.py<\/span>
# Copyright : 2020 By Lidihuo<\/span>
# Author by : www.lidihuo.com<\/span>
# Date : 2020-08-26<\/span>
from <\/span>sklearn.model_selection import <\/span>train_test_split
<\/span><\/code><\/pre>\n<\/p><\/div>\n
\n \u4e0a\u8ff0\u547d\u4ee4\u5c06\u4ecesklearn\u4e2d\u5bfc\u5165train_test_split\u51fd\u6570\uff0c\u4e0b\u9762\u7684\u547d\u4ee4\u5c06\u6570\u636e\u5206\u89e3\u4e3a\u8bad\u7ec3\u548c\u6d4b\u8bd5\u6570\u636e\u3002 \u5728\u4e0b\u9762\u7ed9\u51fa\u7684\u4f8b\u5b50\u4e2d\uff0c\u4f7f\u752840%\u7684\u6570\u636e\u8fdb\u884c\u6d4b\u8bd5\uff0c\u5176\u4f59\u6570\u636e\u5c06\u7528\u4e8e\u8bad\u7ec3\u6a21\u578b\u3002\n <\/div>\n
\n
 # Filename : example.py<\/span>
# Copyright : 2020 By Lidihuo<\/span>
# Author by : www.lidihuo.com<\/span>
# Date : 2020-08-26<\/span>
train, test, train_labels, test_labels = train_test_split(features,labels,test_size = 0.40, random_state = 42)
<\/span><\/code><\/pre>\n<\/p><\/div>\n
\n \u7b2c4\u6b65<\/strong> - \u5efa\u7acb\u6a21\u578b\u5728\u8fd9\u4e00\u6b65\u4e2d\uff0c\u6211\u4eec\u5c06\u5efa\u7acb\u6a21\u578b\u3002\u4f7f\u7528\u6734\u7d20\u8d1d\u53f6\u65af\u7b97\u6cd5\u6765\u6784\u5efa\u6a21\u578b\u3002 \u4ee5\u4e0b\u547d\u4ee4\u53ef\u7528\u4e8e\u6784\u5efa\u6a21\u578b -\n <\/div>\n
\n
 # Filename : example.py<\/span>
# Copyright : 2020 By Lidihuo<\/span>
# Author by : www.lidihuo.com<\/span>
# Date : 2020-08-26<\/span>
from <\/span>sklearn.naive_bayes import <\/span>GaussianNB
<\/span><\/code><\/pre>\n<\/p><\/div>\n
\n \u4e0a\u8ff0\u547d\u4ee4\u5c06\u5bfc\u5165GaussianNB\u6a21\u5757\u3002 \u73b0\u5728\uff0c\u4ee5\u4e0b\u547d\u4ee4\u7528\u6765\u521d\u59cb\u5316\u6a21\u578b\u3002\n <\/div>\n
\n
 # Filename : example.py<\/span>
# Copyright : 2020 By Lidihuo<\/span>
# Author by : www.lidihuo.com<\/span>
# Date : 2020-08-26<\/span>
gnb = GaussianNB()
<\/span><\/code><\/pre>\n<\/p><\/div>\n
\n \u5c06\u901a\u8fc7\u4f7f\u7528gnb.fit()\u5c06\u5b83\u62df\u5408\u5230\u6570\u636e\u6765\u8bad\u7ec3\u6a21\u578b\u3002\n <\/div>\n
\n
 # Filename : example.py<\/span>
# Copyright : 2020 By Lidihuo<\/span>
# Author by : www.lidihuo.com<\/span>
# Date : 2020-08-26<\/span>
model <\/span>= gnb.fit<\/span>(train, train_labels)
<\/span><\/code><\/pre>\n<\/p><\/div>\n
\n \u7b2c5\u6b65<\/strong> - \u8bc4\u4f30\u6a21\u578b\u53ca\u5176\u51c6\u786e\u6027\u5728\u8fd9\u4e00\u6b65\u4e2d\uff0c\u6211\u4eec\u5c06\u901a\u8fc7\u5bf9\u6d4b\u8bd5\u6570\u636e\u8fdb\u884c\u9884\u6d4b\u6765\u8bc4\u4f30\u6a21\u578b\u3002\u4e3a\u4e86\u505a\u51fa\u9884\u6d4b\uff0c\u6211\u4eec\u5c06\u4f7f\u7528predict()\u51fd\u6570\u3002 \u4ee5\u4e0b\u547d\u4ee4\u505a\u5230\u8fd9\u4e00\u70b9 -\n <\/div>\n
\n
 # Filename : example.py<\/span>
# Copyright : 2020 By Lidihuo<\/span>
# Author by : www.lidihuo.com<\/span>
# Date : 2020-08-26<\/span>
preds = gnb.predict<\/span>(test)
print(preds)
## -- \u7ed3\u679c\u5982\u4e0b
<\/span> [1 0 0 1 1 0 0 0 1 1 1 0 1 0 1 0 1 1 1 0 1 1 0 1 1 1 1 1 1
 0 1 1 1 1 1 1 0 1 0 1 1 0 1 1 1 1 1 1 1 1 0 0 1 1 1 1 1 0
 0 1 1 0 0 1 1 1 0 0 1 1 0 0 1 0 1 1 1 1 1 1 0 1 1 0 0 0 0
 0 1 1 1 1 1 1 1 1 0 0 1 0 0 1 0 0 1 1 1 0 1 1 0 1 1 0 0 0
 1 1 1 0 0 1 1 0 1 0 0 1 1 0 0 0 1 1 1 0 1 1 0 0 1 0 1 1 0
 1 0 0 1 1 1 1 1 1 1 0 0 1 1 1 1 1 1 1 1 1 1 1 1 0 1 1 1 0
 1 1 0 1 1 1 1 1 1 0 0 0 1 1 0 1 0 1 1 1 1 0 1 1 0 1 1 1 0
 1 0 0 1 1 1 1 1 1 1 1 0 1 1 1 1 1 0 1 0 0 1 1 0 1]
<\/span><\/code><\/pre>\n<\/p><\/div>\n
\n \u4e0a\u8ff00\u548c1\u7cfb\u5217\u662f\u80bf\u7624\u7c7b\u522b\u7684\u9884\u6d4b\u503c - \u6076\u6027\u548c\u826f\u6027\u3002\n <\/div>\n
\n \u73b0\u5728\uff0c\u901a\u8fc7\u6bd4\u8f83\u4e24\u4e2a\u6570\u7ec4\u5373test_labels\u548cpreds\uff0c\u53ef\u4ee5\u53d1\u73b0\u6a21\u578b\u7684\u51c6\u786e\u6027\u3002\u4f7f\u7528accuracy_score()\u51fd\u6570\u6765\u786e\u5b9a\u51c6\u786e\u6027\u3002 \u8003\u8651\u4e0b\u9762\u7684\u547d\u4ee4 -\n <\/div>\n
\n
 # Filename : example.py<\/span>
# Copyright : 2020 By Lidihuo<\/span>
# Author by : www.lidihuo.com<\/span>
# Date : 2020-08-26<\/span>
from <\/span>sklearn.metrics import <\/span>accuracy_score
print(accuracy_score(test_labels,preds))
0.951754385965
<\/span><\/code><\/pre>\n<\/p><\/div>\n
\n \u7ed3\u679c\u663e\u793aNa\u00efveBayes\u5206\u7c7b\u5668\u51c6\u786e\u7387\u4e3a95.17%\u3002\n <\/div>\n
\n \u901a\u8fc7\u8fd9\u79cd\u65b9\u5f0f\uff0c\u501f\u52a9\u4e0a\u8ff0\u6b65\u9aa4\uff0c\u6211\u4eec\u53ef\u4ee5\u4f7f\u7528Python\u6784\u5efa\u5206\u7c7b\u5668\u3002\n <\/div>\n

<\/span>\u5728Python\u4e2d\u6784\u5efa\u5206\u7c7b\u5668<\/h2>\n
\n \u5728\u672c\u8282\u4e2d\uff0c\u6211\u4eec\u5c06\u5b66\u4e60\u5982\u4f55\u5728Python\u4e2d\u6784\u5efa\u5206\u7c7b\u5668\u3002\n <\/div>\n
\n \u6734\u7d20\u8d1d\u53f6\u65af\u5206\u7c7b\u5668<\/strong>\n <\/div>\n
\n \u6734\u7d20\u8d1d\u53f6\u65af\u662f\u4e00\u79cd\u4f7f\u7528\u8d1d\u53f6\u65af\u5b9a\u7406\u5efa\u7acb\u5206\u7c7b\u5668\u7684\u5206\u7c7b\u6280\u672f\u3002 \u5047\u8bbe\u662f\u9884\u6d4b\u53d8\u91cf\u662f\u72ec\u7acb\u7684\u3002 \u7b80\u800c\u8a00\u4e4b\uff0c\u5b83\u5047\u8bbe\u7c7b\u4e2d\u67d0\u4e2a\u7279\u5f81\u7684\u5b58\u5728\u4e0e\u4efb\u4f55\u5176\u4ed6\u7279\u5f81\u7684\u5b58\u5728\u65e0\u5173\u3002\u8981\u6784\u5efa\u6734\u7d20\u8d1d\u53f6\u65af\u5206\u7c7b\u5668\uff0c\u6211\u4eec\u9700\u8981\u4f7f\u7528\u540d\u4e3a
\n scikit learn<\/em>\u7684python\u5e93\u3002 \u5728scikit\u5b66\u4e60\u5305\u4e2d\uff0c\u6709\u4e09\u79cd\u7c7b\u578b\u7684\u6734\u7d20\u8d1d\u53f6\u65af\u6a21\u578b\u88ab\u79f0\u4e3aGaussian\uff0cMultinomial\u548cBernoulli\u3002\n <\/div>\n
\n \u8981\u6784\u5efa\u6734\u7d20\u8d1d\u53f6\u65af\u673a\u5668\u5b66\u4e60\u5206\u7c7b\u5668\u6a21\u578b\uff0c\u9700\u8981\u4ee5\u4e0b\u201c\u51cf\u53f7\u201d\n <\/div>\n
\n \u6570\u636e\u96c6<\/strong>\n <\/div>\n
\n \u6211\u4eec\u5c06\u4f7f\u7528\u540d\u4e3a
\n Breast Cancer Wisconsin Diagnostic Database\u6570\u636e\u96c6\u3002 \u6570\u636e\u96c6\u5305\u62ec\u6709\u5173\u4e73\u817a\u764c\u80bf\u7624\u7684\u5404\u79cd\u4fe1\u606f\uff0c\u4ee5\u53ca\u6076\u6027\u6216\u826f\u6027\u5206\u7c7b\u6807\u7b7e\u3002 \u8be5\u6570\u636e\u96c6\u5728569\u4e2a\u80bf\u7624\u4e0a\u5177\u6709569\u4e2a\u5b9e\u4f8b\u6216\u6570\u636e\uff0c\u5e76\u4e14\u5305\u62ec\u5173\u4e8e30\u4e2a\u5c5e\u6027\u6216\u7279\u5f81(\u8bf8\u5982\u80bf\u7624\u7684\u534a\u5f84\uff0c\u7eb9\u7406\uff0c\u5149\u6ed1\u5ea6\u548c\u9762\u79ef)\u7684\u4fe1\u606f\u3002\u53ef\u4ee5\u4ecesklearn\u5305\u4e2d\u5bfc\u5165\u8fd9\u4e2a\u6570\u636e\u96c6\u3002\n <\/div>\n
\n \u6734\u7d20\u8d1d\u53f6\u65af\u6a21\u578b<\/strong>\n <\/div>\n
\n \u4e3a\u4e86\u6784\u5efa\u6734\u7d20\u8d1d\u53f6\u65af\u5206\u7c7b\u5668\uff0c\u9700\u8981\u4e00\u4e2a\u6734\u7d20\u8d1d\u53f6\u65af\u6a21\u578b\u3002 \u5982\u524d\u6240\u8ff0\uff0cscikit\u5b66\u4e60\u5305\u4e2d\u6709\u4e09\u79cd\u7c7b\u578b\u7684Na\u00efveBayes\u6a21\u578b\uff0c\u5206\u522b\u79f0\u4e3aGaussian\uff0cMultinomial\u548cBernoulli\u3002 \u5728\u4e0b\u9762\u7684\u4f8b\u5b50\u4e2d\uff0c\u5c06\u4f7f\u7528\u9ad8\u65af\u6734\u7d20\u8d1d\u53f6\u65af\u6a21\u578b\u3002\n <\/div>\n
\n \u901a\u8fc7\u4f7f\u7528\u4e0a\u8ff0\u5185\u5bb9\uff0c\u6211\u4eec\u5c06\u5efa\u7acb\u4e00\u4e2a\u6734\u7d20\u8d1d\u53f6\u65af\u673a\u5668\u5b66\u4e60\u6a21\u578b\u6765\u4f7f\u7528\u80bf\u7624\u4fe1\u606f\u6765\u9884\u6d4b\u80bf\u7624\u662f\u5426\u662f\u6076\u6027\u7684\u6216\u826f\u6027\u7684\u3002\n <\/div>\n
\n \u9996\u5148\uff0c\u6211\u4eec\u9700\u8981\u5b89\u88c5sklearn\u6a21\u5757\u3002 \u5b83\u53ef\u4ee5\u901a\u8fc7\u4ee5\u4e0b\u547d\u4ee4\u5b8c\u6210 -\n <\/div>\n
\n
 # Filename : example.py<\/span>
# Copyright : 2020 By Lidihuo<\/span>
# Author by : www.lidihuo.com<\/span>
# Date : 2020-08-26<\/span>
import <\/span>sklearn
<\/span><\/code><\/pre>\n<\/p><\/div>\n
\n \u73b0\u5728\uff0c\u9700\u8981\u5bfc\u5165\u540d\u4e3aBreast Cancer Wisconsin Diagnostic Database\u7684\u6570\u636e\u96c6\u3002\n <\/div>\n
\n
 # Filename : example.py<\/span>
# Copyright : 2020 By Lidihuo<\/span>
# Author by : www.lidihuo.com<\/span>
# Date : 2020-08-26<\/span>
from <\/span>sklearn.datasets import <\/span>load_breast_cancer
<\/span><\/code><\/pre>\n<\/p><\/div>\n
\n \u73b0\u5728\uff0c\u4ee5\u4e0b\u547d\u4ee4\u5c06\u52a0\u8f7d\u6570\u636e\u96c6\u3002\n <\/div>\n
\n
 # Filename : example.py<\/span>
# Copyright : 2020 By Lidihuo<\/span>
# Author by : www.lidihuo.com<\/span>
# Date : 2020-08-26<\/span>
data = load_breast_cancer()
<\/span><\/code><\/pre>\n<\/p><\/div>\n
\n \u6570\u636e\u53ef\u4ee5\u6309\u5982\u4e0b\u65b9\u5f0f\u7ec4\u7ec7 -\n <\/div>\n
\n
 # Filename : example.py<\/span>
# Copyright : 2020 By Lidihuo<\/span>
# Author by : www.lidihuo.com<\/span>
# Date : 2020-08-26<\/span>
label_names = data['target_names'<\/span>]
labels = data['target'<\/span>]
feature_names = data['feature_names'<\/span>]
features = data['data'<\/span>]
<\/span><\/code><\/pre>\n<\/p><\/div>\n
\n \u73b0\u5728\uff0c\u4e3a\u4e86\u4f7f\u5b83\u66f4\u6e05\u6670\uff0c\u53ef\u4ee5\u5728\u4ee5\u4e0b\u547d\u4ee4\u7684\u5e2e\u52a9\u4e0b\u6253\u5370\u7c7b\u6807\u7b7e\uff0c\u7b2c\u4e00\u4e2a\u6570\u636e\u5b9e\u4f8b\u7684\u6807\u7b7e\uff0c\u529f\u80fd\u540d\u79f0\u548c\u529f\u80fd\u7684\u503c -\n <\/div>\n
\n
 # Filename : example.py<\/span>
# Copyright : 2020 By Lidihuo<\/span>
# Author by : www.lidihuo.com<\/span>
# Date : 2020-08-26<\/span>
print(label_names)
<\/span><\/code><\/pre>\n<\/p><\/div>\n
\n \u4e0a\u8ff0\u547d\u4ee4\u5c06\u5206\u522b\u6253\u5370\u6076\u6027\u548c\u826f\u6027\u7684\u7c7b\u540d\u3002 \u5b83\u663e\u793a\u4e3a\u4e0b\u9762\u7684\u8f93\u51fa -\n <\/div>\n
\n
 # Filename : example.py<\/span>
# Copyright : 2020 By Lidihuo<\/span>
# Author by : www.lidihuo.com<\/span>
# Date : 2020-08-26<\/span>
['malignant'<\/span> 'benign'<\/span>]
<\/span><\/code><\/pre>\n<\/p><\/div>\n
\n \u73b0\u5728\uff0c\u4e0b\u9762\u7ed9\u51fa\u7684\u547d\u4ee4\u5c06\u663e\u793a\u5b83\u4eec\u6620\u5c04\u5230\u4e8c\u8fdb\u5236\u503c0\u548c1\u3002\u8fd9\u91cc0\u8868\u793a\u6076\u6027\u80bf\u7624\uff0c1\u8868\u793a\u826f\u6027\u764c\u75c7\u3002 \u5b83\u663e\u793a\u4e3a\u4e0b\u9762\u7684\u8f93\u51fa -\n <\/div>\n
\n
 # Filename : example.py<\/span>
# Copyright : 2020 By Lidihuo<\/span>
# Author by : www.lidihuo.com<\/span>
# Date : 2020-08-26<\/span>
print(labels[0])
0
<\/span><\/code><\/pre>\n<\/p><\/div>\n
\n \u4ee5\u4e0b\u4e24\u4e2a\u547d\u4ee4\u5c06\u751f\u6210\u529f\u80fd\u540d\u79f0\u548c\u529f\u80fd\u503c\u3002\n <\/div>\n
\n
 # Filename : example.py<\/span>
# Copyright : 2020 By Lidihuo<\/span>
# Author by : www.lidihuo.com<\/span>
# Date : 2020-08-26<\/span>
print(feature_names[0])
mean radius
print(features[0])
[ 1.79900000e+01 1.03800000e+01 1.22800000e+02 1.00100000e+03
  1.18400000e-01 2.77600000e-01 3.00100000e-01 1.47100000e-01
  2.41900000e-01 7.87100000e-02 1.09500000e+00 9.05300000e-01
  8.58900000e+00 1.53400000e+02 6.39900000e-03 4.90400000e-02
  5.37300000e-02 1.58700000e-02 3.00300000e-02 6.19300000e-03
  2.53800000e+01 1.73300000e+01 1.84600000e+02 2.01900000e+03
  1.62200000e-01 6.65600000e-01 7.11900000e-01 2.65400000e-01
  4.60100000e-01 1.18900000e-01]
<\/span><\/code><\/pre>\n<\/p><\/div>\n
\n \u4ece\u4ee5\u4e0a\u8f93\u51fa\u53ef\u4ee5\u770b\u51fa\uff0c\u7b2c\u4e00\u4e2a\u6570\u636e\u5b9e\u4f8b\u662f\u4e00\u4e2a\u4e3b\u8981\u534a\u5f84\u4e3a1.7990000e + 01\u7684\u6076\u6027\u80bf\u7624\u3002\n <\/div>\n
\n \u8981\u5728\u672a\u770b\u5230\u7684\u6570\u636e\u4e0a\u6d4b\u8bd5\u6a21\u578b\uff0c\u6211\u4eec\u9700\u8981\u5c06\u6570\u636e\u5206\u89e3\u4e3a\u8bad\u7ec3\u548c\u6d4b\u8bd5\u6570\u636e\u3002 \u5b83\u53ef\u4ee5\u5728\u4e0b\u9762\u7684\u4ee3\u7801\u7684\u5e2e\u52a9\u4e0b\u5b8c\u6210 -\n <\/div>\n
\n
 # Filename : example.py<\/span>
# Copyright : 2020 By Lidihuo<\/span>
# Author by : www.lidihuo.com<\/span>
# Date : 2020-08-26<\/span>
from <\/span>sklearn.model_selection import <\/span>train_test_split
<\/span><\/code><\/pre>\n<\/p><\/div>\n
\n \u4e0a\u8ff0\u547d\u4ee4\u5c06\u4ecesklearn\u4e2d\u5bfc\u5165train_test_split\u51fd\u6570\uff0c\u4e0b\u9762\u7684\u547d\u4ee4\u5c06\u6570\u636e\u5206\u89e3\u4e3a\u8bad\u7ec3\u548c\u6d4b\u8bd5\u6570\u636e\u3002 \u5728\u4e0b\u9762\u7684\u4f8b\u5b50\u4e2d\uff0c\u4f7f\u752840%\u7684\u6570\u636e\u8fdb\u884c\u6d4b\u8bd5\uff0c\u5e76\u5c06\u63d0\u793a\u6570\u636e\u7528\u4e8e\u8bad\u7ec3\u6a21\u578b\u3002\n <\/div>\n
\n
 # Filename : example.py<\/span>
# Copyright : 2020 By Lidihuo<\/span>
# Author by : www.lidihuo.com<\/span>
# Date : 2020-08-26<\/span>
train, test, train_labels, test_labels =
train_test_split(features,labels,test_size = 0.40, random_state = 42)
<\/span><\/code><\/pre>\n<\/p><\/div>\n
\n \u73b0\u5728\uff0c\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\u6784\u5efa\u6a21\u578b -\n <\/div>\n
\n
 # Filename : example.py<\/span>
# Copyright : 2020 By Lidihuo<\/span>
# Author by : www.lidihuo.com<\/span>
# Date : 2020-08-26<\/span>
from <\/span>sklearn.naive_bayes import <\/span>GaussianNB
<\/span><\/code><\/pre>\n<\/p><\/div>\n
\n \u4e0a\u8ff0\u547d\u4ee4\u5c06\u4ecesklearn\u4e2d\u5bfc\u5165train_test_split\u51fd\u6570\uff0c\u4e0b\u9762\u7684\u547d\u4ee4\u5c06\u6570\u636e\u5206\u89e3\u4e3a\u8bad\u7ec3\u548c\u6d4b\u8bd5\u6570\u636e\u3002 \u5728\u4e0b\u9762\u7684\u4f8b\u5b50\u4e2d\uff0c\u6211\u4eec\u4f7f\u752840%\u7684\u6570\u636e\u8fdb\u884c\u6d4b\u8bd5\uff0c\u5e76\u5c06\u63d0\u793a\u6570\u636e\u7528\u4e8e\u8bad\u7ec3\u6a21\u578b\u3002\n <\/div>\n
\n
 # Filename : example.py<\/span>
# Copyright : 2020 By Lidihuo<\/span>
# Author by : www.lidihuo.com<\/span>
# Date : 2020-08-26<\/span>
train, test, train_labels, test_labels =
train_test_split(features,labels,test_size = 0.40, random_state = 42)
<\/span><\/code><\/pre>\n<\/p><\/div>\n
\n \u73b0\u5728\uff0c\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\u6784\u5efa\u6a21\u578b -\n <\/div>\n
\n
 # Filename : example.py<\/span>
# Copyright : 2020 By Lidihuo<\/span>
# Author by : www.lidihuo.com<\/span>
# Date : 2020-08-26<\/span>
from <\/span>sklearn.naive_bayes import <\/span>GaussianNB
<\/span><\/code><\/pre>\n<\/p><\/div>\n
\n \u4e0a\u8ff0\u547d\u4ee4\u5c06\u5bfc\u5165GaussianNB\u6a21\u5757\u3002 \u73b0\u5728\uff0c\u4f7f\u7528\u4e0b\u9762\u7ed9\u51fa\u7684\u547d\u4ee4\uff0c\u9700\u8981\u521d\u59cb\u5316\u6a21\u578b\u3002\n <\/div>\n
\n
 # Filename : example.py<\/span>
# Copyright : 2020 By Lidihuo<\/span>
# Author by : www.lidihuo.com<\/span>
# Date : 2020-08-26<\/span>
gnb = GaussianNB()
<\/span><\/code><\/pre>\n<\/p><\/div>\n
\n \u5c06\u901a\u8fc7\u4f7f\u7528gnb.fit()\u5c06\u5b83\u62df\u5408\u5230\u6570\u636e\u6765\u8bad\u7ec3\u6a21\u578b\u3002\n <\/div>\n
\n
 # Filename : example.py<\/span>
# Copyright : 2020 By Lidihuo<\/span>
# Author by : www.lidihuo.com<\/span>
# Date : 2020-08-26<\/span>
model <\/span>= gnb.fit<\/span>(train, train_labels)
<\/span><\/code><\/pre>\n<\/p><\/div>\n
\n \u73b0\u5728\uff0c\u901a\u8fc7\u5bf9\u6d4b\u8bd5\u6570\u636e\u8fdb\u884c\u9884\u6d4b\u6765\u8bc4\u4f30\u6a21\u578b\uff0c\u5e76\u4e14\u53ef\u4ee5\u6309\u5982\u4e0b\u65b9\u5f0f\u5b8c\u6210 -\n <\/div>\n
\n
 # Filename : example.py<\/span>
# Copyright : 2020 By Lidihuo<\/span>
# Author by : www.lidihuo.com<\/span>
# Date : 2020-08-26<\/span>
preds = gnb.predict<\/span>(test)
print(preds)
[1 0 0 1 1 0 0 0 1 1 1 0 1 0 1 0 1 1 1 0 1 1 0 1 1 1 1 1 1
 0 1 1 1 1 1 1 0 1 0 1 1 0 1 1 1 1 1 1 1 1 0 0 1 1 1 1 1 0
 0 1 1 0 0 1 1 1 0 0 1 1 0 0 1 0 1 1 1 1 1 1 0 1 1 0 0 0 0
 0 1 1 1 1 1 1 1 1 0 0 1 0 0 1 0 0 1 1 1 0 1 1 0 1 1 0 0 0
 1 1 1 0 0 1 1 0 1 0 0 1 1 0 0 0 1 1 1 0 1 1 0 0 1 0 1 1 0
 1 0 0 1 1 1 1 1 1 1 0 0 1 1 1 1 1 1 1 1 1 1 1 1 0 1 1 1 0
 1 1 0 1 1 1 1 1 1 0 0 0 1 1 0 1 0 1 1 1 1 0 1 1 0 1 1 1 0
 1 0 0 1 1 1 1 1 1 1 1 0 1 1 1 1 1 0 1 0 0 1 1 0 1]
<\/span><\/code><\/pre>\n<\/p><\/div>\n
\n \u4e0a\u8ff00\u548c1\u7cfb\u5217\u662f\u80bf\u7624\u7c7b\u522b\u7684\u9884\u6d4b\u503c\uff0c\u5373\u6076\u6027\u548c\u826f\u6027\u3002\n <\/div>\n
\n \u73b0\u5728\uff0c\u901a\u8fc7\u6bd4\u8f83\u4e24\u4e2a\u6570\u7ec4\u5373test_labels\u548cpreds\uff0c\u53ef\u4ee5\u770b\u5230\u6a21\u578b\u7684\u51c6\u786e\u6027\u3002 \u6211\u4eec\u5c06\u4f7f\u7528accuracy_score()\u51fd\u6570\u6765\u786e\u5b9a\u51c6\u786e\u6027\u3002 \u8003\u8651\u4e0b\u9762\u7684\u547d\u4ee4 -\n <\/div>\n
\n
 # Filename : example.py<\/span>
# Copyright : 2020 By Lidihuo<\/span>
# Author by : www.lidihuo.com<\/span>
# Date : 2020-08-26<\/span>
from <\/span>sklearn.metrics import <\/span>accuracy_score
print(accuracy_score(test_labels,preds))
0.951754385965
<\/span><\/code><\/pre>\n<\/p><\/div>\n
\n \u7ed3\u679c\u663e\u793aNa\u00efveBayes\u5206\u7c7b\u5668\u51c6\u786e\u7387\u4e3a95.17%\u3002\n <\/div>\n
\n \u8fd9\u662f\u57fa\u4e8eNa\u00efveBayse\u9ad8\u65af\u6a21\u578b\u7684\u673a\u5668\u5b66\u4e60\u5206\u7c7b\u5668\u3002\n <\/div>\n
\n \u652f\u6301\u5411\u91cf\u673a(SVM)<\/strong>
\n
\u57fa\u672c\u4e0a\uff0c\u652f\u6301\u5411\u91cf\u673a(SVM)\u662f\u4e00\u79cd\u6709\u76d1\u7763\u7684\u673a\u5668\u5b66\u4e60\u7b97\u6cd5\uff0c\u53ef\u7528\u4e8e\u56de\u5f52\u548c\u5206\u7c7b\u3002 SVM\u7684\u4e3b\u8981\u6982\u5ff5\u662f\u5c06\u6bcf\u4e2a\u6570\u636e\u9879\u7ed8\u5236\u4e3an\u7ef4\u7a7a\u95f4\u4e2d\u7684\u4e00\u4e2a\u70b9\uff0c\u6bcf\u4e2a\u7279\u5f81\u7684\u503c\u662f\u7279\u5b9a\u5750\u6807\u7684\u503c\u3002\u4ee5\u4e0b\u662f\u4e86\u89e3SVM\u6982\u5ff5\u7684\u7b80\u5355\u56fe\u5f62\u8868\u793a -\n <\/div>\n
\n \u4eba\u5de5\u667a\u80fd\u76d1\u7763\u5b66\u4e60(\u5206\u7c7b)_https:\/\/bianchenghao6.com_\u3010\u4eba\u5de5\u667a\u80fd\u6559\u7a0b\u3011_\u7b2c1\u5f20\n <\/div>\n
\n \u5728\u4e0a\u56fe\u4e2d\uff0c\u6709\u4e24\u4e2a\u7279\u5f81\u3002 \u56e0\u6b64\uff0c\u9996\u5148\u9700\u8981\u5728\u4e8c\u7ef4\u7a7a\u95f4\u4e2d\u7ed8\u5236\u8fd9\u4e24\u4e2a\u53d8\u91cf\uff0c\u5176\u4e2d\u6bcf\u4e2a\u70b9\u90fd\u6709\u4e24\u4e2a\u5750\u6807\uff0c\u79f0\u4e3a\u652f\u6301\u5411\u91cf\u3002 \u8be5\u884c\u5c06\u6570\u636e\u5206\u6210\u4e24\u4e2a\u4e0d\u540c\u7684\u5206\u7c7b\u7ec4\u3002 \u8fd9\u6761\u7ebf\u5c06\u662f\u5206\u7c7b\u5668\u3002\n <\/div>\n
\n \u5728\u8fd9\u91cc\uff0c\u5c06\u4f7f\u7528scikit-learn\u548ciris\u6570\u636e\u96c6\u6765\u6784\u5efaSVM\u5206\u7c7b\u5668\u3002 Scikitlearn\u5e93\u5177\u6709sklearn.svm\u6a21\u5757\u5e76\u63d0\u4f9bsklearn.svm.svc\u8fdb\u884c\u5206\u7c7b\u3002 \u4e0b\u9762\u663e\u793a\u4e86\u57fa\u4e8e4\u4e2a\u7279\u5f81\u6765\u9884\u6d4b\u8679\u819c\u690d\u7269\u79cd\u7c7b\u7684SVM\u5206\u7c7b\u5668\u3002\n <\/div>\n
\n \u6570\u636e\u96c6<\/strong>\n <\/div>\n
\n \u6211\u4eec\u5c06\u4f7f\u7528\u5305\u542b3\u4e2a\u7c7b\u522b(\u6bcf\u4e2a\u7c7b\u522b\u4e3a50\u4e2a\u5b9e\u4f8b)\u7684\u8679\u819c\u6570\u636e\u96c6\uff0c\u5176\u4e2d\u6bcf\u4e2a\u7c7b\u522b\u6307\u7684\u662f\u4e00\u7c7b\u8679\u819c\u5de5\u5382\u3002 \u6bcf\u4e2a\u5b9e\u4f8b\u5177\u6709\u56db\u4e2a\u7279\u5f81\uff0c\u5373\u843c\u7247\u957f\u5ea6\uff0c\u843c\u7247\u5bbd\u5ea6\uff0c\u82b1\u74e3\u957f\u5ea6\u548c\u82b1\u74e3\u5bbd\u5ea6\u3002 \u4e0b\u9762\u663e\u793a\u4e86\u57fa\u4e8e4\u4e2a\u7279\u5f81\u6765\u9884\u6d4b\u8679\u819c\u690d\u7269\u5206\u7c7b\u7684SVM\u5206\u7c7b\u5668\u3002\n <\/div>\n
\n \u5185\u6838<\/strong>\u8fd9\u662fSVM\u4f7f\u7528\u7684\u6280\u672f\u3002 \u57fa\u672c\u4e0a\u8fd9\u4e9b\u529f\u80fd\u91c7\u7528\u4f4e\u7ef4\u8f93\u5165\u7a7a\u95f4\u5e76\u5c06\u5176\u8f6c\u6362\u5230\u66f4\u9ad8\u7ef4\u7a7a\u95f4\u3002 \u5b83\u5c06\u4e0d\u53ef\u5206\u79bb\u7684\u95ee\u9898\u8f6c\u6362\u6210\u53ef\u5206\u79bb\u7684\u95ee\u9898\u3002 \u6838\u51fd\u6570\u53ef\u4ee5\u662f\u7ebf\u6027\uff0c\u591a\u9879\u5f0f\uff0crbf\u548csigmoid\u4e2d\u7684\u4efb\u4f55\u4e00\u79cd\u3002 \u5728\u8fd9\u4e2a\u4f8b\u5b50\u4e2d\uff0c\u5c06\u4f7f\u7528\u7ebf\u6027\u5185\u6838\u3002\n <\/div>\n
\n \u73b0\u5728\u5bfc\u5165\u4e0b\u5217\u8f6f\u4ef6\u5305 -\n <\/div>\n
\n
 # Filename : example.py<\/span>
# Copyright : 2020 By Lidihuo<\/span>
# Author by : www.lidihuo.com<\/span>
# Date : 2020-08-26<\/span>
import <\/span>pandas <\/span>as <\/span>pd
import <\/span>numpy as <\/span>np
from <\/span>sklearn import <\/span>svm, datasets
import <\/span>matplotlib.pyplot as <\/span>plt
<\/span><\/code><\/pre>\n<\/p><\/div>\n
\n \u73b0\u5728\uff0c\u52a0\u8f7d\u8f93\u5165\u6570\u636e -\n <\/div>\n
\n
 # Filename : example.py<\/span>
# Copyright : 2020 By Lidihuo<\/span>
# Author by : www.lidihuo.com<\/span>
# Date : 2020-08-26<\/span>
iris <\/span>= datasets.load_iris<\/span>()
<\/span><\/code><\/pre>\n<\/p><\/div>\n
\n \u6211\u4eec\u4f7f\u7528\u524d\u4e24\u4e2a\u529f\u80fd -\n <\/div>\n
\n
 # Filename : example.py<\/span>
# Copyright : 2020 By Lidihuo<\/span>
# Author by : www.lidihuo.com<\/span>
# Date : 2020-08-26<\/span>
X = iris.data[:, :2]
y = iris.target
<\/span><\/code><\/pre>\n<\/p><\/div>\n
\n \u6211\u4eec\u5c06\u7528\u539f\u59cb\u6570\u636e\u7ed8\u5236\u652f\u6301\u5411\u91cf\u673a\u8fb9\u754c\uff0c\u521b\u5efa\u4e00\u4e2a\u7f51\u683c\u6765\u7ed8\u5236\u3002\n <\/div>\n
\n
 # Filename : example.py<\/span>
# Copyright : 2020 By Lidihuo<\/span>
# Author by : www.lidihuo.com<\/span>
# Date : 2020-08-26<\/span>
x_min, x_max = X[:, 0].min<\/span>() - 1, X[:, 0].max<\/span>() + 1
y_min, y_max = X[:, 1].min<\/span>() - 1, X[:, 1].max<\/span>() + 1
h = (x_max \/ x_min)\/100
xx, yy = np.meshgrid<\/span>(np.arange<\/span>(x_min, x_max, h),
np.arange<\/span>(y_min, y_max, h))
X_plot = np.c_[xx.ravel<\/span>(), yy.ravel<\/span>()]
<\/span><\/code><\/pre>\n<\/p><\/div>\n
\n \u9700\u8981\u7ed9\u51fa\u6b63\u5219\u5316\u53c2\u6570\u7684\u503c\u3002\n <\/div>\n
\n
 # Filename : example.py<\/span>
# Copyright : 2020 By Lidihuo<\/span>
# Author by : www.lidihuo.com<\/span>
# Date : 2020-08-26<\/span>
C = 1.0
<\/span><\/code><\/pre>\n<\/p><\/div>\n
\n \u9700\u8981\u521b\u5efaSVM\u5206\u7c7b\u5668\u5bf9\u8c61\u3002\u53c2\u8003\u4ee5\u4e0b\u4ee3\u7801 -\n <\/div>\n
\n
 # Filename : example.py<\/span>
# Copyright : 2020 By Lidihuo<\/span>
# Author by : www.lidihuo.com<\/span>
# Date : 2020-08-26<\/span>
Svc_classifier = svm_classifier.SVC<\/span>(kernel='linear'<\/span>,
C=C, decision_function_shape = 'ovr'<\/span>).fit<\/span>(X, y)
Z = svc_classifier.predict<\/span>(X_plot)
Z = Z.reshape<\/span>(xx.shape)
plt.figure<\/span>(figsize = (15, 5))
plt.subplot<\/span>(121)
plt.contourf<\/span>(xx, yy, Z, cmap = plt.cm.tab10, alpha = 0.3)
plt.scatter<\/span>(X[:, 0], X[:, 1], c = y, cmap = plt.cm.Set1)
plt.xlabel<\/span>('Sepal length'<\/span>)
plt.ylabel<\/span>('Sepal width'<\/span>)
plt.xlim<\/span>(xx.min<\/span>(), xx.max<\/span>())
plt.title<\/span>('SVC with <\/span>linear kernel'<\/span>)
<\/span><\/code><\/pre>\n<\/p><\/div>\n
\n \u6267\u884c\u540e\u5f97\u5230\u4ee5\u4e0b\u7ed3\u679c -\n <\/div>\n
\n \u4eba\u5de5\u667a\u80fd\u76d1\u7763\u5b66\u4e60(\u5206\u7c7b)_https:\/\/bianchenghao6.com_\u3010\u4eba\u5de5\u667a\u80fd\u6559\u7a0b\u3011_\u7b2c2\u5f20\n <\/div>\n

\u903b\u8f91\u56de\u5f52<\/h2>\n
\n \u57fa\u672c\u4e0a\uff0c\u903b\u8f91\u56de\u5f52\u6a21\u578b\u662f\u76d1\u7763\u5206\u7c7b\u7b97\u6cd5\u65cf\u7684\u6210\u5458\u4e4b\u4e00\u3002 Logistic\u56de\u5f52\u901a\u8fc7\u4f7f\u7528\u903b\u8f91\u51fd\u6570\u4f30\u8ba1\u6982\u7387\u6765\u6d4b\u91cf\u56e0\u53d8\u91cf\u548c\u81ea\u53d8\u91cf\u4e4b\u95f4\u7684\u5173\u7cfb\u3002\n <\/div>\n
\n \u5728\u8fd9\u91cc\uff0c\u5982\u679c\u6211\u4eec\u8ba8\u8bba\u4f9d\u8d56\u53d8\u91cf\u548c\u72ec\u7acb\u53d8\u91cf\uff0c\u90a3\u4e48\u56e0\u53d8\u91cf\u5c31\u662f\u8981\u9884\u6d4b\u7684\u76ee\u6807\u7c7b\u53d8\u91cf\uff0c\u53e6\u4e00\u65b9\u9762\uff0c\u81ea\u53d8\u91cf\u662f\u7528\u6765\u9884\u6d4b\u76ee\u6807\u7c7b\u7684\u7279\u5f81\u3002\n <\/div>\n
\n \u5728\u903b\u8f91\u56de\u5f52\u4e2d\uff0c\u4f30\u8ba1\u6982\u7387\u610f\u5473\u7740\u9884\u6d4b\u4e8b\u4ef6\u7684\u53ef\u80fd\u6027\u53d1\u751f\u3002\u4f8b\u5982\uff0c\u5e97\u4e3b\u60f3\u8981\u9884\u6d4b\u8fdb\u5165\u5546\u5e97\u7684\u987e\u5ba2\u5c06\u8d2d\u4e70\u6e38\u620f\u7ad9(\u4f8b\u5982)\u6216\u4e0d\u8d2d\u4e70\u3002\u987e\u5ba2\u5c06\u4f1a\u89c2\u5bdf\u5230\u8bb8\u591a\u987e\u5ba2\u7684\u7279\u5f81 - \u6027\u522b\uff0c\u5e74\u9f84\u7b49\uff0c\u4ee5\u4fbf\u9884\u6d4b\u53ef\u80fd\u6027\u7684\u53d1\u751f\uff0c\u5373\u8d2d\u4e70\u6e38\u620f\u7ad9\u6216\u4e0d\u8d2d\u7269\u3002\u903b\u8f91\u51fd\u6570\u662f\u7528\u6765\u6784\u5efa\u5177\u6709\u5404\u79cd\u53c2\u6570\u7684\u51fd\u6570\u7684S\u5f62\u66f2\u7ebf\u3002\n <\/div>\n
\n \u524d\u63d0\u6761\u4ef6<\/strong>\n <\/div>\n
\n \u5728\u4f7f\u7528\u903b\u8f91\u56de\u5f52\u6784\u5efa\u5206\u7c7b\u5668\u4e4b\u524d\uff0c\u6211\u4eec\u9700\u8981\u5728\u7cfb\u7edf\u4e0a\u5b89\u88c5Tkinter\u8f6f\u4ef6\u5305\u3002 \u5b83\u53ef\u4ee5\u4ece
\n https:\/\/docs.python.org\/2\/library\/tkinter.html \u8fdb\u884c\u5b89\u88c5\u3002\n <\/div>\n
\n \u73b0\u5728\uff0c\u5728\u4e0b\u9762\u7ed9\u51fa\u7684\u4ee3\u7801\u7684\u5e2e\u52a9\u4e0b\uff0c\u53ef\u4ee5\u4f7f\u7528\u903b\u8f91\u56de\u5f52\u6765\u521b\u5efa\u5206\u7c7b\u5668 -\n <\/div>\n
\n \u9996\u5148\uff0c\u5bfc\u5165\u4e00\u4e9b\u8f6f\u4ef6\u5305 -\n <\/div>\n
\n
 # Filename : example.py<\/span>
# Copyright : 2020 By Lidihuo<\/span>
# Author by : www.lidihuo.com<\/span>
# Date : 2020-08-26<\/span>
import <\/span>numpy as <\/span>np
from <\/span>sklearn import <\/span>linear_model
import <\/span>matplotlib.pyplot as <\/span>plt
<\/span><\/code><\/pre>\n<\/p><\/div>\n
\n \u73b0\u5728\uff0c\u9700\u8981\u5b9a\u4e49\u53ef\u4ee5\u5b8c\u6210\u7684\u6837\u672c\u6570\u636e\uff0c\u5982\u4e0b\u6240\u793a -\n <\/div>\n
\n
 # Filename : example.py<\/span>
# Copyright : 2020 By Lidihuo<\/span>
# Author by : www.lidihuo.com<\/span>
# Date : 2020-08-26<\/span>
X = np.array<\/span>([[2, 4.8], [2.9, 4.7], [2.5, 5], [3.2, 5.5], [6, 5], [7.6, 4],
              [3.2, 0.9], [2.9, 1.9],[2.4, 3.5], [0.5, 3.4], [1, 4], [0.9, 5.9]])
y = np.array<\/span>([0, 0, 0, 1, 1, 1, 2, 2, 2, 3, 3, 3])
<\/span><\/code><\/pre>\n<\/p><\/div>\n
\n \u63a5\u4e0b\u6765\uff0c\u6211\u4eec\u9700\u8981\u521b\u5efa\u903b\u8f91\u56de\u5f52\u5206\u7c7b\u5668\uff0c\u53ef\u4ee5\u6309\u5982\u4e0b\u65b9\u5f0f\u5b8c\u6210 -\n <\/div>\n
\n
 # Filename : example.py<\/span>
# Copyright : 2020 By Lidihuo<\/span>
# Author by : www.lidihuo.com<\/span>
# Date : 2020-08-26<\/span>
Classifier_LR = linear_model.LogisticRegression<\/span>(solver = 'liblinear'<\/span>, C = 75)
<\/span><\/code><\/pre>\n<\/p><\/div>\n
\n \u6700\u540e\u4f46\u91cd\u8981\u7684\u662f\uff0c\u6211\u4eec\u9700\u8981\u8bad\u7ec3\u8fd9\u4e2a\u5206\u7c7b\u5668 -\n <\/div>\n
\n
 # Filename : example.py<\/span>
# Copyright : 2020 By Lidihuo<\/span>
# Author by : www.lidihuo.com<\/span>
# Date : 2020-08-26<\/span>
Classifier_LR.fit<\/span>(X, y)
<\/span><\/code><\/pre>\n<\/p><\/div>\n
\n \u73b0\u5728\uff0c\u6211\u4eec\u5982\u4f55\u53ef\u89c6\u5316\u8f93\u51fa\uff1f \u53ef\u4ee5\u901a\u8fc7\u521b\u5efa\u4e00\u4e2a\u540d\u4e3aLogistic_visualize()\u7684\u51fd\u6570\u6765\u5b8c\u6210 -\n <\/div>\n
\n
 # Filename : example.py<\/span>
# Copyright : 2020 By Lidihuo<\/span>
# Author by : www.lidihuo.com<\/span>
# Date : 2020-08-26<\/span>
def <\/span>Logistic_visualize(Classifier_LR, X, y):
   min_x, max_x = X[:, 0].min<\/span>() - 1.0, X[:, 0].max<\/span>() + 1.0
   min_y, max_y = X[:, 1].min<\/span>() - 1.0, X[:, 1].max<\/span>() + 1.0
<\/span><\/code><\/pre>\n<\/p><\/div>\n
\n \u5728\u4e0a\u9762\u7684\u884c\u4e2d\uff0c\u6211\u4eec\u5b9a\u4e49\u4e86\u5728\u7f51\u683c\u4e2d\u4f7f\u7528\u7684\u6700\u5c0f\u503c\u548c\u6700\u5927\u503cX\u548cY\u3002\u53e6\u5916\uff0c\u8fd8\u5c06\u5b9a\u4e49\u7ed8\u5236\u7f51\u683c\u7684\u6b65\u957f\u3002\n <\/div>\n
\n
 # Filename : example.py<\/span>
# Copyright : 2020 By Lidihuo<\/span>
# Author by : www.lidihuo.com<\/span>
# Date : 2020-08-26<\/span>
mesh_step_size = 0.02
<\/span><\/code><\/pre>\n<\/p><\/div>\n
\n \u4e0b\u9762\u5b9a\u4e49X\u548cY\u503c\u7684\u7f51\u683c\uff0c\u5982\u4e0b\u6240\u793a -\n <\/div>\n
\n
 # Filename : example.py<\/span>
# Copyright : 2020 By Lidihuo<\/span>
# Author by : www.lidihuo.com<\/span>
# Date : 2020-08-26<\/span>
x_vals, y_vals = np.meshgrid<\/span>(np.arange<\/span>(min_x, max_x, mesh_step_size),
                 np.arange<\/span>(min_y, max_y, mesh_step_size))
<\/span><\/code><\/pre>\n<\/p><\/div>\n
\n \u4f7f\u7528\u4ee5\u4e0b\u4ee3\u7801\uff0c\u53ef\u4ee5\u5728\u7f51\u683c\u7f51\u683c\u4e0a\u8fd0\u884c\u5206\u7c7b\u5668 -\n <\/div>\n
\n
 # Filename : example.py<\/span>
# Copyright : 2020 By Lidihuo<\/span>
# Author by : www.lidihuo.com<\/span>
# Date : 2020-08-26<\/span>
output = classifier.predict<\/span>(np.c_[x_vals.ravel<\/span>(), y_vals.ravel<\/span>()])
output = output.reshape<\/span>(x_vals.shape)
plt.figure<\/span>()
plt.pcolormesh<\/span>(x_vals, y_vals, output, cmap = plt.cm.gray)
plt.scatter<\/span>(X[:, 0], X[:, 1], c = y, s = 75, edgecolors = 'black'<\/span>,
linewidth=1, cmap = plt.cm.Paired)
<\/span><\/code><\/pre>\n<\/p><\/div>\n
\n \u4ee5\u4e0b\u4ee3\u7801\u884c\u5c06\u6307\u5b9a\u56fe\u7684\u8fb9\u754c -\n <\/div>\n
\n
 # Filename : example.py<\/span>
# Copyright : 2020 By Lidihuo<\/span>
# Author by : www.lidihuo.com<\/span>
# Date : 2020-08-26<\/span>
plt.xlim<\/span>(x_vals.min<\/span>(), x_vals.max<\/span>())
plt.ylim<\/span>(y_vals.min<\/span>(), y_vals.max<\/span>())
plt.xticks<\/span>((np.arange<\/span>(int(X[:, 0].min<\/span>() - 1), int(X[:, 0].max<\/span>() + 1), 1.0)))
plt.yticks<\/span>((np.arange<\/span>(int(X[:, 1].min<\/span>() - 1), int(X[:, 1].max<\/span>() + 1), 1.0)))
plt.show<\/span>()
<\/span><\/code><\/pre>\n<\/p><\/div>\n
\n \u73b0\u5728\uff0c\u5728\u8fd0\u884c\u4ee3\u7801\u4e4b\u540e\uff0c\u6211\u4eec\u5c06\u5f97\u5230\u4ee5\u4e0b\u8f93\u51fa\uff0c\u903b\u8f91\u56de\u5f52\u5206\u7c7b\u5668 -
\n \u4eba\u5de5\u667a\u80fd\u76d1\u7763\u5b66\u4e60(\u5206\u7c7b)_https:\/\/bianchenghao6.com_\u3010\u4eba\u5de5\u667a\u80fd\u6559\u7a0b\u3011_\u7b2c3\u5f20\n <\/div>\n

\u51b3\u7b56\u6811\u5206\u7c7b\u5668<\/h2>\n
\n \u51b3\u7b56\u6811\u57fa\u672c\u4e0a\u662f\u4e00\u4e2a\u4e8c\u53c9\u6811\u6d41\u7a0b\u56fe\uff0c\u5176\u4e2d\u6bcf\u4e2a\u8282\u70b9\u6839\u636e\u67d0\u4e2a\u7279\u5f81\u53d8\u91cf\u5206\u5272\u4e00\u7ec4\u89c2\u5bdf\u503c\u3002\n <\/div>\n
\n \u5728\u8fd9\u91cc\uff0c\u6211\u4eec\u6b63\u5728\u6784\u5efa\u4e00\u4e2a\u7528\u4e8e\u9884\u6d4b\u7537\u6027\u6216\u5973\u6027\u7684\u51b3\u7b56\u6811\u5206\u7c7b\u5668\u3002\u8fd9\u91cc\u5c06\u91c7\u53d6\u4e00\u4e2a\u975e\u5e38\u5c0f\u7684\u6570\u636e\u96c6\uff0c\u670919\u4e2a\u6837\u672c\u3002 \u8fd9\u4e9b\u6837\u672c\u5c06\u5305\u542b\u4e24\u4e2a\u7279\u5f81 - \u201c\u8eab\u9ad8\u201d\u548c\u201c\u5934\u53d1\u957f\u5ea6\u201d\u3002\n <\/div>\n
\n \u524d\u63d0\u6761\u4ef6<\/strong>\n <\/div>\n
\n \u4e3a\u4e86\u6784\u5efa\u4ee5\u4e0b\u5206\u7c7b\u5668\uff0c\u6211\u4eec\u9700\u8981\u5b89\u88c5pydotplus\u548cgraphviz\u3002 \u57fa\u672c\u4e0a\uff0cgraphviz\u662f\u4f7f\u7528\u70b9\u6587\u4ef6\u7ed8\u5236\u56fe\u5f62\u7684\u5de5\u5177\uff0cpydotplus\u662fGraphviz\u7684Dot\u8bed\u8a00\u6a21\u5757\u3002 \u5b83\u53ef\u4ee5\u4e0e\u5305\u7ba1\u7406\u5668\u6216\u4f7f\u7528pip\u6765\u5b89\u88c5\u3002\n <\/div>\n
\n \u73b0\u5728\uff0c\u53ef\u4ee5\u5728\u4ee5\u4e0bPython\u4ee3\u7801\u7684\u5e2e\u52a9\u4e0b\u6784\u5efa\u51b3\u7b56\u6811\u5206\u7c7b\u5668 -\n <\/div>\n
\n \u9996\u5148\uff0c\u5bfc\u5165\u4e00\u4e9b\u91cd\u8981\u7684\u5e93\u5982\u4e0b -\n <\/div>\n
\n
 # Filename : example.py<\/span>
# Copyright : 2020 By Lidihuo<\/span>
# Author by : www.lidihuo.com<\/span>
# Date : 2020-08-26<\/span>
import <\/span>pydotplus
from <\/span>sklearn import <\/span>tree
from <\/span>sklearn.datasets import <\/span>load_iris
from <\/span>sklearn.metrics import <\/span>classification_report
from <\/span>sklearn import <\/span>cross_validation
import <\/span>collections
<\/span><\/code><\/pre>\n<\/p><\/div>\n
\n \u73b0\u5728\uff0c\u63d0\u4f9b\u5982\u4e0b\u6570\u636e\u96c6 -\n <\/div>\n
\n
 # Filename : example.py<\/span>
# Copyright : 2020 By Lidihuo<\/span>
# Author by : www.lidihuo.com<\/span>
# Date : 2020-08-26<\/span>
X = [[165,19],[175,32],[136,35],[174,65],[141,28],[176,15],[131,32],
[166,6],[128,32],[179,10],[136,34],[186,2],[126,25],[176,28],[112,38],
[169,9],[171,36],[116,25],[196,25]]
Y = ['Man'<\/span><\/span><\/span><\/span><\/span><\/span><\/span><\/span>,'Woman'<\/span><\/span><\/span><\/span><\/span><\/span><\/span><\/span><\/span><\/span><\/span>,'Woman','Man','Woman','Man','Woman','Man','Woman',
'Man','Woman','Man','Woman','Woman','Woman','Man','Woman','Woman','Man']
data_feature_names = ['height'<\/span>,'length of hair'<\/span>]
X_train, X_test, Y_train, Y_test = cross_validation.train_test_split
(X, Y, test_size=0.40, random_state=5)
<\/span><\/code><\/pre>\n<\/p><\/div>\n
\n \u5728\u63d0\u4f9b\u6570\u636e\u96c6\u4e4b\u540e\uff0c\u9700\u8981\u62df\u5408\u53ef\u4ee5\u5982\u4e0b\u5b8c\u6210\u7684\u6a21\u578b -\n <\/div>\n
\n
 # Filename : example.py<\/span>
# Copyright : 2020 By Lidihuo<\/span>
# Author by : www.lidihuo.com<\/span>
# Date : 2020-08-26<\/span>
clf = tree.DecisionTreeClassifier<\/span>()
clf = clf.fit<\/span>(X,Y)
<\/span><\/code><\/pre>\n<\/p><\/div>\n
\n \u9884\u6d4b\u53ef\u4ee5\u4f7f\u7528\u4ee5\u4e0bPython\u4ee3\u7801\u6765\u5b8c\u6210 -\n <\/div>\n
\n
 # Filename : example.py<\/span>
# Copyright : 2020 By Lidihuo<\/span>
# Author by : www.lidihuo.com<\/span>
# Date : 2020-08-26<\/span>
prediction = clf.predict<\/span>([[133,37]])
print(prediction)
<\/span><\/code><\/pre>\n<\/p><\/div>\n
\n \u4f7f\u7528\u4ee5\u4e0bPython\u4ee3\u7801\u6765\u5b9e\u73b0\u53ef\u89c6\u5316\u51b3\u7b56\u6811 -\n <\/div>\n
\n
 # Filename : example.py<\/span>
# Copyright : 2020 By Lidihuo<\/span>
# Author by : www.lidihuo.com<\/span>
# Date : 2020-08-26<\/span>
dot_data = tree.export_graphviz<\/span>(clf,feature_names = data_feature_names,
            out_file = None,filled = True<\/span>,rounded = True<\/span>)
graph = pydotplus.graph_from_dot_data<\/span>(dot_data)
colors = ('orange'<\/span>, 'yellow'<\/span>)
edges = collections.defaultdict<\/span>(list)
for <\/span><\/span>edge in <\/span>graph.get_edge_list<\/span>():
edges[edge.get_source<\/span>()].append<\/span>(int(edge.get_destination<\/span>()))
for <\/span><\/span>edge in <\/span>edges: edges[edge].sort<\/span>()
for <\/span><\/span>i in <\/span>range(2):dest = graph.get_node<\/span>(str(edges[edge][i]))[0]
dest.set_fillcolor<\/span>(colors[i])
graph.write_png<\/span>('Decisiontree16.png'<\/span>)
<\/span><\/code><\/pre>\n<\/p><\/div>\n
\n \u5b83\u4f1a\u5c06\u4e0a\u8ff0\u4ee3\u7801\u7684\u9884\u6d4b\u4f5c\u4e3a[\u2018Woman\u2019]\u5e76\u521b\u5efa\u4ee5\u4e0b\u51b3\u7b56\u6811 -\n <\/div>\n
\n \u4eba\u5de5\u667a\u80fd\u76d1\u7763\u5b66\u4e60(\u5206\u7c7b)_https:\/\/bianchenghao6.com_\u3010\u4eba\u5de5\u667a\u80fd\u6559\u7a0b\u3011_\u7b2c4\u5f20\n <\/div>\n
\n \u53ef\u4ee5\u6539\u53d8\u9884\u6d4b\u4e2d\u7684\u7279\u5f81\u503c\u6765\u6d4b\u8bd5\u5b83\u3002\n <\/div>\n

\u968f\u673a\u68ee\u6797\u5206\u7c7b\u5668<\/h2>\n
\n \u96c6\u6210\u65b9\u6cd5\u662f\u5c06\u673a\u5668\u5b66\u4e60\u6a21\u578b\u7ec4\u5408\u6210\u66f4\u5f3a\u5927\u7684\u673a\u5668\u5b66\u4e60\u6a21\u578b\u7684\u65b9\u6cd5\u3002 \u968f\u673a\u68ee\u6797\u662f\u51b3\u7b56\u6811\u7684\u96c6\u5408\uff0c\u5c31\u662f\u5176\u4e2d\u4e4b\u4e00\u3002 \u5b83\u6bd4\u5355\u4e00\u51b3\u7b56\u6811\u597d\uff0c\u56e0\u4e3a\u5728\u4fdd\u7559\u9884\u6d4b\u80fd\u529b\u7684\u540c\u65f6\uff0c\u901a\u8fc7\u5e73\u5747\u7ed3\u679c\u53ef\u4ee5\u51cf\u5c11\u8fc7\u5ea6\u62df\u5408\u3002 \u5728\u8fd9\u91cc\uff0c\u6211\u4eec\u5c06\u5728scikit\u5b66\u4e60\u764c\u75c7\u6570\u636e\u96c6\u4e0a\u5b9e\u65bd\u968f\u673a\u68ee\u6797\u6a21\u578b\u3002\n <\/div>\n
\n \u5bfc\u5165\u5fc5\u8981\u7684\u8f6f\u4ef6\u5305 -\n <\/div>\n
\n
 # Filename : example.py<\/span>
# Copyright : 2020 By Lidihuo<\/span>
# Author by : www.lidihuo.com<\/span>
# Date : 2020-08-26<\/span>
from <\/span>sklearn.ensemble import <\/span>RandomForestClassifier
from <\/span>sklearn.model_selection import <\/span>train_test_split
from <\/span>sklearn.datasets import <\/span>load_breast_cancer
cancer = load_breast_cancer()
import <\/span>matplotlib.pyplot as <\/span>plt
import <\/span>numpy as <\/span>np
<\/span><\/code><\/pre>\n<\/p><\/div>\n
\n \u73b0\u5728\uff0c\u9700\u8981\u6309\u7167\u4ee5\u4e0b\u65b9\u5f0f\u63d0\u4f9b\u6570\u636e\u96c6\n <\/div>\n
\n
 # Filename : example.py<\/span>
# Copyright : 2020 By Lidihuo<\/span>
# Author by : www.lidihuo.com<\/span>
# Date : 2020-08-26<\/span>
cancer = load_breast_cancer()
X_train, X_test, y_train,
y_test = train_test_split(cancer.data, cancer.target, random_state = 0)
<\/span><\/code><\/pre>\n<\/p><\/div>\n
\n \u5728\u63d0\u4f9b\u6570\u636e\u96c6\u4e4b\u540e\uff0c\u9700\u8981\u62df\u5408\u53ef\u4ee5\u5982\u4e0b\u5b8c\u6210\u7684\u6a21\u578b -\n <\/div>\n
\n
 # Filename : example.py<\/span>
# Copyright : 2020 By Lidihuo<\/span>
# Author by : www.lidihuo.com<\/span>
# Date : 2020-08-26<\/span>
forest = RandomForestClassifier(n_estimators = 50, random_state = 0)
forest.fit<\/span>(X_train,y_train)
<\/span><\/code><\/pre>\n<\/p><\/div>\n
\n \u73b0\u5728\uff0c\u83b7\u5f97\u8bad\u7ec3\u4ee5\u53ca\u6d4b\u8bd5\u5b50\u96c6\u7684\u51c6\u786e\u6027:\u5982\u679c\u589e\u52a0\u4f30\u8ba1\u5668\u7684\u6570\u91cf\uff0c\u90a3\u4e48\u6d4b\u8bd5\u5b50\u96c6\u7684\u51c6\u786e\u6027\u4e5f\u4f1a\u589e\u52a0\u3002\n <\/div>\n
\n
 # Filename : example.py<\/span>
# Copyright : 2020 By Lidihuo<\/span>
# Author by : www.lidihuo.com<\/span>
# Date : 2020-08-26<\/span>
print('Accuracy on the training subset:(:.3f)'<\/span><\/span>,format<\/span>(forest.score<\/span>(X_train,y_train)))
print('Accuracy on the training subset:(:.3f)',format<\/span>(forest.score<\/span>(X_test,y_test)))
<\/span><\/code><\/pre>\n<\/p><\/div>\n
\n \u4e0a\u9762\u4ee3\u7801\uff0c\u8f93\u51fa\u7ed3\u679c\u5982\u4e0b\u6240\u793a -\n <\/div>\n
\n
 # Filename : example.py<\/span>
# Copyright : 2020 By Lidihuo<\/span>
# Author by : www.lidihuo.com<\/span>
# Date : 2020-08-26<\/span>
Accuracy on the training subset:(:.3f) 1.0
Accuracy on the training subset:(:.3f) 0.965034965034965
<\/span><\/code><\/pre>\n<\/p><\/div>\n
\n \u73b0\u5728\uff0c\u4e0e\u51b3\u7b56\u6811\u4e00\u6837\uff0c\u968f\u673a\u68ee\u6797\u5177\u6709feature_importance\u6a21\u5757\uff0c\u5b83\u5c06\u63d0\u4f9b\u6bd4\u51b3\u7b56\u6811\u66f4\u597d\u7684\u7279\u5f81\u6743\u91cd\u89c6\u56fe\u3002 \u5b83\u53ef\u4ee5\u5982\u4e0b\u7ed8\u5236\u548c\u53ef\u89c6\u5316 -\n <\/div>\n
\n
 # Filename : example.py<\/span>
# Copyright : 2020 By Lidihuo<\/span>
# Author by : www.lidihuo.com<\/span>
# Date : 2020-08-26<\/span>
n_features = cancer.data.shape[1]
plt.barh<\/span>(range(n_features),forest.feature_importances_, align='center'<\/span>)
plt.yticks<\/span>(np.arange<\/span>(n_features),cancer.feature_names)
plt.xlabel<\/span>('Feature Importance'<\/span>)
plt.ylabel<\/span>('Feature'<\/span>)
plt.show<\/span>()
<\/span><\/code><\/pre>\n<\/p><\/div>\n
\n \u6267\u884c\u4e0a\u9762\u4ee3\u7801\uff0c\u5f97\u5230\u4ee5\u4e0b\u8f93\u51fa\u7ed3\u679c -\n <\/div>\n
\n \u4eba\u5de5\u667a\u80fd\u76d1\u7763\u5b66\u4e60(\u5206\u7c7b)_https:\/\/bianchenghao6.com_\u3010\u4eba\u5de5\u667a\u80fd\u6559\u7a0b\u3011_\u7b2c5\u5f20\n <\/div>\n

\u5206\u7c7b\u5668\u7684\u6027\u80fd<\/h2>\n
\n \u5728\u5b9e\u73b0\u673a\u5668\u5b66\u4e60\u7b97\u6cd5\u4e4b\u540e\uff0c\u6211\u4eec\u9700\u8981\u627e\u51fa\u6a21\u578b\u7684\u6709\u6548\u6027\u3002 \u8861\u91cf\u6709\u6548\u6027\u7684\u6807\u51c6\u53ef\u4ee5\u57fa\u4e8e\u6570\u636e\u96c6\u548c\u5ea6\u91cf\u6807\u51c6\u3002 \u4e3a\u4e86\u8bc4\u4f30\u4e0d\u540c\u7684\u673a\u5668\u5b66\u4e60\u7b97\u6cd5\uff0c\u6211\u4eec\u53ef\u4ee5\u4f7f\u7528\u4e0d\u540c\u7684\u6027\u80fd\u6307\u6807\u3002 \u4f8b\u5982\uff0c\u5047\u8bbe\u4f7f\u7528\u5206\u7c7b\u5668\u6765\u533a\u5206\u4e0d\u540c\u5bf9\u8c61\u7684\u56fe\u50cf\uff0c\u53ef\u4ee5\u4f7f\u7528\u5206\u7c7b\u6027\u80fd\u6307\u6807\uff0c\u5982\u5e73\u5747\u51c6\u786e\u7387\uff0cAUC\u7b49\u3002\u4ece\u67d0\u79cd\u610f\u4e49\u4e0a\u8bf4\uff0c\u6211\u4eec\u9009\u62e9\u8bc4\u4f30\u673a\u5668\u5b66\u4e60\u6a21\u578b\u7684\u6307\u6807\u662f\u975e\u5e38\u91cd\u8981\u7684\uff0c\u56e0\u4e3a\u6307\u6807\u7684\u9009\u62e9\u4f1a\u5f71\u54cd\u673a\u5668\u5b66\u4e60\u7b97\u6cd5\u7684\u6027\u80fd\u5982\u4f55\u88ab\u6d4b\u91cf\u548c\u6bd4\u8f83\u3002 \u4ee5\u4e0b\u662f\u4e00\u4e9b\u6307\u6807 -\n <\/div>\n
\n \u6df7\u4e71\u77e9\u9635<\/strong>\n <\/div>\n
\n \u57fa\u672c\u4e0a\u5b83\u7528\u4e8e\u8f93\u51fa\u53ef\u4ee5\u662f\u4e24\u79cd\u6216\u66f4\u591a\u79cd\u7c7b\u7684\u5206\u7c7b\u95ee\u9898\u3002 \u8fd9\u662f\u8861\u91cf\u5206\u7c7b\u5668\u6027\u80fd\u7684\u6700\u7b80\u5355\u65b9\u6cd5\u3002 \u6df7\u6dc6\u77e9\u9635\u57fa\u672c\u4e0a\u662f\u4e00\u4e2a\u5305\u542b\u4e24\u4e2a\u7ef4\u5ea6\u5373\u201c\u5b9e\u9645\u201d\u548c\u201c\u9884\u6d4b\u201d\u7684\u8868\u683c\u3002 \u8fd9\u4e24\u4e2a\u7ef4\u5ea6\u90fd\u6709\u201c\u771f\u6b63\u7684\u6b63\u9762(TP)\u201d\uff0c\u201c\u771f\u6b63\u7684\u8d1f\u9762(TN)\u201d\uff0c\u201c\u9519\u8bef\u7684\u6b63\u9762(FP)\u201d\uff0c\u201c\u9519\u8bef\u7684\u5426\u5b9a(FN)\u201d\u3002\n <\/div>\n
\n \u4eba\u5de5\u667a\u80fd\u76d1\u7763\u5b66\u4e60(\u5206\u7c7b)_https:\/\/bianchenghao6.com_\u3010\u4eba\u5de5\u667a\u80fd\u6559\u7a0b\u3011_\u7b2c6\u5f20\n <\/div>\n
\n \u5728\u4e0a\u9762\u7684\u6df7\u6dc6\u77e9\u9635\u4e2d\uff0c1\u8868\u793a\u6b63\u7c7b\uff0c0\u8868\u793a\u8d1f\u7c7b\u3002\u4ee5\u4e0b\u662f\u4e0e\u6df7\u6dc6\u77e9\u9635\u76f8\u5173\u7684\u672f\u8bed -\n <\/div>\n

\u771f\u6b63 - \u5f53\u5b9e\u9645\u7684\u6570\u636e\u70b9\u7c7b\u522b\u4e3a1\u5e76\u4e14\u9884\u6d4b\u4e5f\u4e3a1\u65f6\uff0cTP\u5c31\u662f\u8fd9\u79cd\u60c5\u51b5\u3002<\/span>
\n \u771f\u8d1f - \u5f53\u6570\u636e\u70b9\u7684\u5b9e\u9645\u7c7b\u522b\u4e3a0\u5e76\u4e14\u9884\u6d4b\u4e5f\u4e3a0\u65f6\uff0cTN\u5c31\u662f\u8fd9\u79cd\u60c5\u51b5\u3002<\/span>
\n \u5047\u6b63 - \u5f53\u5b9e\u9645\u7684\u6570\u636e\u70b9\u7c7b\u522b\u4e3a0\u5e76\u4e14\u9884\u6d4b\u4e5f\u4e3a1\u65f6\uff0cFP\u5c31\u662f\u8fd9\u79cd\u60c5\u51b5\u3002<\/span>
\n \u5047\u8d1f - FN\u662f\u6570\u636e\u70b9\u7684\u5b9e\u9645\u7c7b\u522b\u4e3a1\u4e14\u9884\u6d4b\u4e5f\u4e3a0\u7684\u60c5\u51b5\u3002<\/span> <\/p>\n

\n \u51c6\u786e\u6027<\/strong>\n <\/div>\n
\n \u6df7\u6dc6\u77e9\u9635\u672c\u8eab\u5e76\u4e0d\u662f\u4e00\u4e2a\u6027\u80fd\u6307\u6807\uff0c\u4f46\u51e0\u4e4e\u6240\u6709\u7684\u6027\u80fd\u77e9\u9635\u5747\u57fa\u4e8e\u6df7\u6dc6\u77e9\u9635\u3002 \u5176\u4e2d\u4e4b\u4e00\u662f\u51c6\u786e\u6027\u3002 \u5728\u5206\u7c7b\u95ee\u9898\u4e2d\uff0c\u5b83\u53ef\u80fd\u88ab\u5b9a\u4e49\u4e3a\u7531\u6a21\u578b\u5bf9\u5404\u79cd\u9884\u6d4b\u6240\u505a\u7684\u6b63\u786e\u9884\u6d4b\u7684\u6570\u91cf\u3002 \u8ba1\u7b97\u51c6\u786e\u5ea6\u7684\u516c\u5f0f\u5982\u4e0b -
\n \u4eba\u5de5\u667a\u80fd\u76d1\u7763\u5b66\u4e60(\u5206\u7c7b)_https:\/\/bianchenghao6.com_\u3010\u4eba\u5de5\u667a\u80fd\u6559\u7a0b\u3011_\u7b2c7\u5f20\n <\/div>\n
\n \u7cbe\u786e<\/strong>\u5b83\u4e3b\u8981\u7528\u4e8e\u6587\u4ef6\u68c0\u7d22\u3002 \u5b83\u53ef\u80fd\u88ab\u5b9a\u4e49\u4e3a\u8fd4\u56de\u7684\u6587\u4ef6\u6709\u591a\u5c11\u662f\u6b63\u786e\u7684\u3002 \u4ee5\u4e0b\u662f\u8ba1\u7b97\u7cbe\u5ea6\u7684\u516c\u5f0f -
\n \u4eba\u5de5\u667a\u80fd\u76d1\u7763\u5b66\u4e60(\u5206\u7c7b)_https:\/\/bianchenghao6.com_\u3010\u4eba\u5de5\u667a\u80fd\u6559\u7a0b\u3011_\u7b2c8\u5f20\n <\/div>\n
\n \u53ec\u56de\u6216\u7075\u654f\u5ea6<\/strong>\u5b83\u53ef\u80fd\u88ab\u5b9a\u4e49\u4e3a\u6a21\u578b\u8fd4\u56de\u7684\u6b63\u6570\u6709\u591a\u5c11\u3002 \u4ee5\u4e0b\u662f\u8ba1\u7b97\u6a21\u578b\u53ec\u56de\/\u7075\u654f\u5ea6\u7684\u516c\u5f0f -\n <\/div>\n
\n \u4eba\u5de5\u667a\u80fd\u76d1\u7763\u5b66\u4e60(\u5206\u7c7b)_https:\/\/bianchenghao6.com_\u3010\u4eba\u5de5\u667a\u80fd\u6559\u7a0b\u3011_\u7b2c9\u5f20\n <\/div>\n
\n \u7279\u5f02\u6027<\/strong>\u5b83\u53ef\u4ee5\u5b9a\u4e49\u4e3a\u6a21\u578b\u8fd4\u56de\u7684\u8d1f\u6570\u6709\u591a\u5c11\u3002 \u8fd9\u4e0e\u53ec\u56de\u5b8c\u5168\u76f8\u53cd\u3002 \u4ee5\u4e0b\u662f\u8ba1\u7b97\u6a21\u578b\u7279\u5f02\u6027\u7684\u516c\u5f0f -\n <\/div>\n
\n \u4eba\u5de5\u667a\u80fd\u76d1\u7763\u5b66\u4e60(\u5206\u7c7b)_https:\/\/bianchenghao6.com_\u3010\u4eba\u5de5\u667a\u80fd\u6559\u7a0b\u3011_\u7b2c10\u5f20\n <\/div>\n

\u5206\u7c7b\u5931\u8861\u95ee\u9898<\/h2>\n
\n \u5206\u7c7b\u4e0d\u5e73\u8861\u662f\u5c5e\u4e8e\u4e00\u4e2a\u7c7b\u522b\u7684\u89c2\u5bdf\u6570\u91cf\u663e\u7740\u4f4e\u4e8e\u5c5e\u4e8e\u5176\u4ed6\u7c7b\u522b\u7684\u89c2\u6d4b\u6570\u91cf\u7684\u573a\u666f\u3002 \u4f8b\u5982\uff0c\u5728\u6211\u4eec\u9700\u8981\u8bc6\u522b\u7f55\u89c1\u75be\u75c5\uff0c\u94f6\u884c\u6b3a\u8bc8\u6027\u4ea4\u6613\u7b49\u60c5\u51b5\u4e0b\uff0c\u8fd9\u4e2a\u95ee\u9898\u975e\u5e38\u7a81\u51fa\u3002\n <\/div>\n
\n \u4e0d\u5e73\u8861\u5206\u7c7b\u7684\u4f8b\u5b50<\/strong>\u8ba9\u6211\u4eec\u8003\u8651\u4e00\u4e2a\u6b3a\u8bc8\u68c0\u6d4b\u6570\u636e\u96c6\u7684\u4f8b\u5b50\u6765\u7406\u89e3\u4e0d\u5e73\u8861\u5206\u7c7b\u7684\u6982\u5ff5 -\n <\/div>\n
\n
 # Filename : example.py<\/span>
# Copyright : 2020 By Lidihuo<\/span>
# Author by : www.lidihuo.com<\/span>
# Date : 2020-08-26<\/span>
Total observations = 5000
Fraudulent Observations = 50
Non-Fraudulent Observations = 4950
Event Rate = 1%
<\/span><\/code><\/pre>\n<\/p><\/div>\n
\n \u89e3\u51b3<\/strong>\u5e73\u8861\u7c7b\u7684\u884c\u4e3a\uff0c\u89e3\u51b3\u4e0d\u5e73\u8861\u7684\u7c7b\u95ee\u9898\u3002 \u5e73\u8861\u7c7b\u7684\u4e3b\u8981\u76ee\u6807\u662f\u589e\u52a0\u5c11\u6570\u7c7b\u7684\u9891\u7387\u6216\u51cf\u5c11\u591a\u6570\u7c7b\u7684\u9891\u7387\u3002 \u4ee5\u4e0b\u662f\u89e3\u51b3\u5931\u8861\u7c7b\u95ee\u9898\u7684\u65b9\u6cd5 -\n <\/div>\n
\n \u91cd\u91c7\u6837<\/strong>\u91cd\u65b0\u91c7\u6837\u662f\u7528\u4e8e\u91cd\u5efa\u6837\u672c\u6570\u636e\u96c6\u7684\u4e00\u7cfb\u5217\u65b9\u6cd5 - \u5305\u62ec\u8bad\u7ec3\u96c6\u548c\u6d4b\u8bd5\u96c6\u3002 \u91cd\u65b0\u62bd\u6837\u662f\u4e3a\u4e86\u63d0\u9ad8\u6a21\u578b\u7684\u51c6\u786e\u6027\u3002 \u4ee5\u4e0b\u662f\u4e00\u4e9b\u91cd\u65b0\u62bd\u6837\u6280\u672f -\n <\/div>\n

\u968f\u673a\u62bd\u6837<\/strong> - \u8fd9\u9879\u6280\u672f\u65e8\u5728\u901a\u8fc7\u968f\u673a\u6392\u9664\u5927\u591a\u6570\u7c7b\u522b\u7684\u4f8b\u5b50\u6765\u5e73\u8861\u8bfe\u5802\u5206\u5e03\u3002 \u8fd9\u6837\u505a\u76f4\u5230\u5927\u591a\u6570\u548c\u5c11\u6570\u7fa4\u4f53\u7684\u5b9e\u4f8b\u5f97\u5230\u5e73\u8861\u3002<\/span> <\/p>\n

\n
 # Filename : example.py<\/span>
# Copyright : 2020 By Lidihuo<\/span>
# Author by : www.lidihuo.com<\/span>
# Date : 2020-08-26<\/span>
Total observations = 5000
Fraudulent Observations = 50
Non-Fraudulent Observations = 4950
Event Rate = 1%
<\/span><\/code><\/pre>\n<\/p><\/div>\n
\n \u5728\u8fd9\u79cd\u60c5\u51b5\u4e0b\uff0c\u6211\u4eec\u5c0610%\u7684\u6837\u672c\u4ece\u975e\u6b3a\u8bc8\u5b9e\u4f8b\u4e2d\u53d6\u800c\u4ee3\u4e4b\uff0c\u7136\u540e\u5c06\u5b83\u4eec\u4e0e\u6b3a\u8bc8\u5b9e\u4f8b\u76f8\u7ed3\u5408 -\u968f\u673a\u62bd\u6837\u540e\u7684\u975e\u6b3a\u8bc8\u6027\u89c2\u5bdf:4950\u768410% = 495\u5c06\u4ed6\u4eec\u4e0e\u6b3a\u8bc8\u89c2\u5bdf\u7ed3\u5408\u540e\u7684\u603b\u89c2\u6d4b\u503c: 50 + 495 = 545\n <\/div>\n
\n \u56e0\u6b64\uff0c\u73b0\u5728\uff0c\u4f4e\u91c7\u6837\u540e\u65b0\u6570\u636e\u96c6\u7684\u4e8b\u4ef6\u7387\u4e3a: 9%\n <\/div>\n
\n \u8fd9\u79cd\u6280\u672f\u7684\u4e3b\u8981\u4f18\u70b9\u662f\u53ef\u4ee5\u51cf\u5c11\u8fd0\u884c\u65f6\u95f4\u5e76\u6539\u5584\u5b58\u50a8\u3002 \u4f46\u53e6\u4e00\u65b9\u9762\uff0c\u5b83\u53ef\u4ee5\u4e22\u5f03\u6709\u7528\u7684\u4fe1\u606f\uff0c\u540c\u65f6\u51cf\u5c11\u8bad\u7ec3\u6570\u636e\u6837\u672c\u7684\u6570\u91cf\u3002\n <\/div>\n

\u968f\u673a\u62bd\u6837<\/strong> - \u8fd9\u79cd\u6280\u672f\u65e8\u5728\u901a\u8fc7\u590d\u5236\u5c11\u6570\u7c7b\u4e2d\u7684\u5b9e\u4f8b\u6570\u91cf\u6765\u5e73\u8861\u7c7b\u5206\u5e03\u3002<\/span> <\/p>\n

\n
 # Filename : example.py<\/span>
# Copyright : 2020 By Lidihuo<\/span>
# Author by : www.lidihuo.com<\/span>
# Date : 2020-08-26<\/span>
Total observations = 5000
Fraudulent Observations = 50
Non-Fraudulent Observations = 4950
Event Rate = 1%
<\/span><\/code><\/pre>\n<\/p><\/div>\n
\n \u5982\u679c\u590d\u523650\u6b21\u6b3a\u8bc8\u6027\u89c2\u5bdf30\u6b21\uff0c\u90a3\u4e48\u5728\u590d\u5236\u5c11\u6570\u7c7b\u522b\u89c2\u5bdf\u503c\u540e\u6b3a\u8bc8\u89c2\u5bdf\u503c\u5c06\u4e3a1500\u3002\u7136\u540e\uff0c\u5728\u8fc7\u91c7\u6837\u540e\u65b0\u6570\u636e\u4e2d\u7684\u603b\u89c2\u5bdf\u503c\u5c06\u4e3a:4950 + 1500 = 6450\u3002\u56e0\u6b64\uff0c\u65b0\u6570\u636e\u96c6\u7684\u4e8b\u4ef6\u7387\u662f:1500\/6450 = 23%\u3002\n <\/div>\n
\n \u8fd9\u79cd\u65b9\u6cd5\u7684\u4e3b\u8981\u4f18\u70b9\u662f\u4e0d\u4f1a\u4e22\u5931\u6709\u7528\u7684\u4fe1\u606f\u3002 \u4f46\u53e6\u4e00\u65b9\u9762\uff0c\u7531\u4e8e\u5b83\u590d\u5236\u4e86\u5c11\u6570\u65cf\u7fa4\u7684\u4e8b\u4ef6\uff0c\u56e0\u6b64\u5b83\u6709\u66f4\u591a\u7684\u8fc7\u5ea6\u673a\u4f1a\u3002\n <\/div>\n

\u5408\u594f\u6280\u5de7<\/h2>\n
\n \u8fd9\u79cd\u65b9\u6cd5\u57fa\u672c\u4e0a\u7528\u4e8e\u4fee\u6539\u73b0\u6709\u7684\u5206\u7c7b\u7b97\u6cd5\uff0c\u4f7f\u5176\u9002\u7528\u4e8e\u4e0d\u5e73\u8861\u7684\u6570\u636e\u96c6\u3002 \u5728\u8fd9\u79cd\u65b9\u6cd5\u4e2d\uff0c\u6211\u4eec\u4ece\u539f\u59cb\u6570\u636e\u4e2d\u6784\u5efa\u51e0\u4e2a\u4e24\u9636\u6bb5\u5206\u7c7b\u5668\uff0c\u7136\u540e\u6c47\u603b\u5b83\u4eec\u7684\u9884\u6d4b\u3002 \u968f\u673a\u68ee\u6797\u5206\u7c7b\u5668\u662f\u57fa\u4e8e\u96c6\u5408\u7684\u5206\u7c7b\u5668\u7684\u4e00\u4e2a\u4f8b\u5b50\u3002
\n \u4eba\u5de5\u667a\u80fd\u76d1\u7763\u5b66\u4e60(\u5206\u7c7b)_https:\/\/bianchenghao6.com_\u3010\u4eba\u5de5\u667a\u80fd\u6559\u7a0b\u3011_\u7b2c11\u5f20\n <\/div>\n

<\/body>
\n<\/html><\/p>\n","protected":false},"excerpt":{"rendered":"\u4eba\u5de5\u667a\u80fd\u76d1\u7763\u5b66\u4e60(\u5206\u7c7b)zh-cn","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[137],"tags":[],"class_list":["post-1310","post","type-post","status-publish","format-standard","hentry","category-rgznjc1"],"_links":{"self":[{"href":"https:\/\/bianchenghao6.com\/wp-json\/wp\/v2\/posts\/1310"}],"collection":[{"href":"https:\/\/bianchenghao6.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/bianchenghao6.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/bianchenghao6.com\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/bianchenghao6.com\/wp-json\/wp\/v2\/comments?post=1310"}],"version-history":[{"count":0,"href":"https:\/\/bianchenghao6.com\/wp-json\/wp\/v2\/posts\/1310\/revisions"}],"wp:attachment":[{"href":"https:\/\/bianchenghao6.com\/wp-json\/wp\/v2\/media?parent=1310"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/bianchenghao6.com\/wp-json\/wp\/v2\/categories?post=1310"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/bianchenghao6.com\/wp-json\/wp\/v2\/tags?post=1310"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}