{"id":6466,"date":"2024-08-15T11:27:45","date_gmt":"2024-08-15T03:27:45","guid":{"rendered":"https:\/\/t.n-years.com\/?p=6466"},"modified":"2024-08-15T11:27:45","modified_gmt":"2024-08-15T03:27:45","slug":"smote-%e8%a7%a3%e5%86%b3%e5%88%86%e7%b1%bb%e4%b8%8d%e5%b9%b3%e8%a1%a1%e9%97%ae%e9%a2%98","status":"publish","type":"post","link":"https:\/\/t.n-years.com\/?p=6466","title":{"rendered":"SMOTE \u89e3\u51b3\u5206\u7c7b\u4e0d\u5e73\u8861\u95ee\u9898"},"content":{"rendered":"<blockquote>\n<p>\u975e\u539f\u521b ChatGPT \u95ee\u7b54\u751f\u6210<\/p>\n<\/blockquote>\n<p><strong>SMOTE<\/strong>\uff08Synthetic Minority Over-sampling Technique\uff09\u662f\u4e00\u79cd\u7528\u4e8e\u89e3\u51b3\u5206\u7c7b\u95ee\u9898\u4e2d<strong>\u7c7b\u522b\u4e0d\u5e73\u8861<\/strong>\u7684\u6280\u672f\u3002\u5b83\u901a\u8fc7\u751f\u6210\u5408\u6210\u7684\u5c11\u6570\u7c7b\u6837\u672c\u6765\u589e\u52a0\u5c11\u6570\u7c7b\u6837\u672c\u7684\u6570\u91cf\uff0c\u4ece\u800c\u5e73\u8861\u7c7b\u522b\u5206\u5e03\uff0c\u63d0\u9ad8\u6a21\u578b\u5728\u5c11\u6570\u7c7b\u4e0a\u7684\u8868\u73b0\u3002\u4e0b\u9762\u662f SMOTE \u65b9\u6cd5\u7684\u8be6\u7ec6\u4ecb\u7ecd\uff1a<\/p>\n<h3>SMOTE \u65b9\u6cd5\u7684\u539f\u7406<\/h3>\n<ol>\n<li>\n<p><strong>\u9009\u62e9\u5c11\u6570\u7c7b\u6837\u672c<\/strong>\uff1a<\/p>\n<ul>\n<li>\u9996\u5148\uff0c\u4ece\u6570\u636e\u96c6\u4e2d\u9009\u62e9\u5c5e\u4e8e\u5c11\u6570\u7c7b\u7684\u6837\u672c\u3002<\/li>\n<\/ul>\n<\/li>\n<li>\n<p><strong>\u8ba1\u7b97\u6700\u8fd1\u90bb<\/strong>\uff1a<\/p>\n<ul>\n<li>\u5bf9\u4e8e\u6bcf\u4e2a\u5c11\u6570\u7c7b\u6837\u672c\uff0c\u8ba1\u7b97\u5176\u5728\u7279\u5f81\u7a7a\u95f4\u4e2d\u7684\u6700\u8fd1\u90bb\u3002\u901a\u5e38\u9009\u62e9\u4e00\u4e2a\u56fa\u5b9a\u6570\u91cf\uff08\u5982 k = 5\uff09\u7684\u6700\u8fd1\u90bb\u6837\u672c\u3002<\/li>\n<\/ul>\n<\/li>\n<li>\n<p><strong>\u751f\u6210\u5408\u6210\u6837\u672c<\/strong>\uff1a<\/p>\n<ul>\n<li>\u5bf9\u4e8e\u6bcf\u4e2a\u5c11\u6570\u7c7b\u6837\u672c\uff0c\u968f\u673a\u9009\u62e9\u5176\u6700\u8fd1\u90bb\u4e2d\u7684\u4e00\u4e2a\u6216\u591a\u4e2a\u6837\u672c\u3002<\/li>\n<li>\u901a\u8fc7\u5728\u8be5\u5c11\u6570\u7c7b\u6837\u672c\u4e0e\u5176\u90bb\u5c45\u4e4b\u95f4\u7684\u8fde\u7ebf\u4e0a\u751f\u6210\u65b0\u7684\u5408\u6210\u6837\u672c\u6765\u5b9e\u73b0\u5e73\u8861\u3002\u5408\u6210\u6837\u672c\u662f\u539f\u59cb\u6837\u672c\u4e0e\u5176\u90bb\u5c45\u6837\u672c\u4e4b\u95f4\u7684\u4e00\u79cd\u52a0\u6743\u7ec4\u5408\u3002\u5177\u4f53\u7684\u751f\u6210\u65b9\u6cd5\u662f\uff1a<br \/>\n[ \\text{Synthetic Sample} = \\text{Original Sample} + \\text{rand}(0,1) \\times (\\text{Neighbor Sample} - \\text{Original Sample}) ]<\/li>\n<li>\u5176\u4e2d\uff0c<code>rand(0,1)<\/code> \u662f\u4e00\u4e2a\u5728 0 \u548c 1 \u4e4b\u95f4\u5747\u5300\u5206\u5e03\u7684\u968f\u673a\u6570\u3002<\/li>\n<\/ul>\n<\/li>\n<\/ol>\n<h3>SMOTE \u7684\u4f18\u52bf<\/h3>\n<ul>\n<li><strong>\u7f13\u89e3\u7c7b\u522b\u4e0d\u5e73\u8861<\/strong>\uff1a\u901a\u8fc7\u751f\u6210\u5408\u6210\u6837\u672c\uff0cSMOTE \u53ef\u4ee5\u6709\u6548\u589e\u52a0\u5c11\u6570\u7c7b\u7684\u6837\u672c\u6570\u91cf\uff0c\u4ece\u800c\u63d0\u9ad8\u5206\u7c7b\u6a21\u578b\u5bf9\u5c11\u6570\u7c7b\u7684\u8bc6\u522b\u80fd\u529b\u3002<\/li>\n<li><strong>\u6539\u5584\u6a21\u578b\u6027\u80fd<\/strong>\uff1a\u5728\u8bb8\u591a\u60c5\u51b5\u4e0b\uff0c\u4f7f\u7528 SMOTE \u53ef\u4ee5\u63d0\u9ad8\u6a21\u578b\u7684\u51c6\u786e\u6027\u3001\u7cbe\u786e\u5ea6\u3001\u53ec\u56de\u7387\u548c F1 Score\uff0c\u7279\u522b\u662f\u5728\u5904\u7406\u5c11\u6570\u7c7b\u6837\u672c\u65f6\u3002<\/li>\n<\/ul>\n<h3>SMOTE \u7684\u9650\u5236\u548c\u8003\u8651\u4e8b\u9879<\/h3>\n<ul>\n<li><strong>\u566a\u58f0\u95ee\u9898<\/strong>\uff1aSMOTE \u53ef\u80fd\u4f1a\u5728\u6570\u636e\u96c6\u4e2d\u5f15\u5165\u566a\u58f0\uff0c\u7279\u522b\u662f\u5728\u5c11\u6570\u7c7b\u6837\u672c\u5468\u56f4\u7684\u533a\u57df\u5b58\u5728\u6570\u636e\u7a00\u758f\u7684\u60c5\u51b5\u4e0b\u3002\u751f\u6210\u7684\u5408\u6210\u6837\u672c\u53ef\u80fd\u4f4d\u4e8e\u7279\u5f81\u7a7a\u95f4\u4e2d\u8f83\u4e0d\u5bc6\u96c6\u7684\u533a\u57df\uff0c\u5bfc\u81f4\u6a21\u578b\u7684\u8fc7\u62df\u5408\u3002<\/li>\n<li><strong>\u8ba1\u7b97\u590d\u6742\u6027<\/strong>\uff1aSMOTE \u9700\u8981\u8ba1\u7b97\u6837\u672c\u4e4b\u95f4\u7684\u8ddd\u79bb\uff0c\u7279\u522b\u662f\u5728\u5927\u89c4\u6a21\u6570\u636e\u96c6\u6216\u9ad8\u7ef4\u6570\u636e\u4e2d\uff0c\u8ba1\u7b97\u590d\u6742\u5ea6\u53ef\u80fd\u8f83\u9ad8\u3002<\/li>\n<li><strong>\u6570\u636e\u5206\u5e03<\/strong>\uff1aSMOTE \u5047\u8bbe\u6570\u636e\u5728\u7279\u5f81\u7a7a\u95f4\u4e2d\u662f\u5747\u5300\u5206\u5e03\u7684\uff0c\u4f46\u5728\u5b9e\u9645\u5e94\u7528\u4e2d\uff0c\u6570\u636e\u53ef\u80fd\u5177\u6709\u590d\u6742\u7684\u5206\u5e03\u5f62\u5f0f\uff0cSMOTE \u751f\u6210\u7684\u5408\u6210\u6837\u672c\u53ef\u80fd\u65e0\u6cd5\u5b8c\u5168\u4ee3\u8868\u5c11\u6570\u7c7b\u7684\u771f\u5b9e\u6570\u636e\u5206\u5e03\u3002<\/li>\n<\/ul>\n<h3>\u5b9e\u73b0 SMOTE \u7684\u5de5\u5177<\/h3>\n<ul>\n<li>\n<p><strong>Python \u5e93<\/strong>\uff1a<\/p>\n<ul>\n<li><code>imbalanced-learn<\/code>\uff1a\u8fd9\u662f\u4e00\u4e2a\u4e13\u95e8\u7528\u4e8e\u5904\u7406\u4e0d\u5e73\u8861\u6570\u636e\u96c6\u7684 Python \u5e93\uff0c\u5176\u4e2d\u5305\u542b\u4e86 SMOTE \u7684\u5b9e\u73b0\u3002\u53ef\u4ee5\u901a\u8fc7 <code>pip install imbalanced-learn<\/code> \u5b89\u88c5\u3002<\/li>\n<\/ul>\n<pre><code class=\"language-python\">from imblearn.over_sampling import SMOTE\n\nsmote = SMOTE(sampling_strategy='auto', k_neighbors=5)\nX_resampled, y_resampled = smote.fit_resample(X, y)<\/code><\/pre>\n<\/li>\n<li>\n<p><strong>R \u5305<\/strong>\uff1a<\/p>\n<ul>\n<li><code>DMwR<\/code>\uff1a\u5728 R \u4e2d\uff0c<code>SMOTE<\/code> \u65b9\u6cd5\u53ef\u4ee5\u901a\u8fc7 <code>DMwR<\/code> \u5305\u5b9e\u73b0\u3002<\/li>\n<\/ul>\n<pre><code class=\"language-R\">library(DMwR)\ndata_balanced <- SMOTE(Class ~ ., data = training_data, perc.over = 100, perc.under = 200)<\/code><\/pre>\n<\/li>\n<\/ul>\n<p>\u603b\u4e4b\uff0cSMOTE \u662f\u4e00\u4e2a\u6709\u6548\u7684\u6280\u672f\uff0c\u7528\u4e8e\u5904\u7406\u7c7b\u522b\u4e0d\u5e73\u8861\u95ee\u9898\u3002\u5b83\u901a\u8fc7\u751f\u6210\u5408\u6210\u6837\u672c\u6765\u589e\u52a0\u5c11\u6570\u7c7b\u7684\u6837\u672c\u6570\u91cf\uff0c\u4ece\u800c\u5e2e\u52a9\u63d0\u9ad8\u5206\u7c7b\u6a21\u578b\u5728\u5c11\u6570\u7c7b\u4e0a\u7684\u6027\u80fd\u3002\u7136\u800c\uff0c\u5728\u5e94\u7528 SMOTE \u65f6\u9700\u8981\u8c28\u614e\u8003\u8651\u6570\u636e\u7684\u566a\u58f0\u548c\u8ba1\u7b97\u590d\u6742\u5ea6\u7b49\u95ee\u9898\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u975e\u539f\u521b ChatGPT \u95ee\u7b54\u751f\u6210 SMOTE\uff08Synthetic Minority Over-sampling&#8230; <\/p>\n<div class=\"read-more navbutton\"><a href=\"https:\/\/t.n-years.com\/?p=6466\">\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":[137],"tags":[146,55],"class_list":["post-6466","post","type-post","status-publish","format-standard","hentry","category-llm","tag-146","tag-55"],"_links":{"self":[{"href":"https:\/\/t.n-years.com\/index.php?rest_route=\/wp\/v2\/posts\/6466","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=6466"}],"version-history":[{"count":1,"href":"https:\/\/t.n-years.com\/index.php?rest_route=\/wp\/v2\/posts\/6466\/revisions"}],"predecessor-version":[{"id":6467,"href":"https:\/\/t.n-years.com\/index.php?rest_route=\/wp\/v2\/posts\/6466\/revisions\/6467"}],"wp:attachment":[{"href":"https:\/\/t.n-years.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=6466"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/t.n-years.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=6466"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/t.n-years.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=6466"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}