{"id":47575,"date":"2024-12-02T11:43:19","date_gmt":"2024-12-02T03:43:19","guid":{"rendered":"https:\/\/fwq.ai\/blog\/47575\/"},"modified":"2024-12-02T11:43:19","modified_gmt":"2024-12-02T03:43:19","slug":"php%e5%87%bd%e6%95%b0%e5%9c%a8%e6%9c%ba%e5%99%a8%e5%ad%a6%e4%b9%a0%e4%b8%ad%e7%9a%84%e5%85%b3%e9%94%ae%e4%bd%9c%e7%94%a8","status":"publish","type":"post","link":"https:\/\/fwq.ai\/blog\/47575\/","title":{"rendered":"PHP\u51fd\u6570\u5728\u673a\u5668\u5b66\u4e60\u4e2d\u7684\u5173\u952e\u4f5c\u7528"},"content":{"rendered":"<p><b><\/b> <\/p>\n<h1>PHP\u51fd\u6570\u5728\u673a\u5668\u5b66\u4e60\u4e2d\u7684\u5173\u952e\u4f5c\u7528<\/h1>\n<p>\u5927\u5bb6\u597d\uff0c\u4eca\u5929\u672c\u4eba\u7ed9\u5927\u5bb6\u5e26\u6765\u6587\u7ae0<span style=\"color: #FF6600;, Helvetica, Arial, sans-serif;font-size: 14px;background-color: #FFFFFF\">\u300aPHP\u51fd\u6570\u5728\u673a\u5668\u5b66\u4e60\u4e2d\u7684\u5173\u952e\u4f5c\u7528\u300b<\/span>\uff0c\u6587\u4e2d\u5185\u5bb9\u4e3b\u8981\u6d89\u53ca\u5230<span style=\"color: #FF6600;, Helvetica, Arial, sans-serif;font-size: 14px;background-color: #FFFFFF\"><span style=\"color: #FF6600;, Helvetica, Arial, sans-serif;font-size: 14px;background-color: #FFFFFF\"><\/span><\/span>\uff0c\u5982\u679c\u4f60\u5bf9<span style=\"color: #FF6600;, Helvetica, Arial, sans-serif;font-size: 14px;background-color: #FFFFFF\">\u6587\u7ae0<\/span>\u65b9\u9762\u7684\u77e5\u8bc6\u70b9\u611f\u5174\u8da3\uff0c\u90a3\u5c31\u8bf7\u5404\u4f4d\u670b\u53cb\u7ee7\u7eed\u770b\u4e0b\u53bb\u5427~\u5e0c\u671b\u80fd\u771f\u6b63\u5e2e\u5230\u4f60\u4eec\uff0c\u8c22\u8c22\uff01<\/p>\n<p>PHP\u5728\u673a\u5668\u5b66\u4e60\u4e2d\u626e\u6f14\u7740\u5173\u952e\u89d2\u8272\uff0c\u63d0\u4f9b\u4ee5\u4e0b\u51fd\u6570\uff1a\u7ebf\u6027\u56de\u5f52\uff1astats_regression_linear()\u805a\u7c7b\uff1akmeans()\u5206\u7c7b\uff1asvm_train() \u548c svm_predict()<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/www.17golang.com\/uploads\/20241026\/1729924113671c8c11af334.jpg\" class=\"aligncenter\" title=\"PHP\u51fd\u6570\u5728\u673a\u5668\u5b66\u4e60\u4e2d\u7684\u5173\u952e\u4f5c\u7528\u63d2\u56fe\" alt=\"PHP\u51fd\u6570\u5728\u673a\u5668\u5b66\u4e60\u4e2d\u7684\u5173\u952e\u4f5c\u7528\u63d2\u56fe\" \/><\/p>\n<p><strong>PHP\u51fd\u6570\u5728\u673a\u5668\u5b66\u4e60\u4e2d\u7684\u5173\u952e\u4f5c\u7528<\/strong><\/p>\n<p><strong>\u5f15\u8a00<\/strong><\/p>\n<p>PHP\u662f\u4e00\u79cd\u901a\u7528\u811a\u672c\u8bed\u8a00\uff0c\u5728\u6784\u5efa\u7f51\u7ad9\u548c\u5e94\u7528\u7a0b\u5e8f\u65f6\u5f97\u5230\u5e7f\u6cdb\u4f7f\u7528\u3002\u8fd1\u5e74\u6765\uff0cPHP\u5728\u673a\u5668\u5b66\u4e60\u9886\u57df\u4e5f\u83b7\u5f97\u4e86\u6781\u5927\u7684\u5173\u6ce8\u3002\u8fd9\u662f\u56e0\u4e3aPHP\u63d0\u4f9b\u4e86\u4e00\u7cfb\u5217\u975e\u5e38\u9002\u5408\u673a\u5668\u5b66\u4e60\u4efb\u52a1\u7684\u51fd\u6570\u548c\u5e93\u3002<\/p>\n<p><strong>\u7ebf\u6027\u56de\u5f52<\/strong><\/p>\n<p>\u7ebf\u6027\u56de\u5f52\u662f\u673a\u5668\u5b66\u4e60\u4e2d\u4e00\u79cd\u5e38\u7528\u7684\u7b97\u6cd5\uff0c\u7528\u4e8e\u9884\u6d4b\u8fde\u7eed\u503c\u3002PHP\u53ef\u4ee5\u901a\u8fc7<code>stats_regression_linear()<\/code>\u51fd\u6570\u8f7b\u677e\u5730\u6267\u884c\u7ebf\u6027\u56de\u5f52\u3002\u8be5\u51fd\u6570\u63a5\u6536\u6570\u636e\u70b9\u6570\u7ec4\u5e76\u8fd4\u56de\u56de\u5f52\u7cfb\u6570\u548c\u622a\u8ddd\u3002<\/p>\n<p><strong>\u793a\u4f8b\u4ee3\u7801\uff1a<\/strong><\/p>\n<pre>&lt;?php\n$data = [\n    [1, 2],\n    [3, 4],\n    [5, 6],\n];\n\n$result = stats_regression_linear($data);\nprint_r($result);\n?&gt;<\/pre>\n<p><strong>\u8f93\u51fa\uff1a<\/strong><\/p>\n<pre>Array\n(\n    [slope] =&gt; 1.2\n    [intercept] =&gt; 0.8\n)<\/pre>\n<p><strong>\u805a\u7c7b<\/strong><\/p>\n<p>\u805a\u7c7b\u662f\u4e00\u79cd\u5c06\u76f8\u4f3c\u6570\u636e\u70b9\u5206\u7ec4\u5728\u4e00\u8d77\u7684\u673a\u5668\u5b66\u4e60\u6280\u672f\u3002PHP\u53ef\u4ee5\u901a\u8fc7<code>kmeans()<\/code>\u51fd\u6570\u6267\u884c\u805a\u7c7b\u3002\u8be5\u51fd\u6570\u63a5\u6536\u6570\u636e\u70b9\u6570\u7ec4\u548c\u7fa4\u96c6\u6570\uff0c\u5e76\u8fd4\u56de\u6bcf\u4e2a\u6570\u636e\u70b9\u7684\u7fa4\u96c6\u5206\u914d\u3002<\/p>\n<p><strong>\u793a\u4f8b\u4ee3\u7801\uff1a<\/strong><\/p>\n<pre>&lt;?php\n$data = [\n    [1, 2],\n    [3, 4],\n    [5, 6],\n    [7, 8],\n];\n\n$result = kmeans($data, 2);\nprint_r($result);\n?&gt;<\/pre>\n<p><strong>\u8f93\u51fa\uff1a<\/strong><\/p>\n<pre>Array\n(\n    [0] =&gt; 0\n    [1] =&gt; 0\n    [2] =&gt; 1\n    [3] =&gt; 1\n)<\/pre>\n<p><strong>\u5206\u7c7b<\/strong><\/p>\n<p>\u5206\u7c7b\u662f\u4e00\u79cd\u5c06\u6570\u636e\u70b9\u5206\u914d\u7ed9\u9884\u5b9a\u4e49\u7c7b\u522b\u6216\u6807\u7b7e\u7684\u673a\u5668\u5b66\u4e60\u6280\u672f\u3002PHP\u53ef\u4ee5\u901a\u8fc7<code>svm_train()<\/code>\u548c<code>svm_predict()<\/code>\u51fd\u6570\u6267\u884c\u652f\u6301\u5411\u91cf\u673a\uff08SVM\uff09\u5206\u7c7b\u3002\u8fd9\u4e9b\u51fd\u6570\u4f7f\u7528\u652f\u6301\u5411\u91cf\u673a\u7b97\u6cd5\u6765\u8bad\u7ec3\u6a21\u578b\uff0c\u7136\u540e\u6839\u636e\u8be5\u6a21\u578b\u5bf9\u65b0\u6570\u636e\u70b9\u8fdb\u884c\u5206\u7c7b\u3002<\/p>\n<p><strong>\u793a\u4f8b\u4ee3\u7801\uff1a<\/strong><\/p>\n<pre>&lt;?php\n$data = [\n    [1, 2, 0],\n    [3, 4, 1],\n    [5, 6, 0],\n];\n\n$model = svm_train($data);\n$result = svm_predict([1, 2], $model);\n\necho $result; \/\/ \u8f93\u51fa\uff1a0<\/pre>\n<p><strong>\u7ed3\u8bba<\/strong><\/p>\n<p>PHP\u63d0\u4f9b\u4e86\u4e00\u7cfb\u5217\u5f3a\u5927\u7684\u51fd\u6570\u548c\u5e93\uff0c\u4f7f\u673a\u5668\u5b66\u4e60\u53d8\u5f97\u89e6\u624b\u53ef\u53ca\u3002\u901a\u8fc7\u5229\u7528\u8fd9\u4e9b\u51fd\u6570\uff0c\u5f00\u53d1\u8005\u53ef\u4ee5\u5728PHP\u4e2d\u8f7b\u677e\u5b9e\u73b0\u5404\u79cd\u673a\u5668\u5b66\u4e60\u7b97\u6cd5\uff0c\u5305\u62ec\u7ebf\u6027\u56de\u5f52\u3001\u805a\u7c7b\u548c\u5206\u7c7b\u3002<\/p>\n<p>\u4eca\u5929\u5173\u4e8e\u300aPHP\u51fd\u6570\u5728\u673a\u5668\u5b66\u4e60\u4e2d\u7684\u5173\u952e\u4f5c\u7528\u300b\u7684\u5185\u5bb9\u5c31\u4ecb\u7ecd\u5230\u8fd9\u91cc\u4e86\uff0c\u662f\u4e0d\u662f\u5b66\u8d77\u6765\u4e00\u76ee\u4e86\u7136\uff01\u60f3\u8981\u4e86\u89e3\u66f4\u591a\u5173\u4e8ephp,\u673a\u5668\u5b66\u4e60\u7684\u5185\u5bb9\u8bf7\u5173\u6ce8\u7c73\u4e91\u516c\u4f17\u53f7\uff01<\/p>\n","protected":false},"excerpt":{"rendered":"<p>PHP\u51fd\u6570\u5728\u673a\u5668\u5b66\u4e60\u4e2d\u7684\u5173\u952e\u4f5c\u7528 \u5927\u5bb6\u597d\uff0c\u4eca\u5929\u672c\u4eba\u7ed9\u5927\u5bb6\u5e26\u6765\u6587\u7ae0\u300aPHP\u51fd\u6570\u5728\u673a\u5668\u5b66\u4e60\u4e2d\u7684\u5173\u952e\u4f5c\u7528\u300b\uff0c\u6587\u4e2d\u5185\u5bb9\u4e3b\u8981\u6d89\u53ca\u5230\uff0c\u5982\u679c\u4f60\u5bf9\u6587\u7ae0\u65b9\u9762\u7684\u77e5\u8bc6\u70b9\u611f\u5174\u8da3\uff0c\u90a3\u5c31\u8bf7\u5404\u4f4d\u670b\u53cb\u7ee7\u7eed\u770b\u4e0b\u53bb\u5427~\u5e0c\u671b\u80fd\u771f\u6b63\u5e2e\u5230\u4f60\u4eec\uff0c\u8c22\u8c22\uff01 PHP\u5728\u673a\u5668\u5b66\u4e60\u4e2d\u626e\u6f14\u7740\u5173\u952e\u89d2\u8272\uff0c\u63d0\u4f9b\u4ee5\u4e0b\u51fd\u6570\uff1a\u7ebf\u6027\u56de\u5f52\uff1astats_regression_linear()\u805a\u7c7b\uff1akmeans()\u5206\u7c7b\uff1asvm_train() \u548c svm_predict() PHP\u51fd\u6570\u5728\u673a\u5668\u5b66\u4e60\u4e2d\u7684\u5173\u952e\u4f5c\u7528 \u5f15\u8a00 PHP\u662f\u4e00\u79cd\u901a\u7528\u811a\u672c\u8bed\u8a00\uff0c\u5728\u6784\u5efa\u7f51\u7ad9\u548c\u5e94\u7528\u7a0b\u5e8f\u65f6\u5f97\u5230\u5e7f\u6cdb\u4f7f\u7528\u3002\u8fd1\u5e74\u6765\uff0cPHP\u5728\u673a\u5668\u5b66\u4e60\u9886\u57df\u4e5f\u83b7\u5f97\u4e86\u6781\u5927\u7684\u5173\u6ce8\u3002\u8fd9\u662f\u56e0\u4e3aPHP\u63d0\u4f9b\u4e86\u4e00\u7cfb\u5217\u975e\u5e38\u9002\u5408\u673a\u5668\u5b66\u4e60\u4efb\u52a1\u7684\u51fd\u6570\u548c\u5e93\u3002 \u7ebf\u6027\u56de\u5f52 \u7ebf\u6027\u56de\u5f52\u662f\u673a\u5668\u5b66\u4e60\u4e2d\u4e00\u79cd\u5e38\u7528\u7684\u7b97\u6cd5\uff0c\u7528\u4e8e\u9884\u6d4b\u8fde\u7eed\u503c\u3002PHP\u53ef\u4ee5\u901a\u8fc7stats_regression_linear()\u51fd\u6570\u8f7b\u677e\u5730\u6267\u884c\u7ebf\u6027\u56de\u5f52\u3002\u8be5\u51fd\u6570\u63a5\u6536\u6570\u636e\u70b9\u6570\u7ec4\u5e76\u8fd4\u56de\u56de\u5f52\u7cfb\u6570\u548c\u622a\u8ddd\u3002 \u793a\u4f8b\u4ee3\u7801\uff1a &lt;?php $data = [ [1, 2], [3, 4], [5, 6], ]; $result = stats_regression_linear($data); print_r($result); ?&gt; \u8f93\u51fa\uff1a Array ( [slope] =&gt; 1.2 [intercept] =&gt; 0.8 ) \u805a\u7c7b \u805a\u7c7b\u662f\u4e00\u79cd\u5c06\u76f8\u4f3c\u6570\u636e\u70b9\u5206\u7ec4\u5728\u4e00\u8d77\u7684\u673a\u5668\u5b66\u4e60\u6280\u672f\u3002PHP\u53ef\u4ee5\u901a\u8fc7kmeans()\u51fd\u6570\u6267\u884c\u805a\u7c7b\u3002\u8be5\u51fd\u6570\u63a5\u6536\u6570\u636e\u70b9\u6570\u7ec4\u548c\u7fa4\u96c6\u6570\uff0c\u5e76\u8fd4\u56de\u6bcf\u4e2a\u6570\u636e\u70b9\u7684\u7fa4\u96c6\u5206\u914d\u3002 \u793a\u4f8b\u4ee3\u7801\uff1a &lt;?php $data = [ [1, 2], [3, 4], [5, 6], [7, 8], ]; $result = [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[16],"tags":[],"class_list":["post-47575","post","type-post","status-publish","format-standard","hentry","category-16"],"_links":{"self":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/47575","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/comments?post=47575"}],"version-history":[{"count":0,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/47575\/revisions"}],"wp:attachment":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/media?parent=47575"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/categories?post=47575"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/tags?post=47575"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}