{"id":554110,"date":"2025-04-03T07:45:43","date_gmt":"2025-04-03T06:45:43","guid":{"rendered":"https:\/\/blog.jetbrains.com\/?post_type=pycharm&#038;p=554110"},"modified":"2025-04-03T07:45:56","modified_gmt":"2025-04-03T06:45:56","slug":"anomaly-detection-in-machine-learning","status":"publish","type":"pycharm","link":"https:\/\/blog.jetbrains.com\/zh-hans\/pycharm\/2025\/04\/anomaly-detection-in-machine-learning\/","title":{"rendered":"\u5728\u673a\u5668\u5b66\u4e60\u4e2d\u4f7f\u7528 Python \u8fdb\u884c\u5f02\u5e38\u503c\u68c0\u6d4b"},"content":{"rendered":"<figure class=\"wp-block-image size-full\"><img decoding=\"async\" loading=\"lazy\" class=\"alignnone wp-image-556318 size-full\" src=\"https:\/\/blog.jetbrains.com\/wp-content\/uploads\/2025\/04\/pc-featured_blog_1280x720_en-1.png\" alt=\"\" width=\"2560\" height=\"1440\" \/><\/figure>\n<p>\u8fd1\u5e74\u6765\uff0c\u6211\u4eec\u7684\u8bb8\u591a\u5e94\u7528\u7a0b\u5e8f\u90fd\u7531\u6211\u4eec\u80fd\u591f\u6536\u96c6\u548c\u5904\u7406\u7684\u5927\u91cf\u6570\u636e\u9a71\u52a8\u3002 \u6709\u4eba\u53ef\u80fd\u4f1a\u8bf4\u6211\u4eec\u6b63\u5904\u4e8e\u6570\u636e\u65f6\u4ee3\u3002 \u5904\u7406\u5982\u6b64\u5927\u91cf\u6570\u636e\u7684\u4e00\u4e2a\u91cd\u8981\u65b9\u9762\u662f<strong>\u5f02\u5e38\u503c\u68c0\u6d4b<\/strong> \u2013 \u8fd9\u4e2a\u8fc7\u7a0b\u4f7f\u6211\u4eec\u80fd\u591f\u8bc6\u522b\u79bb\u7fa4\u503c\u3001\u8d85\u51fa\u9884\u671f\u8303\u56f4\u7684\u6570\u636e\u5e76\u5c55\u73b0\u53cd\u5e38\u7684\u884c\u4e3a\u3002 \u5728\u79d1\u5b66\u7814\u7a76\u4e2d\uff0c\u5f02\u5e38\u503c\u6570\u636e\u70b9\u53ef\u80fd\u662f\u6280\u672f\u95ee\u9898\u7684\u539f\u56e0\uff0c\u5728\u5f97\u51fa\u7ed3\u8bba\u65f6\u53ef\u80fd\u9700\u8981\u820d\u5f03\uff0c\u6216\u8005\uff0c\u4e5f\u53ef\u80fd\u5e26\u6765\u65b0\u7684\u53d1\u73b0\u3002<\/p>\n<p>\u5728\u8fd9\u7bc7\u535a\u6587\u4e2d\uff0c\u6211\u4eec\u5c06\u5206\u6790\u4e3a\u4ec0\u4e48\u4f7f\u7528\u673a\u5668\u5b66\u4e60\u8fdb\u884c\u5f02\u5e38\u503c\u68c0\u6d4b\u5f88\u6709\u5e2e\u52a9\uff0c\u5e76\u63a2\u7d22\u4f7f\u7528 Python \u68c0\u6d4b\u5f02\u5e38\u503c\u7684\u5173\u952e\u6280\u672f\u3002 \u60a8\u5c06\u5b66\u4e60\u5982\u4f55\u5b9e\u73b0 OneClassSVM \u548c\u5b64\u7acb\u68ee\u6797\u7b49\u6d41\u884c\u65b9\u6cd5\uff0c\u67e5\u770b\u76f4\u89c2\u5448\u73b0\u8fd9\u4e9b\u7ed3\u679c\u7684\u793a\u4f8b\u5e76\u4e86\u89e3\u5982\u4f55\u5c06\u5b83\u4eec\u5e94\u7528\u4e8e\u5b9e\u9645\u95ee\u9898\u3002<\/p>\n<h2 class=\"wp-block-heading\">\u5f02\u5e38\u503c\u68c0\u6d4b\u5728\u54ea\u91cc\u4f7f\u7528\uff1f<\/h2>\n<p>\u5f02\u5e38\u503c\u68c0\u6d4b\u4e5f\u662f\u73b0\u4ee3\u5546\u4e1a\u667a\u80fd\u7684\u91cd\u8981\u7ec4\u6210\u90e8\u5206\uff0c\u56e0\u4e3a\u5b83\u63d0\u4f9b\u4e86\u53ef\u80fd\u51fa\u9519\u7684\u5730\u65b9\u7684\u6d1e\u5bdf\uff0c\u4e5f\u53ef\u80fd\u53d1\u73b0\u6f5c\u5728\u95ee\u9898\u3002 \u4ee5\u4e0b\u662f\u5728\u73b0\u4ee3\u5546\u4e1a\u4e2d\u4f7f\u7528\u5f02\u5e38\u503c\u68c0\u6d4b\u7684\u4e00\u4e9b\u793a\u4f8b\u3002<\/p>\n<p><strong>\u5b89\u5168\u8b66\u62a5<\/strong><\/p>\n<p>\u67d0\u4e9b\u7f51\u7edc\u5b89\u5168\u653b\u51fb\u53ef\u4ee5\u901a\u8fc7\u5f02\u5e38\u503c\u68c0\u6d4b\u53d1\u73b0\uff0c\u4f8b\u5982\uff0c\u8bf7\u6c42\u91cf\u6fc0\u589e\u53ef\u80fd\u8868\u793a <a href=\"https:\/\/en.wikipedia.org\/wiki\/Denial-of-service_attack\" target=\"_blank\" rel=\"noopener\">DDoS \u653b\u51fb<\/a>\uff0c\u53ef\u7591\u767b\u5f55\u884c\u4e3a\uff08\u5982\u591a\u6b21\u5c1d\u8bd5\u5931\u8d25\uff09\u53ef\u80fd\u8868\u793a\u672a\u6388\u6743\u8bbf\u95ee\u3002 \u68c0\u6d4b\u5230\u53ef\u7591\u7528\u6237\u884c\u4e3a\u53ef\u80fd\u8868\u793a\u6f5c\u5728\u7f51\u7edc\u5b89\u5168\u5a01\u80c1\uff0c\u516c\u53f8\u53ef\u4ee5\u91c7\u53d6\u76f8\u5e94\u63aa\u65bd\u9632\u6b62\u6216\u5c3d\u53ef\u80fd\u51cf\u5c11\u635f\u5931\u3002<\/p>\n<p><strong>\u6b3a\u8bc8\u68c0\u6d4b<\/strong><\/p>\n<p>\u4f8b\u5982\uff0c\u5728\u91d1\u878d\u7ec4\u7ec7\u4e2d\uff0c\u94f6\u884c\u53ef\u4ee5\u4f7f\u7528\u5f02\u5e38\u503c\u68c0\u6d4b\u7a81\u51fa\u663e\u793a\u53ef\u7591\u8d26\u6237\u6d3b\u52a8\uff0c\u8fd9\u53ef\u80fd\u662f\u6d17\u94b1\u6216\u8eab\u4efd\u76d7\u7a83\u7b49\u975e\u6cd5\u6d3b\u52a8\u7684\u8ff9\u8c61\u3002 \u53ef\u7591\u4ea4\u6613\u4e5f\u53ef\u80fd\u8868\u793a\u4fe1\u7528\u5361\u6b3a\u8bc8\u3002<\/p>\n<p><strong>\u53ef\u89c2\u6d4b\u6027<\/strong><\/p>\n<p>Web \u670d\u52a1\u7684\u5e38\u89c1\u505a\u6cd5\u4e4b\u4e00\u662f\uff0c\u5728\u7cfb\u7edf\u51fa\u73b0\u5f02\u5e38\u884c\u4e3a\u65f6\u6536\u96c6\u670d\u52a1\u7684\u5b9e\u65f6\u6027\u80fd\u6307\u6807\u3002 \u4f8b\u5982\uff0c\u5185\u5b58\u4f7f\u7528\u91cf\u6fc0\u589e\u53ef\u80fd\u8868\u660e\u7cfb\u7edf\u4e2d\u7684\u67d0\u4e9b\u4e1c\u897f\u6ca1\u6709\u6b63\u5e38\u8fd0\u884c\uff0c\u5de5\u7a0b\u5e08\u53ef\u80fd\u9700\u8981\u7acb\u5373\u89e3\u51b3\uff0c\u4ee5\u907f\u514d\u670d\u52a1\u4e2d\u65ad\u3002<\/p>\n<h2 class=\"wp-block-heading\">\u4e3a\u4ec0\u4e48\u8981\u4f7f\u7528\u673a\u5668\u5b66\u4e60\u8fdb\u884c\u5f02\u5e38\u503c\u68c0\u6d4b\uff1f<\/h2>\n<p>\u867d\u7136\u4f20\u7edf\u7edf\u8ba1\u65b9\u6cd5\u4e5f\u53ef\u4ee5\u5e2e\u52a9\u53d1\u73b0\u79bb\u7fa4\u503c\uff0c\u4f46\u4f7f\u7528\u673a\u5668\u5b66\u4e60\u8fdb\u884c\u5f02\u5e38\u503c\u68c0\u6d4b\u5df2\u7ecf\u5e26\u6765\u4e86\u98a0\u8986\u6027\u53d8\u5316\u3002 \u5229\u7528\u673a\u5668\u5b66\u4e60\u7b97\u6cd5\uff0c\u53ef\u4ee5\u4e00\u6b21\u6027\u5206\u6790\u66f4\u590d\u6742\u7684\u6570\u636e\uff08\u4f8b\u5982\uff0c\u5177\u6709\u591a\u4e2a\u53c2\u6570\u7684\u6570\u636e\uff09\u3002 \u673a\u5668\u5b66\u4e60\u6280\u672f\u8fd8\u63d0\u4f9b\u4e86\u4e00\u79cd\u5206\u6790\u5206\u7c7b\u6570\u636e\u7684\u65b9\u5f0f\uff0c\u4f7f\u7528\u4f20\u7edf\u7edf\u8ba1\u65b9\u6cd5\u4e0d\u5bb9\u6613\u5206\u6790\u8fd9\u4e9b\u6570\u636e\uff0c\u56e0\u4e3a\u4f20\u7edf\u7edf\u8ba1\u65b9\u6cd5\u66f4\u9002\u5408\u6570\u503c\u6570\u636e\u3002<\/p>\n<p>\u5f88\u591a\u65f6\u5019\uff0c\u8fd9\u4e9b\u5f02\u5e38\u503c\u68c0\u6d4b\u7b97\u6cd5\u90fd\u7ecf\u8fc7\u7f16\u7a0b\uff0c\u53ef\u4ee5\u4f5c\u4e3a\u5e94\u7528\u7a0b\u5e8f\u90e8\u7f72\uff08\u8bf7\u53c2\u9605\u6211\u4eec\u7684<a href=\"https:\/\/blog.jetbrains.com\/pycharm\/2024\/09\/how-to-use-fastapi-for-machine-learning\/\">\u5982\u4f55\u5c06 FastAPI \u7528\u4e8e\u673a\u5668\u5b66\u4e60<\/a>\u6559\u7a0b\uff09\uff0c\u5e76\u6309\u8981\u6c42\u6216\u9884\u5b9a\u65f6\u95f4\u95f4\u9694\u8fd0\u884c\u4ee5\u68c0\u6d4b\u5f02\u5e38\u503c\u3002 \u8fd9\u610f\u5473\u7740\u5b83\u4eec\u53ef\u4ee5\u4fc3\u4f7f\u516c\u53f8\u5185\u90e8\u7684\u7acb\u5373\u884c\u52a8\uff0c\u4e5f\u53ef\u4ee5\u7528\u4f5c\u62a5\u544a\u5de5\u5177\u4f9b\u5546\u4e1a\u667a\u80fd\u56e2\u961f\u5ba1\u67e5\u548c\u8c03\u6574\u6218\u7565\u3002<\/p>\n<h2 class=\"wp-block-heading\">\u5f02\u5e38\u503c\u68c0\u6d4b\u6280\u672f\u548c\u7b97\u6cd5\u7684\u7c7b\u578b<\/h2>\n<p>\u5f02\u5e38\u503c\u68c0\u6d4b\u901a\u5e38\u6709\u4e24\u79cd\u4e3b\u8981\u7c7b\u578b\uff1a\u79bb\u7fa4\u503c\u68c0\u6d4b\u548c\u65b0\u9896\u6027\u68c0\u6d4b\u3002<\/p>\n<p><strong>\u79bb\u7fa4\u503c\u68c0\u6d4b<\/strong><\/p>\n<p>\u79bb\u7fa4\u503c\u68c0\u6d4b\u6709\u65f6\u4e5f\u88ab\u79f0\u4e3a<strong>\u65e0\u76d1\u7763<\/strong>\u5f02\u5e38\u503c\u68c0\u6d4b\uff0c\u56e0\u4e3a\u5b83\u5047\u8bbe\u5728\u8bad\u7ec3\u6570\u636e\u4e2d\u5b58\u5728\u4e00\u4e9b\u672a\u68c0\u51fa\u7684\u5f02\u5e38\u503c\uff08\u56e0\u6b64\u672a\u6807\u8bb0\uff09\uff0c\u5e76\u4e14\u65b9\u5f0f\u662f\u4f7f\u7528\u65e0\u76d1\u7763\u673a\u5668\u5b66\u4e60\u7b97\u6cd5\u5c06\u5f02\u5e38\u503c\u6311\u51fa\u3002 \u7b97\u6cd5\u5305\u62ec<a href=\"https:\/\/scikit-learn.org\/stable\/modules\/outlier_detection.html\" target=\"_blank\" rel=\"noopener\">\u4e00\u7c7b\u652f\u6301\u5411\u91cf\u673a (SVM)\u3001\u5b64\u7acb\u68ee\u6797\u3001\u5c40\u90e8\u79bb\u7fa4\u56e0\u5b50\u548c\u692d\u5706\u5305\u7edc<\/a>\u7b49\u3002<\/p>\n<p><strong>\u65b0\u9896\u6027\u68c0\u6d4b<\/strong><\/p>\n<p>\u65b0\u9896\u6027\u68c0\u6d4b\u6709\u65f6\u88ab\u79f0\u4e3a<strong>\u534a\u76d1\u7763<\/strong>\u5f02\u5e38\u503c\u68c0\u6d4b\u3002 \u7531\u4e8e\u6211\u4eec\u5047\u8bbe\u6240\u6709\u8bad\u7ec3\u6570\u636e\u5e76\u975e\u5b8c\u5168\u7531\u5f02\u5e38\u503c\u7ec4\u6210\uff0c\u5b83\u4eec\u90fd\u88ab\u6807\u8bb0\u4e3a\u6b63\u5e38\u3002 \u76ee\u6807\u662f\u68c0\u6d4b\u65b0\u6570\u636e\u662f\u5426\u4e3a\u5f02\u5e38\u503c\uff0c\u8fd9\u6709\u65f6\u4e5f\u79f0\u4e3a\u65b0\u9896\u6027\u3002 \u53ea\u8981\u8bad\u7ec3\u6570\u636e\u4e2d\u6ca1\u6709\u5f02\u5e38\u503c\uff0c\u7528\u4e8e\u79bb\u7fa4\u503c\u68c0\u6d4b\u7684\u7b97\u6cd5\u4e5f\u53ef\u4ee5\u7528\u4e8e\u65b0\u9896\u6027\u68c0\u6d4b\u3002<\/p>\n<p>\u9664\u4e86\u4e0a\u8ff0\u79bb\u7fa4\u503c\u68c0\u6d4b\u548c\u65b0\u9896\u6027\u68c0\u6d4b\u5916\uff0c\u5728\u65f6\u95f4\u5e8f\u5217\u6570\u636e\u4e2d\u8fdb\u884c\u5f02\u5e38\u503c\u68c0\u6d4b\u4e5f\u5f88\u5e38\u89c1\u3002 \u4e0d\u8fc7\uff0c\u7531\u4e8e\u65f6\u95f4\u5e8f\u5217\u6570\u636e\u6240\u7528\u65b9\u5f0f\u548c\u6280\u672f\u901a\u5e38\u4e0e\u4e0a\u8ff0\u7b97\u6cd5\u4e0d\u540c\uff0c\u6211\u4eec\u5c06\u5728\u4ee5\u540e\u8be6\u7ec6\u8ba8\u8bba\u3002<\/p>\n<h2 class=\"wp-block-heading\">\u4ee3\u7801\u793a\u4f8b\uff1a\u67e5\u627e\u8702\u5de2\u6570\u636e\u96c6\u4e2d\u7684\u5f02\u5e38\u503c<\/h2>\n<p>\u5728\u8fd9\u7bc7\u535a\u6587\u4e2d\uff0c\u6211\u4eec\u5c06\u4ee5<a href=\"https:\/\/www.kaggle.com\/datasets\/vivovinco\/beehives\/data\" target=\"_blank\" rel=\"noopener\">\u8702\u5de2\u6570\u636e\u96c6<\/a>\u4e3a\u4f8b\uff0c\u68c0\u6d4b\u8702\u5de2\u4e2d\u7684\u5f02\u5e38\u503c\u3002 \u8fd9\u4e2a\u6570\u636e\u96c6\u63d0\u4f9b\u4e86\u8702\u5de2\u5728\u4e0d\u540c\u65f6\u95f4\u7684\u5404\u79cd\u6d4b\u91cf\u6570\u636e\uff08\u5305\u62ec\u8702\u5de2\u7684\u6e29\u5ea6\u548c\u76f8\u5bf9\u6e7f\u5ea6\uff09\u3002<\/p>\n<p>\u63a5\u4e0b\u6765\uff0c\u6211\u4eec\u5c06\u5c55\u793a\u4e24\u79cd\u622a\u7136\u4e0d\u540c\u7684\u5f02\u5e38\u503c\u68c0\u6d4b\u65b9\u6cd5\u3002 \u5b83\u4eec\u5206\u522b\u662f\u57fa\u4e8e\u652f\u6301\u5411\u91cf\u673a\u6280\u672f\u7684 OneClassSVM\uff08\u6211\u4eec\u5c06\u4f7f\u7528\u5b83\u6765\u7ed8\u5236\u51b3\u7b56\u8fb9\u754c\uff09\uff0c\u4ee5\u53ca\u5b64\u7acb\u68ee\u6797\uff0c\u8fd9\u662f\u4e00\u79cd\u7c7b\u4f3c\u4e8e\u968f\u673a\u68ee\u6797\u7684\u96c6\u6210\u65b9\u6cd5\u3002<\/p>\n<h3 class=\"wp-block-heading\">\u793a\u4f8b\uff1aOneClassSVM<\/h3>\n<p>\u5728\u7b2c\u4e00\u4e2a\u4f8b\u5b50\u4e2d\uff0c\u6211\u4eec\u5c06\u4f7f\u7528\u8702\u5de2 17 \u7684\u6570\u636e\uff0c\u5047\u8bbe\u871c\u8702\u4f1a\u5c06\u8702\u5de2\u4fdd\u6301\u5728\u4e00\u4e2a\u5bf9\u8702\u7fa4\u6765\u8bf4\u6052\u5b9a\u8212\u9002\u7684\u73af\u5883\u4e2d\u3002\u6211\u4eec\u53ef\u4ee5\u770b\u770b\u8fd9\u662f\u5426\u5c5e\u5b9e\uff0c\u4ee5\u53ca\u8702\u5de2\u662f\u5426\u4f1a\u7ecf\u5386\u5f02\u5e38\u7684\u6e29\u5ea6\u548c\u76f8\u5bf9\u6e7f\u5ea6\u6c34\u5e73\u3002 \u6211\u4eec\u5c06\u4f7f\u7528 <a href=\"https:\/\/scikit-learn.org\/stable\/modules\/generated\/sklearn.svm.OneClassSVM.html\" target=\"_blank\" rel=\"noopener\">OneClassSVM<\/a> \u62df\u5408\u6570\u636e\u5e76\u67e5\u770b\u6563\u70b9\u56fe\u4e0a\u7684\u51b3\u7b56\u8fb9\u754c\u3002<\/p>\n<p>OneClassSVM \u4e2d\u7684 SVM \u4ee3\u8868<a href=\"https:\/\/scikit-learn.org\/stable\/modules\/svm.html#svm\" target=\"_blank\" rel=\"noopener\">\u652f\u6301\u5411\u91cf\u673a<\/a>\uff0c\u8fd9\u662f\u4e00\u79cd\u7528\u4e8e\u5206\u7c7b\u548c\u56de\u5f52\u7684\u6d41\u884c\u673a\u5668\u5b66\u4e60\u7b97\u6cd5\u3002 \u867d\u7136\u652f\u6301\u5411\u91cf\u673a\u53ef\u7528\u4e8e<a href=\"https:\/\/scikit-learn.org\/stable\/modules\/svm.html#mathematical-formulation\" target=\"_blank\" rel=\"noopener\">\u5bf9\u9ad8\u7ef4\u6570\u636e\u70b9\u5206\u7c7b<\/a>\uff0c\u4f46\u901a\u8fc7\u9009\u62e9\u4e00\u4e2a\u5185\u6838\u4e0e\u4e00\u4e2a\u6807\u91cf\u53c2\u6570\u5b9a\u4e49\u8fb9\u754c\uff0c\u6211\u4eec\u53ef\u4ee5\u521b\u5efa\u4e00\u4e2a\u5305\u542b\u5927\u591a\u6570\u6570\u636e\u70b9\uff08\u6b63\u5e38\u6570\u636e\uff09\u7684\u51b3\u7b56\u8fb9\u754c\uff0c\u540c\u65f6\u4fdd\u7559\u8fb9\u754c\u5916\u7684\u5c11\u91cf\u5f02\u5e38\u503c\uff0c\u8868\u793a\u53d1\u73b0\u65b0\u5f02\u5e38\u503c\u7684\u6982\u7387 (nu)\u3002 Scholkopf \u7b49\u4f5c\u8005\u5728\u9898\u4e3a <a href=\"https:\/\/www.microsoft.com\/en-us\/research\/wp-content\/uploads\/2016\/02\/tr-99-87.pdf\" target=\"_blank\" rel=\"noopener\"><em>Estimating the Support of a High-Dimensional Distribution<\/em><\/a> \u7684\u8bba\u6587\u4e2d\u8bb2\u89e3\u4e86\u4f7f\u7528\u652f\u6301\u5411\u91cf\u673a\u8fdb\u884c\u5f02\u5e38\u503c\u68c0\u6d4b\u7684\u65b9\u6cd5\u3002<\/p>\n<h4 class=\"wp-block-heading\"><strong>1. \u5f00\u59cb\u4e00\u4e2a Jupyter \u9879\u76ee<\/strong><\/h4>\n<p>\u5728 PyCharm (Professional 2024.2.2) \u4e2d\u5f00\u59cb<a href=\"https:\/\/www.jetbrains.com.cn\/help\/pycharm\/creating-and-running-your-first-python-project.html\" target=\"_blank\" rel=\"noopener\">\u65b0\u9879\u76ee<\/a>\u65f6\uff0c\u9009\u62e9 <em>Python<\/em> \u4e0b\u7684 <em>Jupyter<\/em>\u3002<\/p>\n<div class=\"buttons\">\n<div class=\"buttons__row\"><a class=\"btn\" href=\"https:\/\/www.jetbrains.com.cn\/pycharm\/data-science\/\" target=\"\" rel=\"noopener\">\u514d\u8d39\u5f00\u59cb\u4f7f\u7528 PyCharm Pro<\/a><\/div>\n<\/div>\n<figure class=\"wp-block-image size-full\"><img decoding=\"async\" loading=\"lazy\" class=\"wp-image-537600\" src=\"https:\/\/blog.jetbrains.com\/wp-content\/uploads\/2025\/01\/image-34.png\" alt=\"\u5728 PyCharm \u4e2d\u5f00\u59cb Jupyter \u9879\u76ee\" width=\"1592\" height=\"1292\" \/><\/figure>\n<p>\u5728 PyCharm \u4e2d\u4f7f\u7528 <a href=\"https:\/\/www.jetbrains.com.cn\/help\/pycharm\/scientific-mode.html\" target=\"_blank\" rel=\"noopener\">Jupyter \u9879\u76ee<\/a>\uff08\u4ee5\u524d\u4e5f\u79f0\u4e3a\u79d1\u5b66\u9879\u76ee\uff09\u7684\u597d\u5904\u662f\uff0c\u5b83\u4f1a\u751f\u6210\u4e00\u4e2a\u6587\u4ef6\u7ed3\u6784\uff0c\u5305\u62ec\u4e00\u4e2a\u7528\u4e8e\u5b58\u50a8\u6570\u636e\u7684\u6587\u4ef6\u5939\u548c\u4e00\u4e2a\u7528\u4e8e\u5b58\u50a8\u6240\u6709 <a href=\"https:\/\/www.jetbrains.com.cn\/help\/pycharm\/jupyter-notebook-support.html\" target=\"_blank\" rel=\"noopener\">Jupyter Notebook<\/a> \u7684\u6587\u4ef6\u5939\uff0c\u56e0\u6b64\u60a8\u53ef\u4ee5\u5c06\u6240\u6709\u5b9e\u9a8c\u96c6\u4e2d\u5728\u4e00\u4e2a\u5730\u65b9\u3002\u00a0<\/p>\n<figure class=\"wp-block-image size-full\"><img decoding=\"async\" loading=\"lazy\" class=\"wp-image-537611\" src=\"https:\/\/blog.jetbrains.com\/wp-content\/uploads\/2025\/01\/image-35.png\" alt=\"PyCharm \u4e2d\u7684 Jupyter \u9879\u76ee\" width=\"996\" height=\"886\" \/><\/figure>\n<p>\u53e6\u4e00\u4e2a\u5de8\u5927\u7684\u597d\u5904\u662f\uff0c\u6211\u4eec\u53ef\u4ee5\u4f7f\u7528 <a href=\"https:\/\/matplotlib.org\/index.html\" target=\"_blank\" rel=\"noopener\">Matplotlib<\/a> \u975e\u5e38\u8f7b\u677e\u5730\u5448\u73b0\u56fe\u5f62\u3002 \u8fd9\u5c06\u5728\u4e0b\u9762\u7684\u6b65\u9aa4\u4e2d\u6709\u6240\u5c55\u73b0\u3002<\/p>\n<h4 class=\"wp-block-heading\"><strong>2. \u5b89\u88c5\u4f9d\u8d56\u9879<\/strong><\/h4>\n<p>\u4ece\u76f8\u5173 GitHub \u4ed3\u5e93\u4e0b\u8f7d\u6b64 <a href=\"https:\/\/github.com\/Cheukting\/anomaly-detection\/blob\/main\/requirements.txt\" target=\"_blank\" rel=\"noopener\">requirements.txt<\/a>\u3002 \u5c06\u5176\u653e\u5165\u9879\u76ee\u76ee\u5f55\u5e76\u5728 PyCharm \u4e2d\u6253\u5f00\u540e\uff0c\u60a8\u5c06\u770b\u5230\u4e00\u6761\u63d0\u793a\uff0c\u8981\u6c42\u5b89\u88c5\u7f3a\u5931\u7684\u5e93\u3002<\/p>\n<figure class=\"wp-block-image size-full\"><img decoding=\"async\" loading=\"lazy\" class=\"wp-image-537625\" src=\"https:\/\/blog.jetbrains.com\/wp-content\/uploads\/2025\/01\/dependencies.png\" alt=\"\u5728 PyCharm \u4e2d\u5b89\u88c5\u4f9d\u8d56\u9879\" width=\"1600\" height=\"524\" \/><\/figure>\n<p>\u70b9\u51fb <em>Install requirements<\/em>\uff08\u5b89\u88c5 requirements\uff09\uff0c\u5c06\u5b89\u88c5\u6240\u6709 requirements\u3002 \u5728\u6b64\u9879\u76ee\u4e2d\uff0c\u6211\u4eec\u4f7f\u7528 Python 3.11.1\u3002<\/p>\n<h4 class=\"wp-block-heading\"><strong>3. \u5bfc\u5165\u5e76\u68c0\u67e5\u6570\u636e<\/strong><\/h4>\n<p>\u60a8\u53ef\u4ee5\u4ece <a href=\"https:\/\/www.kaggle.com\/datasets\/vivovinco\/beehives\/data\" target=\"_blank\" rel=\"noopener\">Kaggle<\/a> \u6216\u6b64 <a href=\"https:\/\/github.com\/Cheukting\/anomaly-detection\/tree\/main\/data\" target=\"_blank\" rel=\"noopener\">GitHub \u4ed3\u5e93<\/a>\u4e0b\u8f7d\u201cBeehives\u201d\u6570\u636e\u96c6\u3002 \u5c06\u5168\u90e8\u4e09\u4e2a CSV \u653e\u5165 <em>Data<\/em> \u6587\u4ef6\u5939\u3002 \u7136\u540e\uff0c\u5728 main.py \u4e2d\u8f93\u5165\u4ee5\u4e0b\u4ee3\u7801\uff1a<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"python\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">import pandas as pd\n\ndf = pd.read_csv('data\/Hive17.csv', sep=\";\")\ndf = df.dropna()\nprint(df.head())<\/pre>\n<p>\u6700\u540e\uff0c\u6309\u5c4f\u5e55\u53f3\u4e0a\u89d2\u7684 <em>Run<\/em>\uff08\u8fd0\u884c\uff09\u6309\u94ae\uff0c\u6211\u4eec\u7684\u4ee3\u7801\u5c06\u5728 Python \u63a7\u5236\u53f0\u4e2d\u8fd0\u884c\uff0c\u8ba9\u6211\u4eec\u4e86\u89e3\u6570\u636e\u4f1a\u662f\u4ec0\u4e48\u6837\u5b50\u3002<\/p>\n<figure class=\"wp-block-image size-full\"><img decoding=\"async\" loading=\"lazy\" class=\"wp-image-537636\" src=\"https:\/\/blog.jetbrains.com\/wp-content\/uploads\/2025\/01\/image-1.gif\" alt=\"\u5728 PyCharm \u4e2d\u5bfc\u5165\u6570\u636e\" width=\"1230\" height=\"938\" \/><\/figure>\n<h4 class=\"wp-block-heading\"><strong>4. \u62df\u5408\u6570\u636e\u70b9\u5e76\u5728\u56fe\u8868\u4e2d\u68c0\u67e5<\/strong><\/h4>\n<p>\u7531\u4e8e\u6211\u4eec\u5c06\u4f7f\u7528 scikit-learn \u4e2d\u7684 OneClassSVM\uff0c\u6211\u4eec\u4f7f\u7528\u4ee5\u4e0b\u4ee3\u7801\u5c06\u5176\u4e0e DecisionBoundaryDisplay \u548c Matplotlib \u4e00\u8d77\u5bfc\u5165\uff1a<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"python\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">from sklearn.svm import OneClassSVM\nfrom sklearn.inspection import DecisionBoundaryDisplay\n\nimport matplotlib.pyplot as plt<\/pre>\n<p>\u6839\u636e\u6570\u636e\u63cf\u8ff0\uff0c\u6211\u4eec\u77e5\u9053 T17 \u5217\u4ee3\u8868\u8702\u5de2\u7684\u6e29\u5ea6\uff0cRH17 \u4ee3\u8868\u8702\u5de2\u7684\u76f8\u5bf9\u6e7f\u5ea6\u3002 \u6211\u4eec\u5c06\u63d0\u53d6\u8fd9\u4e24\u5217\u7684\u503c\u4f5c\u4e3a\u8f93\u5165\uff1a<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"python\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">X = df[[\"T17\", \"RH17\"]].values<\/pre>\n<p>\u7136\u540e\uff0c\u521b\u5efa\u5e76\u62df\u5408\u6a21\u578b\u3002 \u6ce8\u610f\uff0c\u6211\u4eec\u9996\u5148\u5c1d\u8bd5\u9ed8\u8ba4\u8bbe\u7f6e\uff1a<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"python\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">estimator = OneClassSVM().fit(X)<\/pre>\n<p>\u63a5\u4e0b\u6765\uff0c\u6211\u4eec\u5c06\u51b3\u7b56\u8fb9\u754c\u4e0e\u6570\u636e\u70b9\u4e00\u8d77\u5c55\u793a\uff1a<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"python\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">disp = DecisionBoundaryDisplay.from_estimator(\n    estimator,\n    X,\n    response_method=\"decision_function\",\n    plot_method=\"contour\",\n    xlabel=\"Temperature\", ylabel=\"Humidity\",\n    levels=[0],\n)\ndisp.ax_.scatter(X[:, 0], X[:, 1])\nplt.show()<\/pre>\n<p>\u73b0\u5728\uff0c\u4fdd\u5b58\u5e76\u518d\u6b21\u6309 <em>Run<\/em>\uff08\u8fd0\u884c\uff09\uff0c\u60a8\u53ef\u4ee5\u770b\u5230\u7ed8\u56fe\u663e\u793a\u5728\u5355\u72ec\u7684\u7a97\u53e3\u4e2d\u4ee5\u4f9b\u68c0\u67e5\u3002<\/p>\n<figure class=\"wp-block-image size-full\"><img decoding=\"async\" loading=\"lazy\" class=\"wp-image-537647\" src=\"https:\/\/blog.jetbrains.com\/wp-content\/uploads\/2025\/01\/image-36.png\" alt=\"\u5728 PyCharm \u4e2d\u62df\u5408\u6570\u636e\u70b9\u5e76\u5728\u56fe\u8868\u4e2d\u68c0\u67e5\" width=\"1600\" height=\"1049\" \/><\/figure>\n<h4 class=\"wp-block-heading\"><strong>5. \u5fae\u8c03\u8d85\u53c2\u6570<\/strong><\/h4>\n<p>\u5982\u4e0a\u56fe\u6240\u793a\uff0c\u51b3\u7b56\u8fb9\u754c\u4e0e\u6570\u636e\u70b9\u5e76\u4e0d\u5341\u5206\u62df\u5408\u3002 \u6570\u636e\u70b9\u7531\u51e0\u4e2a\u4e0d\u89c4\u5219\u5f62\u72b6\uff08\u800c\u4e0d\u662f\u692d\u5706\u5f62\uff09\u7ec4\u6210\u3002 \u4e3a\u4e86\u5fae\u8c03\u6211\u4eec\u7684\u6a21\u578b\uff0c\u6211\u4eec\u5fc5\u987b<a href=\"https:\/\/scikit-learn.org\/stable\/modules\/generated\/sklearn.linear_model.SGDOneClassSVM.html\" target=\"_blank\" rel=\"noopener\">\u4e3a OneClassSVM \u6a21\u578b\u63d0\u4f9b\u201cnu\u201d\u548c\u201cgamma\u201d\u7684\u7279\u5b9a\u503c<\/a>\u3002 \u60a8\u53ef\u4ee5\u81ea\u5df1\u5c1d\u8bd5\u4e00\u4e0b\uff0c\u4f46\u7ecf\u8fc7\u51e0\u6b21\u6d4b\u8bd5\u540e\uff0c\u4f3c\u4e4e\u201cnu=0.1, gamma=0.05\u201d\u7ed9\u51fa\u7684\u7ed3\u679c\u6700\u597d\u3002<\/p>\n<figure class=\"wp-block-image size-full\"><img decoding=\"async\" loading=\"lazy\" class=\"wp-image-537777\" src=\"https:\/\/blog.jetbrains.com\/wp-content\/uploads\/2025\/01\/fine-tune-hyperparameters.png\" alt=\"\u5728 PyCharm \u4e2d\u5fae\u8c03\u8d85\u53c2\u6570\" width=\"1274\" height=\"957\" \/><\/figure>\n<h3 class=\"wp-block-heading\">\u793a\u4f8b\uff1a\u5b64\u7acb\u68ee\u6797<\/h3>\n<p><a href=\"https:\/\/scikit-learn.org\/stable\/modules\/generated\/sklearn.ensemble.IsolationForest.html\" target=\"_blank\" rel=\"noopener\">\u5b64\u7acb\u68ee\u6797<\/a>\u662f\u4e00\u79cd<a href=\"https:\/\/scikit-learn.org\/stable\/api\/sklearn.ensemble.html\" target=\"_blank\" rel=\"noopener\">\u57fa\u4e8e\u96c6\u6210\u7684\u65b9\u6cd5<\/a>\uff0c\u7c7b\u4f3c\u4e8e\u66f4\u6d41\u884c\u7684<a href=\"https:\/\/scikit-learn.org\/stable\/modules\/ensemble.html#forest\" target=\"_blank\" rel=\"noopener\">\u968f\u673a\u68ee\u6797<\/a>\u5206\u7c7b\u65b9\u6cd5\u3002 \u901a\u8fc7\u968f\u673a\u9009\u62e9\u5206\u79bb\u7279\u5f81\u548c\u503c\uff0c\u5b83\u5c06\u521b\u5efa\u8bb8\u591a\u51b3\u7b56\u6811\uff0c\u7136\u540e\u4ece\u6811\u7684\u6839\u5230\u505a\u51fa\u8be5\u51b3\u7b56\u7684\u8282\u70b9\u7684\u8def\u5f84\u957f\u5ea6\u5c06\u5728\u6240\u6709\u6811\uff08\u56e0\u6b64\u79f0\u4e3a\u201c\u68ee\u6797\u201d\uff09\u4e0a\u53d6\u5e73\u5747\u503c\u3002 \u8f83\u77ed\u7684\u5e73\u5747\u8def\u5f84\u957f\u5ea6\u8868\u793a\u5b58\u5728\u5f02\u5e38\u503c\u3002<\/p>\n<figure class=\"wp-block-image size-full\"><img decoding=\"async\" loading=\"lazy\" class=\"wp-image-537669\" src=\"https:\/\/blog.jetbrains.com\/wp-content\/uploads\/2025\/01\/isolation-forest.png\" alt=\"\u5b64\u7acb\u68ee\u6797\" width=\"1600\" height=\"900\" \/>\n<figcaption class=\"wp-element-caption\"><em>\u8f83\u77ed\u7684\u51b3\u7b56\u8def\u5f84\u901a\u5e38\u8868\u793a\u6570\u636e\u4e0e\u5176\u4ed6\u6570\u636e\u6709\u5f88\u5927\u4e0d\u540c\u3002<\/em><\/figcaption>\n<\/figure>\n<p>\u73b0\u5728\uff0c\u6211\u4eec\u6bd4\u8f83 OneClassSVM \u548c IsolationForest \u7684\u7ed3\u679c\u3002 \u4e3a\u6b64\uff0c\u6211\u4eec\u7ed8\u5236\u4e24\u79cd\u7b97\u6cd5\u505a\u51fa\u7684\u51b3\u7b56\u8fb9\u754c\u7684\u56fe\u3002 \u5728\u540e\u7eed\u6b65\u9aa4\u4e2d\uff0c\u6211\u4eec\u5c06\u4f7f\u7528\u76f8\u540c\u7684<a href=\"https:\/\/www.kaggle.com\/datasets\/vivovinco\/beehives\/data\" target=\"_blank\" rel=\"noopener\">\u8702\u5de2 17 \u6570\u636e<\/a>\u57fa\u4e8e\u4e0a\u8ff0\u811a\u672c\u6784\u5efa\u3002<\/p>\n<h4 class=\"wp-block-heading\"><strong>1. \u5bfc\u5165 IsolationForest<\/strong><\/h4>\n<p>IsolationForest \u53ef\u4ee5\u4ece Scikit-learn \u4e2d\u7684\u96c6\u6210\u7c7b\u522b\u4e2d\u5bfc\u5165\uff1a<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"python\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">from sklearn.ensemble import IsolationForest<\/pre>\n<h4 class=\"wp-block-heading\"><strong>2. \u91cd\u6784\u5e76\u6dfb\u52a0\u65b0\u7684 estimator<\/strong><\/h4>\n<p>\u7531\u4e8e\u73b0\u5728\u6211\u4eec\u5c06\u6709\u4e24\u4e2a\u4e0d\u540c\u7684 estimator\uff0c\u6211\u4eec\u5c06\u5b83\u4eec\u653e\u5728\u4e00\u4e2a\u5217\u8868\u4e2d\uff1a<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"python\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">estimators = [\n    OneClassSVM(nu=0.1, gamma=0.05).fit(X),\n    IsolationForest(n_estimators=100).fit(X)\n]<\/pre>\n<p>\u7136\u540e\uff0c\u6211\u4eec\u4f7f\u7528 for \u5faa\u73af\u904d\u5386\u6240\u6709 estimator\u3002<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"python\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">for estimator in estimators:\n    disp = DecisionBoundaryDisplay.from_estimator(\n        estimator,\n        X,\n        response_method=\"decision_function\",\n        plot_method=\"contour\",\n        xlabel=\"Temperature\", ylabel=\"Humidity\",\n        levels=[0],\n    )\n    disp.ax_.scatter(X[:, 0], X[:, 1])\n    plt.show()<\/pre>\n<p>\u6700\u540e\uff0c\u6211\u4eec\u4e3a\u6bcf\u4e2a\u56fe\u8868\u6dfb\u52a0\u6807\u9898\u4ee5\u65b9\u4fbf\u68c0\u67e5\u3002 \u4e3a\u6b64\uff0c\u6211\u4eec\u5c06\u5728 disp.ax_.scatter \u540e\u6dfb\u52a0\u4ee5\u4e0b\u5185\u5bb9\uff1a<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"python\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">disp.ax_.set_title(\n        f\"Decision boundary using {estimator.__class__.__name__}\"\n    )<\/pre>\n<p>\u60a8\u53ef\u80fd\u4f1a\u53d1\u73b0\uff0c\u4f7f\u7528 PyCharm \u7684\u91cd\u6784\u975e\u5e38\u7b80\u5355\uff0c\u56e0\u4e3a\u5b83\u63d0\u4f9b\u4e86\u81ea\u52a8\u8865\u5168\u5efa\u8bae\u3002<\/p>\n<figure class=\"wp-block-image size-full\"><img decoding=\"async\" loading=\"lazy\" class=\"wp-image-537733\" src=\"https:\/\/blog.jetbrains.com\/wp-content\/uploads\/2025\/01\/image-40.png\" alt=\"\u5728 PyCharm \u4e2d\u4f7f\u7528\u81ea\u52a8\u8865\u5168\u8fdb\u884c\u91cd\u6784\" width=\"1600\" height=\"628\" \/><\/figure>\n<figure class=\"wp-block-image size-full\"><img decoding=\"async\" loading=\"lazy\" class=\"wp-image-537711\" src=\"https:\/\/blog.jetbrains.com\/wp-content\/uploads\/2025\/01\/image-39.png\" alt=\"PyCharm \u4e2d\u7684\u81ea\u52a8\u8865\u5168\" width=\"1520\" height=\"546\" \/><\/figure>\n<h4 class=\"wp-block-heading\"><strong>3. \u8fd0\u884c\u4ee3\u7801<\/strong><\/h4>\n<p>\u548c\u5148\u524d\u4e00\u6837\uff0c\u6309\u53f3\u4e0a\u89d2\u7684 <em>Run<\/em>\uff08\u8fd0\u884c\uff09\u6309\u94ae\u5373\u53ef\u8fd0\u884c\u4ee3\u7801\u3002 \u8fd9\u6b21\u8fd0\u884c\u4ee3\u7801\u540e\uff0c\u6211\u4eec\u5e94\u8be5\u4f1a\u5f97\u5230\u4e24\u4e2a\u56fe\u8868\u3002<\/p>\n<figure class=\"wp-block-image size-full\"><img decoding=\"async\" loading=\"lazy\" class=\"wp-image-537722\" src=\"https:\/\/blog.jetbrains.com\/wp-content\/uploads\/2025\/01\/run-the-code.gif\" alt=\"\u5728 PyCharm \u4e2d\u8fd0\u884c\u4ee3\u7801\" width=\"1056\" height=\"582\" \/><\/figure>\n<p>\u60a8\u53ef\u4ee5\u901a\u8fc7\u53f3\u4fa7\u7684\u9884\u89c8\u8f7b\u677e\u7ffb\u9605\u8fd9\u4e24\u4e2a\u56fe\u8868\u3002 \u53ef\u4ee5\u770b\u51fa\uff0c\u4f7f\u7528\u4e0d\u540c\u7684\u7b97\u6cd5\u65f6\uff0c\u51b3\u7b56\u8fb9\u754c\u6709\u5f88\u5927\u4e0d\u540c\u3002 \u8fdb\u884c\u5f02\u5e38\u503c\u68c0\u6d4b\u65f6\uff0c\u503c\u5f97\u5c1d\u8bd5\u4e0d\u540c\u7684\u7b97\u6cd5\u548c\u53c2\u6570\uff0c\u5bfb\u627e\u6700\u9002\u5408\u7528\u4f8b\u7684\u65b9\u6848\u3002<\/p>\n<h2 class=\"wp-block-heading\">\u4e0b\u4e00\u6b65\uff1a\u65f6\u95f4\u5e8f\u5217\u6570\u636e\u4e2d\u7684\u5f02\u5e38\u503c\u68c0\u6d4b<\/h2>\n<p>\u5982\u679c\u6570\u636e\u50cf\u6211\u4eec\u7684\u8702\u5de2\u6570\u636e\u4e00\u6837\u662f\u65f6\u95f4\u5e8f\u5217\uff0c\u90a3\u4e48\u8fd8\u6709\u5176\u4ed6\u65b9\u6cd5\u53ef\u4ee5\u627e\u51fa\u5f02\u5e38\u503c\u3002 \u7531\u4e8e\u65f6\u95f4\u5e8f\u5217\u5177\u6709\u8d8b\u52bf\u548c\u5468\u671f\uff0c\u4efb\u4f55\u4e0d\u7b26\u5408\u8d8b\u52bf\u548c\u5468\u671f\u6a21\u5f0f\u7684\u503c\u90fd\u53ef\u4ee5\u88ab\u89c6\u4e3a\u5f02\u5e38\u503c\u3002 \u68c0\u6d4b\u65f6\u95f4\u5e8f\u5217\u5f02\u5e38\u503c\u7684\u6d41\u884c\u65b9\u6cd5\u5305\u62ec STL \u5206\u89e3\u548c LSTM \u9884\u6d4b\u3002<\/p>\n<p>\u5728<a href=\"https:\/\/blog.jetbrains.com\/pycharm\/2025\/01\/anomaly-detection-in-time-series\/\" data-type=\"link\" data-id=\"https:\/\/blog.jetbrains.com\/pycharm\/2025\/01\/anomaly-detection-in-time-series\/\">\u8fd9\u7bc7\u535a\u6587<\/a>\u4e2d\uff0c\u60a8\u53ef\u4ee5\u4e86\u89e3\u5982\u4f55\u4f7f\u7528\u8fd9\u4e9b\u65b9\u6cd5\u68c0\u6d4b\u65f6\u95f4\u5e8f\u5217\u4e2d\u7684\u5f02\u5e38\u503c\u3002<\/p>\n<h2 class=\"wp-block-heading\">\u603b\u7ed3<\/h2>\n<p>\u5f02\u5e38\u503c\u68c0\u6d4b\u5df2\u88ab\u8bc1\u660e\u662f\u5546\u4e1a\u667a\u80fd\u7684\u4e00\u4e2a\u91cd\u8981\u65b9\u9762\uff0c\u5728\u67d0\u4e9b\u5546\u4e1a\u9886\u57df\uff0c\u8bc6\u522b\u5f02\u5e38\u503c\u5e76\u7acb\u5373\u91c7\u53d6\u884c\u52a8\u81f3\u5173\u91cd\u8981\u3002 \u4f7f\u7528\u5408\u9002\u7684\u673a\u5668\u5b66\u4e60\u6a21\u578b\u81ea\u52a8\u68c0\u6d4b\u5f02\u5e38\u503c\u6709\u52a9\u4e8e\u5728\u77ed\u65f6\u95f4\u5185\u5206\u6790\u590d\u6742\u3001\u5927\u91cf\u7684\u6570\u636e\u3002 \u5728\u8fd9\u7bc7\u535a\u6587\u4e2d\uff0c\u6211\u4eec\u5c55\u793a\u4e86\u5982\u4f55\u4f7f\u7528 OneClassSVM \u7b49\u7edf\u8ba1\u6a21\u578b\u8bc6\u522b\u5f02\u5e38\u503c\u3002<\/p>\n<p>\u8981\u8be6\u7ec6\u4e86\u89e3\u5982\u4f55\u5c06 PyCharm \u7528\u4e8e\u673a\u5668\u5b66\u4e60\uff0c\u8bf7\u53c2\u9605<a href=\"https:\/\/blog.jetbrains.com\/pycharm\/2022\/06\/start-studying-machine-learning-with-pycharm\/\">\u5f00\u59cb\u4f7f\u7528 PyCharm \u5b66\u4e60\u673a\u5668\u5b66\u4e60<\/a>\u548c<a href=\"https:\/\/blog.jetbrains.com\/pycharm\/2024\/09\/how-to-use-jupyter-notebooks-in-pycharm\/\">\u5982\u4f55\u5728 PyCharm \u4e2d\u4f7f\u7528 Jupyter Notebook<\/a>\u3002<\/p>\n<h2 class=\"wp-block-heading\">\u4f7f\u7528 PyCharm \u68c0\u6d4b\u5f02\u5e38\u503c<\/h2>\n<p>\u501f\u52a9 PyCharm Professional \u4e2d\u7684 Jupyter \u9879\u76ee\uff0c\u60a8\u53ef\u4ee5\u8f7b\u677e\u7ec4\u7ec7\u5305\u542b\u5927\u91cf\u6570\u636e\u6587\u4ef6\u548c Notebook \u7684\u5f02\u5e38\u503c\u68c0\u6d4b\u9879\u76ee\u3002 \u5728 PyCharm \u4e2d\uff0c\u53ef\u4ee5\u751f\u6210\u56fe\u8868\u8f93\u51fa\u68c0\u67e5\u5f02\u5e38\u503c\uff0c\u5e76\u975e\u5e38\u65b9\u4fbf\u5730\u67e5\u770b\u7ed8\u56fe\u3002 \u5176\u4ed6\u529f\u80fd\uff0c\u4f8b\u5982\u81ea\u52a8\u8865\u5168\u5efa\u8bae\uff0c\u4f7f\u6d4f\u89c8 Scikit-learn \u6a21\u578b\u548c Matplotlib \u7ed8\u56fe\u8bbe\u7f6e\u53d8\u5f97\u975e\u5e38\u5bb9\u6613\u3002<\/p>\n<p>\u4f7f\u7528 PyCharm \u589e\u5f3a\u6570\u636e\u79d1\u5b66\u9879\u76ee\uff0c\u67e5\u770b\u4e3a\u7b80\u5316\u6570\u636e\u79d1\u5b66\u5de5\u4f5c\u6d41\u800c\u63d0\u4f9b\u7684<a href=\"https:\/\/www.jetbrains.com.cn\/pycharm\/data-science\/\" target=\"_blank\" rel=\"noopener\">\u6570\u636e\u79d1\u5b66\u529f\u80fd<\/a>\u3002<\/p>\n<div class=\"buttons\">\n<div class=\"buttons__row\"><a class=\"btn\" href=\"https:\/\/www.jetbrains.com.cn\/pycharm\/data-science\/\" target=\"\" rel=\"noopener\">\u514d\u8d39\u5f00\u59cb\u4f7f\u7528 PyCharm Pro<\/a><\/div>\n<\/div>\n\n\n<p><\/p>\n\n\n\n<p>\u672c\u535a\u6587\u82f1\u6587\u539f\u4f5c\u8005\uff1a<\/p>\n\n\n    <div class=\"about-author \">\n        <div class=\"about-author__box\">\n            <div class=\"row\">\n                <div class=\"about-author__box-img\">\n                    <img decoding=\"async\" src=\"https:\/\/blog.jetbrains.com\/wp-content\/uploads\/2025\/01\/CheukTingHo-Kimono-e1738750639162-200x200.jpg\" width=\"200\" height=\"200\" alt=\"Cheuk Ting Ho\" loading=\"lazy\"  class=\"avatar avatar-200 wp-user-avatar wp-user-avatar-200 photo avatar-default\">\n                <\/div>\n                <div class=\"about-author__box-text\">\n                                            <h4>Cheuk Ting Ho<\/h4>\n                                                        <\/div>\n            <\/div>\n        <\/div>\n    <\/div>\n","protected":false},"author":1297,"featured_media":556304,"comment_status":"closed","ping_status":"closed","template":"","categories":[952,1401],"tags":[8670],"cross-post-tag":[],"acf":[],"_links":{"self":[{"href":"https:\/\/blog.jetbrains.com\/zh-hans\/wp-json\/wp\/v2\/pycharm\/554110"}],"collection":[{"href":"https:\/\/blog.jetbrains.com\/zh-hans\/wp-json\/wp\/v2\/pycharm"}],"about":[{"href":"https:\/\/blog.jetbrains.com\/zh-hans\/wp-json\/wp\/v2\/types\/pycharm"}],"author":[{"embeddable":true,"href":"https:\/\/blog.jetbrains.com\/zh-hans\/wp-json\/wp\/v2\/users\/1297"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.jetbrains.com\/zh-hans\/wp-json\/wp\/v2\/comments?post=554110"}],"version-history":[{"count":9,"href":"https:\/\/blog.jetbrains.com\/zh-hans\/wp-json\/wp\/v2\/pycharm\/554110\/revisions"}],"predecessor-version":[{"id":556333,"href":"https:\/\/blog.jetbrains.com\/zh-hans\/wp-json\/wp\/v2\/pycharm\/554110\/revisions\/556333"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/blog.jetbrains.com\/zh-hans\/wp-json\/wp\/v2\/media\/556304"}],"wp:attachment":[{"href":"https:\/\/blog.jetbrains.com\/zh-hans\/wp-json\/wp\/v2\/media?parent=554110"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.jetbrains.com\/zh-hans\/wp-json\/wp\/v2\/categories?post=554110"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.jetbrains.com\/zh-hans\/wp-json\/wp\/v2\/tags?post=554110"},{"taxonomy":"cross-post-tag","embeddable":true,"href":"https:\/\/blog.jetbrains.com\/zh-hans\/wp-json\/wp\/v2\/cross-post-tag?post=554110"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}