{"id":6074,"date":"2024-05-29T15:13:46","date_gmt":"2024-05-29T07:13:46","guid":{"rendered":"https:\/\/t.n-years.com\/?p=6074"},"modified":"2024-05-29T15:13:48","modified_gmt":"2024-05-29T07:13:48","slug":"%e7%9b%ae%e6%a0%87%e5%87%bd%e6%95%b0%e6%80%8e%e4%b9%88%e5%85%b7%e4%bd%93%e7%ae%97%e6%b3%95%e5%85%b3%e8%81%94","status":"publish","type":"post","link":"https:\/\/t.n-years.com\/?p=6074","title":{"rendered":"\u76ee\u6807\u51fd\u6570\u600e\u4e48\u5177\u4f53\u7b97\u6cd5\u5173\u8054"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\">\u975e\u539f\u521b\uff0cChatGPT \u95ee\u7b54\u751f\u6210<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u5728\u673a\u5668\u5b66\u4e60\u548c\u7edf\u8ba1\u5b66\u4e2d\uff0c\u76ee\u6807\u51fd\u6570\uff08objective function\uff09\uff0c\u4e5f\u79f0\u4f5c\u635f\u5931\u51fd\u6570\uff08loss function\uff09\u6216\u6210\u672c\u51fd\u6570\uff08cost function\uff09\uff0c\u662f\u7528\u4e8e\u8bc4\u4f30\u6a21\u578b\u6027\u80fd\u7684\u4e00\u4e2a\u6838\u5fc3\u6982\u5ff5\u3002\u76ee\u6807\u51fd\u6570\u5b9a\u4e49\u4e86\u6a21\u578b\u8f93\u51fa\u4e0e\u771f\u5b9e\u6807\u7b7e\u4e4b\u95f4\u7684\u5dee\u8ddd\uff0c\u5e76\u901a\u8fc7\u4f18\u5316\u8be5\u51fd\u6570\u6765\u627e\u5230\u6a21\u578b\u7684\u6700\u4f73\u53c2\u6570\u3002\u4e0d\u540c\u7684\u673a\u5668\u5b66\u4e60\u7b97\u6cd5\u901a\u8fc7\u4e0d\u540c\u7684\u76ee\u6807\u51fd\u6570\u6765\u8fdb\u884c\u4f18\u5316\u3002\u4ee5\u4e0b\u662f\u4e00\u4e9b\u5177\u4f53\u7b97\u6cd5\u548c\u5b83\u4eec\u76f8\u5173\u7684\u76ee\u6807\u51fd\u6570\uff1a<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">1. \u7ebf\u6027\u56de\u5f52 (Linear Regression)<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>\u76ee\u6807\u51fd\u6570<\/strong>: \u5747\u65b9\u8bef\u5dee (Mean Squared Error, MSE)<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">[ \\text{MSE} = \\frac{1}{n} \\sum_{i=1}^{n} (y_i - \\hat{y}_i)^2 ]<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u5728\u7ebf\u6027\u56de\u5f52\u4e2d\uff0c\u76ee\u6807\u662f\u6700\u5c0f\u5316\u9884\u6d4b\u503c ((\\hat{y}_i)) \u548c\u771f\u5b9e\u503c ((y_i)) \u4e4b\u95f4\u7684\u5747\u65b9\u8bef\u5dee\u3002<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">2. \u903b\u8f91\u56de\u5f52 (Logistic Regression)<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>\u76ee\u6807\u51fd\u6570<\/strong>: \u903b\u8f91\u635f\u5931 (Logistic Loss) \u6216\u8005\u5bf9\u6570\u635f\u5931 (Log Loss)<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">[ \\text{Log Loss} = -\\frac{1}{n} \\sum_{i=1}^{n} [y_i \\log(\\hat{y}_i) + (1 - y_i) \\log(1 - \\hat{y}_i)] ]<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u5728\u903b\u8f91\u56de\u5f52\u4e2d\uff0c\u76ee\u6807\u662f\u6700\u5c0f\u5316\u5206\u7c7b\u6982\u7387\u4e0e\u5b9e\u9645\u7c7b\u522b\u4e4b\u95f4\u7684\u5bf9\u6570\u635f\u5931\u3002<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">3. \u652f\u6301\u5411\u91cf\u673a (Support Vector Machine, SVM)<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>\u76ee\u6807\u51fd\u6570<\/strong>: \u5408\u9875\u635f\u5931 (Hinge Loss)<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">[ \\text{Hinge Loss} = \\frac{1}{n} \\sum_{i=1}^{n} \\max(0, 1 - y_i \\cdot \\hat{y}_i) ]<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">SVM \u901a\u8fc7\u6700\u5c0f\u5316\u5408\u9875\u635f\u5931\u548c\u6b63\u5219\u5316\u9879\uff08\u4e3a\u4e86\u627e\u5230\u6700\u5927\u95f4\u9694\u5206\u79bb\u8d85\u5e73\u9762\uff09\u6765\u4f18\u5316\u6a21\u578b\u3002<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">4. KMeans \u805a\u7c7b (KMeans Clustering)<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>\u76ee\u6807\u51fd\u6570<\/strong>: \u60ef\u6027 (Inertia) \u6216\u8005\u7c07\u5185\u5e73\u65b9\u548c (Within-Cluster Sum of Squares, WCSS)<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">[ \\text{Inertia} = \\sum_{i=1}^{n} \\min_{\\mu_k \\in C} || x_i - \\mu_k ||^2 ]<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">KMeans \u901a\u8fc7\u6700\u5c0f\u5316\u6570\u636e\u70b9\u5230\u5176\u6700\u8fd1\u7c07\u4e2d\u5fc3\u7684\u8ddd\u79bb\u5e73\u65b9\u548c\u6765\u8fdb\u884c\u805a\u7c7b\u3002<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">5. \u795e\u7ecf\u7f51\u7edc (Neural Networks)<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>\u76ee\u6807\u51fd\u6570<\/strong>: \u4ea4\u53c9\u71b5\u635f\u5931 (Cross-Entropy Loss) \u6216\u5747\u65b9\u8bef\u5dee (MSE)<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u5bf9\u4e8e\u5206\u7c7b\u4efb\u52a1\uff0c\u5e38\u7528\u4ea4\u53c9\u71b5\u635f\u5931\uff1a<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">[ \\text{Cross-Entropy Loss} = -\\frac{1}{n} \\sum_{i=1}^{n} \\sum_{c=1}^{C} y_{i,c} \\log(\\hat{y}_{i,c}) ]<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u5bf9\u4e8e\u56de\u5f52\u4efb\u52a1\uff0c\u5e38\u7528\u5747\u65b9\u8bef\u5dee\uff1a<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">[ \\text{MSE} = \\frac{1}{n} \\sum_{i=1}^{n} (y_i - \\hat{y}_i)^2 ]<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">6. \u51b3\u7b56\u6811 (Decision Trees)<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>\u76ee\u6807\u51fd\u6570<\/strong>: \u57fa\u5c3c\u4e0d\u7eaf\u5ea6 (Gini Impurity) \u6216\u4fe1\u606f\u589e\u76ca (Information Gain)<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u57fa\u5c3c\u4e0d\u7eaf\u5ea6\uff1a<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">[ \\text{Gini Impurity} = 1 - \\sum_{k=1}^{K} p_k^2 ]<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u4fe1\u606f\u589e\u76ca\u57fa\u4e8e\u71b5 (Entropy)\uff1a<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">[ \\text{Entropy} = - \\sum_{k=1}^{K} p_k \\log(p_k) ]<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u51b3\u7b56\u6811\u901a\u8fc7\u6700\u5927\u5316\u4fe1\u606f\u589e\u76ca\u6216\u8005\u6700\u5c0f\u5316\u57fa\u5c3c\u4e0d\u7eaf\u5ea6\u6765\u9009\u62e9\u6700\u4f73\u5206\u88c2\u3002<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">\u76ee\u6807\u51fd\u6570\u7684\u4f18\u5316<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">\u4e3a\u4e86\u627e\u5230\u4f7f\u76ee\u6807\u51fd\u6570\u503c\u6700\u5c0f\uff08\u6216\u6700\u5927\uff09\u7684\u6a21\u578b\u53c2\u6570\uff0c\u5404\u79cd\u7b97\u6cd5\u4f7f\u7528\u4e86\u4e0d\u540c\u7684\u4f18\u5316\u6280\u672f\uff1a<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>\u68af\u5ea6\u4e0b\u964d\u6cd5 (Gradient Descent)<\/strong>: \u7528\u4e8e\u8bb8\u591a\u4f18\u5316\u95ee\u9898\uff0c\u5982\u7ebf\u6027\u56de\u5f52\u3001\u903b\u8f91\u56de\u5f52\u548c\u795e\u7ecf\u7f51\u7edc\uff0c\u901a\u8fc7\u8fed\u4ee3\u66f4\u65b0\u53c2\u6570\u6765\u6700\u5c0f\u5316\u76ee\u6807\u51fd\u6570\u3002<\/li>\n\n\n\n<li><strong>\u4e8c\u6b21\u89c4\u5212 (Quadratic Programming)<\/strong>: \u7528\u4e8e SVM\uff0c\u901a\u8fc7\u89e3\u51b3\u4e8c\u6b21\u4f18\u5316\u95ee\u9898\u6765\u627e\u5230\u6700\u4f18\u5206\u79bb\u8d85\u5e73\u9762\u3002<\/li>\n\n\n\n<li><strong>EM \u7b97\u6cd5 (Expectation-Maximization Algorithm)<\/strong>: \u7528\u4e8e\u9ad8\u65af\u6df7\u5408\u6a21\u578b (Gaussian Mixture Models) \u7b49\uff0c\u901a\u8fc7\u8fed\u4ee3\u671f\u671b\u6b65\u9aa4\u548c\u6700\u5927\u5316\u6b65\u9aa4\u6765\u4f18\u5316\u53c2\u6570\u3002<\/li>\n\n\n\n<li><strong>\u968f\u673a\u4f18\u5316 (Stochastic Optimization)<\/strong>: \u7528\u4e8e\u5927\u578b\u6570\u636e\u96c6\uff0c\u901a\u8fc7\u5728\u6bcf\u6b21\u8fed\u4ee3\u4e2d\u4ec5\u4f7f\u7528\u90e8\u5206\u6570\u636e\u6765\u66f4\u65b0\u53c2\u6570\uff0c\u4f8b\u5982\u968f\u673a\u68af\u5ea6\u4e0b\u964d\u6cd5 (Stochastic Gradient Descent)\u3002<\/li>\n<\/ul>\n\n\n\n<h3 class=\"wp-block-heading\">\u5177\u4f53\u4f8b\u5b50\uff1aKMeans \u805a\u7c7b<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">\u8ba9\u6211\u4eec\u8be6\u7ec6\u89e3\u91ca KMeans \u805a\u7c7b\u7684\u76ee\u6807\u51fd\u6570\u548c\u4f18\u5316\u8fc7\u7a0b\uff1a<\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li><strong>\u76ee\u6807\u51fd\u6570<\/strong>: \u6700\u5c0f\u5316\u7c07\u5185\u5e73\u65b9\u548c (Within-Cluster Sum of Squares, WCSS)<\/li>\n<\/ol>\n\n\n\n<p class=\"wp-block-paragraph\">[ \\text{WCSS} = \\sum_{i=1}^{n} \\min_{\\mu_k \\in C} || x_i - \\mu_k ||^2 ]<\/p>\n\n\n\n<ol class=\"wp-block-list\" start=\"2\">\n<li><strong>\u7b97\u6cd5\u6b65\u9aa4<\/strong>:\n<ul class=\"wp-block-list\">\n<li>\u521d\u59cb\u5316 ( K ) \u4e2a\u7c07\u4e2d\u5fc3\uff08\u968f\u673a\u9009\u62e9\u6570\u636e\u70b9\uff09\u3002<\/li>\n\n\n\n<li>\u91cd\u590d\u4ee5\u4e0b\u6b65\u9aa4\u76f4\u5230\u7c07\u4e2d\u5fc3\u4e0d\u518d\u53d8\u5316\uff1a<\/li>\n\n\n\n<li><strong>\u5206\u914d\u6b65\u9aa4<\/strong>: \u5c06\u6bcf\u4e2a\u6570\u636e\u70b9\u5206\u914d\u5230\u6700\u8fd1\u7684\u7c07\u4e2d\u5fc3\u3002<\/li>\n\n\n\n<li><strong>\u66f4\u65b0\u6b65\u9aa4<\/strong>: \u91cd\u65b0\u8ba1\u7b97\u6bcf\u4e2a\u7c07\u7684\u4e2d\u5fc3\u4e3a\u5f53\u524d\u7c07\u4e2d\u6240\u6709\u70b9\u7684\u5e73\u5747\u503c\u3002<\/li>\n<\/ul>\n<\/li>\n\n\n\n<li><strong>\u5177\u4f53\u5b9e\u73b0<\/strong>\uff1a<\/li>\n<\/ol>\n\n\n\n<pre class=\"wp-block-code\"><code>import numpy as np\nimport matplotlib.pyplot as plt\nfrom sklearn.cluster import KMeans\n\n# \u751f\u6210\u793a\u4f8b\u6570\u636e\nnp.random.seed(42)\nX = np.vstack(&#91;\n    np.random.normal(loc=&#91;2, 2], scale=0.5, size=(100, 2)),\n    np.random.normal(loc=&#91;-2, -2], scale=0.5, size=(100, 2)),\n    np.random.normal(loc=&#91;2, -2], scale=0.5, size=(100, 2)),\n    np.random.normal(loc=&#91;-2, 2], scale=0.5, size=(100, 2))\n])\n\n# \u4f7f\u7528 KMeans \u8fdb\u884c\u805a\u7c7b\nkmeans = KMeans(n_clusters=4, random_state=42)\nkmeans.fit(X)\nlabels = kmeans.labels_\ncenters = kmeans.cluster_centers_\n\n# \u53ef\u89c6\u5316\u805a\u7c7b\u7ed3\u679c\nplt.figure(figsize=(8, 6))\nplt.scatter(X&#91;:, 0], X&#91;:, 1], c=labels, cmap='viridis', marker='o', alpha=0.5, label='Data Points')\nplt.scatter(centers&#91;:, 0], centers&#91;:, 1], c='red', marker='x', s=100, label='Cluster Centers')\nplt.title('KMeans Clustering Example')\nplt.xlabel('Feature 1')\nplt.ylabel('Feature 2')\nplt.legend()\nplt.show()<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">\u901a\u8fc7\u4e0a\u9762\u7684\u4f8b\u5b50\uff0c\u53ef\u4ee5\u770b\u5230\u5982\u4f55\u5b9a\u4e49\u548c\u4f18\u5316\u76ee\u6807\u51fd\u6570\u6765\u5b9e\u73b0\u4e0d\u540c\u7684\u673a\u5668\u5b66\u4e60\u7b97\u6cd5\u3002\u6bcf\u4e2a\u7b97\u6cd5\u901a\u8fc7\u6700\u5c0f\u5316\u6216\u6700\u5927\u5316\u5176\u7279\u5b9a\u7684\u76ee\u6807\u51fd\u6570\u6765\u627e\u5230\u6700\u4f73\u6a21\u578b\u53c2\u6570\uff0c\u4ece\u800c\u5b9e\u73b0\u5bf9\u6570\u636e\u7684\u6709\u6548\u5efa\u6a21\u548c\u9884\u6d4b\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u975e\u539f\u521b\uff0cChatGPT \u95ee\u7b54\u751f\u6210 \u5728\u673a\u5668\u5b66\u4e60\u548c\u7edf\u8ba1\u5b66\u4e2d\uff0c\u76ee\u6807\u51fd\u6570\uff08objective function\uff09\uff0c\u4e5f\u79f0&#8230; <\/p>\n<div class=\"read-more navbutton\"><a href=\"https:\/\/t.n-years.com\/?p=6074\">\u9605\u8bfb\u66f4\u591a<i class=\"fa fa-angle-double-right\"><\/i><\/a><\/div>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[5],"tags":[],"class_list":["post-6074","post","type-post","status-publish","format-standard","hentry","category-5"],"_links":{"self":[{"href":"https:\/\/t.n-years.com\/index.php?rest_route=\/wp\/v2\/posts\/6074","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/t.n-years.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/t.n-years.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/t.n-years.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/t.n-years.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=6074"}],"version-history":[{"count":1,"href":"https:\/\/t.n-years.com\/index.php?rest_route=\/wp\/v2\/posts\/6074\/revisions"}],"predecessor-version":[{"id":6075,"href":"https:\/\/t.n-years.com\/index.php?rest_route=\/wp\/v2\/posts\/6074\/revisions\/6075"}],"wp:attachment":[{"href":"https:\/\/t.n-years.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=6074"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/t.n-years.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=6074"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/t.n-years.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=6074"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}