{"id":4958,"date":"2018-07-30T16:49:00","date_gmt":"2018-07-30T07:49:00","guid":{"rendered":"https:\/\/yorozu.cloudfree.jp\/wordpress\/?p=4958"},"modified":"2024-12-05T17:12:08","modified_gmt":"2024-12-05T08:12:08","slug":"%e3%82%a2%e3%83%a4%e3%83%a1%e3%81%ae%e7%a8%ae%e9%a1%9e%e5%88%a4%e5%88%a5%ef%bc%88%e3%81%9d%e3%81%ae%ef%bc%97%ef%bc%89","status":"publish","type":"post","link":"https:\/\/yorozu.cloudfree.jp\/wordpress\/?p=4958","title":{"rendered":"\u30a2\u30e4\u30e1\u306e\u7a2e\u985e\u5224\u5225\uff08\u305d\u306e\uff17\uff09"},"content":{"rendered":"\n<p>\u5b9f\u884c\u4f8b\u306f\u300csaka.mokumoku\u300d\u306e\u300cGoogle Colabotry\u300d\u74b0\u5883\u306b\u4fdd\u5b58\u3057\u3066\u3042\u308b<\/p>\n\n\n\n<h4 class=\"wp-block-heading\"><strong>\uff11\uff0eiris \u30c7\u30fc\u30bf\u30bb\u30c3\u30c8\u306e\u8aac\u660e<\/strong><\/h4>\n\n\n\n<p>\u3000\u30c7\u30fc\u30bf\u30bb\u30c3\u30c8\u306e\u30ed\u30fc\u30c9<br>\u3000\u3000\u3000load_iris&nbsp;\u95a2\u6570\u3067\u30ed\u30fc\u30c9\u3059\u308b<br><br>\u3000\u30c7\u30fc\u30bf\u30bb\u30c3\u30c8\u306e\u8aac\u660e<br>\u3000\u3000\u3000 DESCR (description) \u306e\u4e2d\u8eab\u3092\u898b\u308b<br>\u3000\u3000\u3000\u3000\u3000Attribute \u306e\u610f\u5473<br>\u3000\u3000\u3000\u3000\u3000\u3000\u3000sepal length\uff1a\u30ac\u30af\u306e\u9577\u3055<br>\u3000\u3000\u3000\u3000\u3000\u3000\u3000sepal width\uff1a\u30ac\u30af\u306e\u5e45<br>\u3000\u3000\u3000\u3000\u3000\u3000\u3000petal length\uff1a\u82b1\u5f01\u306e\u9577\u3055<br>\u3000\u3000\u3000\u3000\u3000\u3000\u3000petal width \uff1a\u82b1\u5f01\u306e\u5e45<\/p>\n\n\n\n<div class=\"hcb_wrap\"><pre class=\"prism line-numbers lang-python\" data-lang=\"Python\"><code>from sklearn.datasets import load_iris\niris = load_iris()\n#\nprint(iris.DESCR)<\/code><\/pre><\/div>\n\n\n\n<p>\u3000\u30c7\u30fc\u30bf\u30bb\u30c3\u30c8\u306e\u5185\u5bb9<br>\u3000\u3000\u3000<a href=\"https:\/\/qiita.com\/ao_log\/items\/fe9bd42fd249c2a7ee7a#%E3%83%87%E3%83%BC%E3%82%BF%E3%82%BB%E3%83%83%E3%83%88%E3%81%AE%E5%BD%A2%E7%8A%B6\"><\/a>\u30c7\u30fc\u30bf\u30bb\u30c3\u30c8\u306e\u5f62\u72b6\u30fb\u30fb\u30fb\u7279\u5fb4\u91cf\u306f 4 \u500b\u3067\u3001150 \u500b\u306e\u30c7\u30fc\u30bf<br>\u3000\u3000\u3000\u3000\u3000\u3000\u3000\u3000\u3000\u3000\u3000\u3000\u3000\u3000\u3000\u5f62\u72b6\u306f shape \u3067\u78ba\u8a8d\u3059\u308b<br><br>\u3000\u3000\u3000\u82b1\u306e\u7a2e\u985e\u30fb\u30fb\u30fbtarget_names \u306b\uff13\u7a2e\u985e\u306e\u82b1\u304c\u683c\u7d0d\u3055\u308c\u3066\u3044\u308b<br>\u3000\u3000\u3000\u3000\u3000\u3000\u3000\u3000\u3000\u3000setosa\u3001&#8217;versicolor\u3001&#8217;virginica<br><br>\u3000\u3000\u3000\u5148\u982d\uff15\u4ef6\u30fb\u30fb\u30fbiris.data<br>\u3000\u3000\u3000\u3000\u3000\u3000\u3000\u3000\u3000\u3000\u3000\u3000 4 \u3064\u306e\u7279\u5fb4\u91cf(\u30ac\u30af\u306e\u9577\u3055\u3001\u5e45\u3001\u82b1\u5f01\u306e\u9577\u3055\u3001\u5e45)<br>\u3000\u3000\u3000\u3000\u3000\u3000\u3000\u3000\u3000\u3000iris.target<br>\u3000\u3000\u3000\u3000\u3000\u3000\u3000\u3000\u3000\u3000\u3000\u3000\uff13\u7a2e\u985e\u30010(=setosa), 1(=versicolor), 2(=virginica)<\/p>\n\n\n\n<div class=\"hcb_wrap\"><pre class=\"prism line-numbers lang-python\" data-lang=\"Python\"><code>print(iris.data.shape)\n#\nprint(iris.target_names)\n#\nfor data, target in zip(iris.data[:5], iris.target[:5]):\n\u3000\u3000print(data, target)<\/code><\/pre><\/div>\n\n\n\n<h4 class=\"wp-block-heading\"><strong>\uff12\uff0e\u30c7\u30fc\u30bf\u30d5\u30ec\u30fc\u30e0\u4f5c\u6210<\/strong><\/h4>\n\n\n\n<p>\u3000\u30c7\u30fc\u30bf\u30d5\u30ec\u30fc\u30e0\u306b\u3059\u308b\u3068\u30c7\u30fc\u30bf\u3092\u6271\u3044\u3084\u3059\u304f\u306a\u308b<br>\u3000\u3000\u3000target \u306e\u884c\u304c 0, 1, 2 \u3060\u3068\u5206\u304b\u308a\u306b\u304f\u3044\u306e\u3067\u7a2e\u985e\u540d\u306b\u7f6e\u304d\u63db\u3048\u308b<br><br>\u3000\u3000\u3000describe\u3067\u5e73\u5747\u5024\u3001\u6700\u5c0f\u3001\u6700\u5927\u5024\u3092\u773a\u3081\u308b<\/p>\n\n\n\n<div class=\"hcb_wrap\"><pre class=\"prism line-numbers lang-python\" data-lang=\"Python\"><code>import pandas as pd\n#\ndf = pd.DataFrame(iris.data, columns=iris.feature_names)\ndf[&#39;target&#39;] = iris.target\ndf.loc[df[&#39;target&#39;] == 0, &#39;target&#39;] = &quot;setosa&quot;\ndf.loc[df[&#39;target&#39;] == 1, &#39;target&#39;] = &quot;versicolor&quot;\ndf.loc[df[&#39;target&#39;] == 2, &#39;target&#39;] = &quot;virginica&quot;\n#\nprint(df.describe())<\/code><\/pre><\/div>\n\n\n\n<h4 class=\"wp-block-heading\"><strong>\uff13\uff0e\u30da\u30a2\u30d7\u30ed\u30c3\u30c8\u3059\u308b<\/strong><\/h4>\n\n\n\n<p>\u3000\u5404\u7279\u5fb4\u91cf\u306e\u30da\u30a2\u3054\u3068\u306b\u6563\u5e03\u56f3\u3092\u8868\u793a\u3059\u308b<br>\u3000\u3000\u3000\u7279\u5fb4\u91cf\u306e\u30da\u30a2\u3067\u898b\u3066\u3082\u540c\u3058\u54c1\u7a2e\u304c\u56fa\u307e\u3063\u3066\u3044\u308b\u306e\u3067\u3001\u6bd4\u8f03\u7684\u5206\u985e\u3057\u3084\u3059\u3044<\/p>\n\n\n\n<div class=\"hcb_wrap\"><pre class=\"prism line-numbers lang-python\" data-lang=\"Python\"><code>import seaborn as sns\n#\nsns.pairplot(df, hue=&quot;target&quot;)<\/code><\/pre><\/div>\n\n\n\n<h4 class=\"wp-block-heading\"><strong>\uff14\uff0e\u5206\u985e\u30a2\u30eb\u30b4\u30ea\u30ba\u30e0<\/strong><\/h4>\n\n\n\n<p>\u3000\u5206\u985e\u30a2\u30eb\u30b4\u30ea\u30ba\u30e0\u306e\u7279\u5fb4\u3092\u898b\u308b\u305f\u3081\u306b<br>\u3000\u3000\u3000\u4f5c\u6210\u3057\u305f\u30e2\u30c7\u30eb\u306e\u6c7a\u5b9a\u5883\u754c(decision boundary)\u3092\u8868\u793a\u3059\u308b<br><br>\u3000\u3000\u3000\u30e2\u30c7\u30eb\u3092 validation \u7528\u3001test \u7528\u306b\u5206\u3051\u305f\u308a\u3001\u6b63\u7b54\u7387\u306e\u8a55\u4fa1\u306f\u884c\u308f\u306a\u3044<br><br>\u3000\u3000\u3000X \u306b\u8a13\u7df4\u30c7\u30fc\u30bf\u3092\u30bb\u30c3\u30c8\u3059\u308b<br>\u3000\u3000\u3000\u3000\u3000\u7279\u5fb4\u91cf\u306f\u30ac\u30af\u306e\u9577\u3055\u3001\u82b1\u5f01\u306e\u9577\u3055\u306e\uff12\u3064\u3060\u3051\u3092\u4f7f\u7528\u3059\u308b<br>\u3000\u3000\u3000y \u306b\u6559\u5e2b\u30c7\u30fc\u30bf\u3068\u3057\u3066\u54c1\u7a2e\u3092\u30bb\u30c3\u30c8\u3059\u308b<br><br>\u3000\u3000\u3000\u63cf\u753b\u7528\u306b\u30b3\u30fc\u30c9\u3092\u6e96\u5099\u3059\u308b<\/p>\n\n\n\n<div class=\"hcb_wrap\"><pre class=\"prism line-numbers lang-python\" data-lang=\"Python\"><code># import some data to play with\nX = iris.data[:, [0, 2]] \ny = iris.target\n\nimport numpy as np\nimport matplotlib.pyplot as plt\n\n# graph common settings\nh = .02  # step size in the mesh\nx_min, x_max = X[:, 0].min() - .5, X[:, 0].max() + .5\ny_min, y_max = X[:, 1].min() - .5, X[:, 1].max() + .5\nxx, yy = np.meshgrid(np.arange(x_min, x_max, h), np.arange(y_min, y_max, h))\n\ndef decision_boundary(clf, X, y, ax, title):\n    clf.fit(X, y)\n    \n    # Plot the decision boundary. For that, we will assign a color to each\n    # point in the mesh [x_min, x_max]x[y_min, y_max].    \n    Z = clf.predict(np.c_[xx.ravel(), yy.ravel()])\n    \n    # Put the result into a color plot\n    Z = Z.reshape(xx.shape)\n    ax.pcolormesh(xx, yy, Z, cmap=plt.cm.Paired)\n    \n    # Plot also the training points\n    ax.scatter(X[:, 0], X[:, 1], c=y, edgecolors=&#39;k&#39;, cmap=plt.cm.Paired)\n    \n    # label\n    ax.set_title(title)\n    ax.set_xlabel(&#39;sepal length&#39;)\n    ax.set_ylabel(&#39;petal length&#39;)\n<\/code><\/pre><\/div>\n\n\n\n<h4 class=\"wp-block-heading\"><strong>\uff15\uff0e\u6559\u5e2b\u3042\u308a\u5b66\u7fd2<\/strong><\/h4>\n\n\n\n<p>\u3000<strong>k-\u8fd1\u508d\u6cd5\u3000(k-NN)<\/strong><br>\u3000\u3000\u3000\u30e2\u30c7\u30eb\u306b\u306f\u8a13\u7df4\u30c7\u30fc\u30bf\u30bb\u30c3\u30c8\u3092\u683c\u7d0d\u3059\u308b\u3060\u3051<br>\u3000\u3000\u3000\u3000\u3000\u4e88\u6e2c\u6642\u306f\u3001\u4e88\u6e2c\u3057\u305f\u3044\u30c7\u30fc\u30bf\u30dd\u30a4\u30f3\u30c8\u306e\u8fd1\u304f\u306e k \u500b\u306e\u8fd1\u508d\u70b9\u3092\u78ba\u8a8d\u3057<br>\u3000\u3000\u3000\u3000\u3000\u305d\u306e\u4e2d\u3067\u4e00\u756a\u591a\u6570\u6d3e\u306e\u30af\u30e9\u30b9\u3092\u4e88\u6e2c\u7d50\u679c\u3068\u3057\u3066\u63a1\u7528\u3059\u308b<br><br>\u3000\u3000\u3000KNeighborsClassifier\u3092\u4f7f\u7528\u3059\u308b<br>\u3000\u3000\u3000\u3000\u3000n_neighbors \u3067\u4e88\u6e2c\u306b\u4f7f\u7528\u3059\u308b\u8fd1\u508d\u70b9\u306e\u6570\u3092\u8a2d\u5b9a\u3059\u308b<br>\u3000\u3000\u3000\u3000\u3000\u3000\u3000n_neighbors = 1 \u306e\u5834\u5408\u306f\u6c7a\u5b9a\u5883\u754c\u304c\u92ed\u89d2\u306b\u306a\u308b\u90e8\u5206\u3082\u3042\u308b<br>\u3000\u3000\u3000\u3000\u3000\u3000\u3000\u6570\u304c\u591a\u304f\u306a\u308b\u306b\u5f93\u3044\u306a\u3060\u3089\u304b\u306b\u306a\u3063\u3066\u3044\u304d\u3001<br>\u3000\u3000\u3000\u3000\u3000\u3000\u3000\u3000\u300010 \u306b\u306a\u308b\u3068\u5883\u754c\u304c\u5358\u7d14\u306b\u306a\u308a\u3059\u304e\u3066\u4e88\u6e2c\u6027\u80fd\u304c\u843d\u3061\u308b<\/p>\n\n\n\n<div class=\"hcb_wrap\"><pre class=\"prism line-numbers lang-python\" data-lang=\"Python\"><code>from sklearn.neighbors import KNeighborsClassifier\n\nfig, axes = plt.subplots(1, 4, figsize=(12, 3))\n\nfor ax, n_neighbors in zip(axes, [1, 3, 6, 10]):\n    title = &quot;%s neighbor(s)&quot;% (n_neighbors)\n    clf = KNeighborsClassifier(n_neighbors=n_neighbors)\n    decision_boundary(clf, X, y, ax, title)<\/code><\/pre><\/div>\n\n\n\n<p>\u3000<strong>\u30ed\u30b8\u30b9\u30c6\u30a3\u30c3\u30af\u56de\u5e30<\/strong><br>\u3000\u3000\u3000\u56de\u5e30\u3068\u3042\u308b\u304c\u3001\u5206\u985e\u30a2\u30eb\u30b4\u30ea\u30ba\u30e0<br><br>\u3000\u3000\u3000LogisticRegression\u3092\u4f7f\u7528\u3059\u308b<br>\u3000\u3000\u3000\u3000\u3000\u6c7a\u5b9a\u5883\u754c\u306f\u76f4\u7dda\u306b\u306a\u308b<br>\u3000\u3000\u3000\u3000\u3000C \u306f\u6b63\u5247\u5316\u306e\u5ea6\u5408\u3044\u3092\u8abf\u6574\u3059\u308b\u30d1\u30e9\u30e1\u30fc\u30bf<br>\u3000\u3000\u3000\u3000\u3000\u3000\u3000\u6b63\u5247\u5316\u306f\u5b66\u7fd2\u6642\u306b\u30da\u30ca\u30eb\u30c6\u30a3\u3092\u4e0e\u3048\u308b\u3053\u3068\u3067\u904e\u5b66\u7fd2\u3092\u6291\u3048\u308b<br>\u3000\u3000\u3000\u3000\u3000\u3000\u3000C \u3092\u5927\u304d\u304f\u3059\u308b\u3068\u6b63\u5247\u5316\u304c\u5f31\u304f\u306a\u308a\u904e\u5b66\u7fd2\u6c17\u5473\u306b\u306a\u308b<br>\u3000\u3000\u3000\u3000\u3000\u3000\u3000\uff23\u3092\u5c0f\u3055\u304f\u3059\u308b\u3068\u30c7\u30fc\u30bf\u306e\u7279\u5fb4\u3092\u5927\u96d1\u628a\u306b\u3057\u304b\u7372\u5f97\u3067\u304d\u306a\u3044<br><br>\u3000\u3000\u3000\u30ed\u30b8\u30b9\u30c6\u30a3\u30c3\u30af\u56de\u5e30\u306a\u3069\u306e\u7dda\u5f62\u30e2\u30c7\u30eb\u306f<br>\u3000\u3000\u3000\u3000\u3000\u9ad8\u6b21\u5143\uff08\u7279\u5fb4\u91cf\u306e\u6570\u304c\u591a\u3044\uff09\u306e\u30c7\u30fc\u30bf\u306b\u5bfe\u3057\u3066\u6709\u52b9<br>\u3000\u3000\u3000\u3000\u3000\u3000\u3000\u9ad8\u901f\u306e\u305f\u3081\u3001\u4ed6\u306e\u624b\u6cd5\u3067\u306f\u5b66\u7fd2\u3067\u304d\u306a\u3044<\/p>\n\n\n\n<div class=\"hcb_wrap\"><pre class=\"prism line-numbers lang-python\" data-lang=\"Python\"><code>from sklearn.linear_model import LogisticRegression\n\nfig, axes = plt.subplots(1, 3, figsize=(10, 3))\n\nfor ax, C in zip(axes, [0.01, 1, 100]):\n    title = &quot;C=%s&quot;% (C)\n    clf = LogisticRegression(C=C)\n    decision_boundary(clf, X, y, ax, title)<\/code><\/pre><\/div>\n\n\n\n<p>\u3000<strong>\u7dda\u5f62\u30b5\u30dd\u30fc\u30c8\u30d9\u30af\u30bf\u30de\u30b7\u30f3<\/strong><br>\u3000\u3000\u3000<a href=\"http:\/\/scikit-learn.org\/stable\/modules\/generated\/sklearn.svm.LinearSVC.html\" target=\"_blank\" rel=\"noreferrer noopener\">LinearSVC<\/a>\u3092\u4f7f\u7528\u3059\u308b<br>\u3000\u3000\u3000\u3000\u3000\u7dda\u5f62\u306a\u306e\u3067\u3001\u6c7a\u5b9a\u5883\u754c\u3082\u76f4\u7dda\u306b\u306a\u308b<br>\u3000\u3000\u3000\u3000\u3000C \u306f\u30ed\u30b8\u30b9\u30c6\u30a3\u30c3\u30af\u56de\u5e30\u540c\u69d8\u3001\u6b63\u5247\u5316\u306e\u5ea6\u5408\u3044\u3092\u8abf\u6574\u3059\u308b\u30d1\u30e9\u30e1\u30fc\u30bf<\/p>\n\n\n\n<div class=\"hcb_wrap\"><pre class=\"prism line-numbers lang-python\" data-lang=\"Python\"><code>from sklearn.svm import LinearSVC\n\nfig, axes = plt.subplots(1, 3, figsize=(10, 3))\n\nfor ax, C in zip(axes, [0.01, 1, 100]):\n    title = &quot;C=%s&quot;% (C)\n    clf = LinearSVC(C=C)\n    decision_boundary(clf, X, y, ax, title)<\/code><\/pre><\/div>\n\n\n\n<p>\u3000<strong>\u30ab\u30fc\u30cd\u30eb\u6cd5\u3092\u7528\u3044\u305f\u30b5\u30dd\u30fc\u30c8\u30d9\u30af\u30bf\u30de\u30b7\u30f3<\/strong><br>\u3000\u3000\u3000SVM \u3068\u3082\u547c\u3070\u308c\u308b<br>\u3000\u3000\u3000\u3000\u3000\u7dda\u5f62\u30ab\u30fc\u30cd\u30eb\u30d9\u30af\u30bf\u30de\u30b7\u30f3\u3068\u6bd4\u3079\u3066\u3001\u975e\u7dda\u5f62\u306a\u5206\u96e2\u304c\u53ef\u80fd<\/p>\n\n\n\n<p>\u3000\u3000\u3000\u3000\u3000SVC\u3092\u4f7f\u7528\u3059\u308b<br>\u3000\u3000\u3000\u3000\u3000C \u306f\u6b63\u5247\u5316\u306e\u30d1\u30e9\u30e1\u30fc\u30bf<br>\u3000\u3000\u3000\u3000\u3000gamma \u306f\u8a13\u7df4\u30c7\u30fc\u30bf\u306e\u5f71\u97ff\u304c\u53ca\u3076\u7bc4\u56f2<br>\u3000\u3000\u3000\u3000\u3000\u3000\u3000\u5c0f\u3055\u3044\u3068\u9060\u304f\u307e\u3067\u3001\u5927\u304d\u3044\u3068\u8fd1\u304f\u306b\u306a\u308b<br>\u3000\u3000\u3000\u3000\u3000\u3000\u3000\u3000\u3000\u5927\u304d\u3059\u304e\u308b\u3068\u904e\u5b66\u7fd2\u306b\u306a\u308a<br>\u3000\u3000\u3000\u3000\u3000\u3000\u3000\u3000\u3000\u5c0f\u3055\u3059\u304e\u308b\u3068\u5927\u96d1\u628a\u306b\u3057\u304b\u30c7\u30fc\u30bf\u306e\u7279\u5fb4\u3092\u7372\u5f97\u3067\u304d\u306a\u3044<\/p>\n\n\n\n<div class=\"hcb_wrap\"><pre class=\"prism line-numbers lang-python\" data-lang=\"Python\"><code>from sklearn.svm import SVC\n\nfig, axes = plt.subplots(3, 3, figsize=(10, 10))\n\nfor ax_row, C in zip(axes, [0.01, 1, 100]):\n    for ax, gamma in zip(ax_row, [0.1, 1, 10]):\n        title = &quot;C=%s, gamma=%s&quot;% (C, gamma)\n        clf = SVC(C=C, gamma=gamma)\n        decision_boundary(clf, X, y, ax, title)<\/code><\/pre><\/div>\n\n\n\n<p>\u3000<strong>\u6c7a\u5b9a\u6728<\/strong><br>\u3000\u3000\u3000\u8cea\u554f\u3092\u901a\u3057\u3066\u30c7\u30fc\u30bf\u3092\u5206\u985e\u3059\u308b\u624b\u6cd5<br>\u3000\u3000\u3000\u3000\u3000\u3042\u3084\u3081\u306e\u5834\u5408\u306b\u306f<br>\u3000\u3000\u3000\u3000\u3000\u3000\u3000\u82b1\u5f01\u306e\u9577\u3055\u304c\u4f55\u30bb\u30f3\u30c1\u4ee5\u4e0a or \u672a\u6e80<br>\u3000\u3000\u3000\u3000\u3000\u3000\u3000\u30ac\u30af\u306e\u9577\u3055\u304c\u4f55\u30bb\u30f3\u30c1\u4ee5\u4e0a or \u672a\u6e80\u30fb\u30fb\u30fb\u3068\u8cea\u554f\u3092\u7e70\u308a\u8fd4\u3059<\/p>\n\n\n\n<p>\u3000\u3000\u3000\u3000\u3000DecisionTreeRegressor\u00a0\u3092\u4f7f\u7528\u3059\u308b<br>\u3000\u3000\u3000\u3000\u3000\u3000\u3000max_depth \u304c\u30c4\u30ea\u30fc\u306e\u6df1\u3055\u3067\u3001\u8cea\u554f\u6570\u306b\u306a\u308b<br>\u3000\u3000\u3000\u3000\u3000\u3000\u3000\u3000\u3000\u591a\u3051\u308c\u3070\u3044\u3044\u308f\u3051\u3067\u3082\u306a\u304f\u3001<br>\u3000\u3000\u3000\u3000\u3000\u3000\u3000\u3000\u3000\u8a13\u7df4\u30c7\u30fc\u30bf\u306b\u904e\u5270\u9069\u5408\u3059\u308b\u306e\u3067\u904e\u5b66\u7fd2\u3068\u306a\u308b<\/p>\n\n\n\n<div class=\"hcb_wrap\"><pre class=\"prism line-numbers lang-python\" data-lang=\"Python\"><code>from sklearn.tree import DecisionTreeRegressor\n\nfig, axes = plt.subplots(1, 3, figsize=(10, 3))\n\nfor ax, max_depth in zip(axes, [1, 3, 8]):\n    title = &quot;max_depth=%s&quot;% (max_depth)\n    clf = DecisionTreeRegressor(max_depth=max_depth)\n    decision_boundary(clf, X, y, ax, title)<\/code><\/pre><\/div>\n\n\n\n<p>\u3000<strong>\u30e9\u30f3\u30c0\u30e0\u30d5\u30a9\u30ec\u30b9\u30c8\u3001\u52fe\u914d\u30d6\u30fc\u30b9\u30c6\u30a3\u30f3\u30b0\u56de\u5e30\u6728<\/strong><br>\u3000\u3000\u3000\u30e9\u30f3\u30c0\u30e0\u30d5\u30a9\u30ec\u30b9\u30c8\u306f\u7570\u306a\u308b\u6c7a\u5b9a\u6728\u3092\u305f\u304f\u3055\u3093\u4f5c\u308a<br>\u3000\u3000\u3000\u3000\u3000\u5168\u3066\u306e\u6c7a\u5b9a\u6728\u3067\u4e88\u6e2c\u3057\u305f\u7d50\u679c\u304b\u3089<br>\u3000\u3000\u3000\u3000\u3000\u3082\u3063\u3068\u3082\u78ba\u7387\u304c\u9ad8\u304f\u306a\u308b\u30e9\u30d9\u30eb\u3092\u6b63\u89e3\u3068\u3059\u308b<br><br>\u3000\u3000\u3000\u500b\u3005\u306e\u6728\u3060\u3068\u904e\u5270\u9069\u5408\u3057\u3066\u3044\u308b\u304b\u3082\u3057\u308c\u306a\u3044\u304c\u3001<br>\u3000\u3000\u3000\u3000\u3000\u591a\u304f\u306e\u7d50\u679c\u3092\u96c6\u7d04\u3059\u308b\u3053\u3068\u3067\u904e\u5b66\u7fd2\u3092\u6291\u5236\u3059\u308b\u52b9\u679c\u304c\u3042\u308b<br><br>\u3000\u3000\u3000RandomForestClassifier\u00a0\u3092\u4f7f\u3046<br>\u3000\u3000\u3000\u3000\u3000\u52fe\u914d\u30d6\u30fc\u30b9\u30c6\u30a3\u30f3\u30b0\u56de\u5e30\u6728\u3082\u305f\u304f\u3055\u3093\u306e\u6c7a\u5b9a\u6728\u3092\u4f5c\u308b\u304c\u3001<br>\u3000\u3000\u3000\u3000\u3000\u3000\u3000\u4e00\u3064\u524d\u306e\u6c7a\u5b9a\u6728\u306e\u4e88\u6e2c\u5024\u3068\u6b63\u89e3\u306e\u30ba\u30ec\u3092\u4fee\u6b63\u3059\u308b\u3088\u3046\u306b<br>\u3000\u3000\u3000\u3000\u3000\u3000\u3000\u6b21\u306e\u6728\u3092\u4f5c\u3063\u3066\u3044\u304f<br><br>\u3000\u3000\u3000\u3000\u3000GradientBoostingClassifier\u00a0\u3092\u4f7f\u3046<br>\u3000\u3000\u3000\u3000\u3000\u3000\u3000\u30e9\u30f3\u30c0\u30e0\u30d5\u30a9\u30ec\u30b9\u30c8\u3088\u308a\u30e2\u30c7\u30eb\u69cb\u7bc9\u306b\u6642\u9593\u304c\u304b\u304b\u308a<br>\u3000\u3000\u3000\u3000\u3000\u3000\u3000\u30d1\u30e9\u30e1\u30fc\u30bf\u8a2d\u5b9a\u306e\u30c1\u30e5\u30fc\u30cb\u30f3\u30b0\u304c\u5927\u5909\u3089\u3057\u3044\u304c\u3001<br>\u3000\u3000\u3000\u3000\u3000\u3000\u3000\u305d\u306e\u5206\u4e88\u6e2c\u6027\u80fd\u304c\u3088\u304f\u306a\u308b<br>\u3000\u3000\u3000\u3000\u3000\u3000\u3000\u3000\u3000GBDT = Gradient Boosting Decision Tree<\/p>\n\n\n\n<div class=\"hcb_wrap\"><pre class=\"prism line-numbers lang-plain\"><code>from sklearn.ensemble import RandomForestClassifier\nfrom sklearn.ensemble import GradientBoostingClassifier\n\nfig, axes = plt.subplots(1, 2, figsize=(7, 3))\nclfs = [RandomForestClassifier(), GradientBoostingClassifier()]\ntitles = [&quot;RandomForestClassifier&quot;, &quot;GradientBoostingClassifier&quot;]\n\nfor ax, clf, title in zip(axes, clfs, titles):\n    decision_boundary(clf, X, y, ax, title)<\/code><\/pre><\/div>\n\n\n\n<p>\u3000<strong>\u30cb\u30e5\u30fc\u30e9\u30eb\u30cd\u30c3\u30c8\u30ef\u30fc\u30af<\/strong><br>\u3000\u3000\u3000MLPClassifier\u00a0\u3092\u4f7f\u3046<br>\u3000\u3000\u3000\u3000\u3000\u96a0\u308c\u5c64 15 \u500b\u3067\u8a08\u7b97\u3057\u305f\u7d50\u679c\u3092\u56f3\u793a\u3059\u308b<br>\u3000\u3000\u3000\u3000\u3000\u3000\u3000\u540c\u3058\u30d1\u30e9\u30e1\u30fc\u30bf\u3067\u3082\u6c7a\u5b9a\u5883\u754c\u304c\u7570\u306a\u3063\u3066\u304f\u308b<br>\u3000\u3000\u3000\u3000\u3000\u3000\u3000\u3000\u3000\u7570\u306a\u308b\u7406\u7531\u306f\u3001\u7570\u306a\u308b\u521d\u671f\u72b6\u614b\u304b\u3089\u5b66\u7fd2\u3092\u958b\u59cb\u3059\u308b\u304b\u3089<\/p>\n\n\n\n<div class=\"hcb_wrap\"><pre class=\"prism line-numbers lang-python\" data-lang=\"Python\"><code>from sklearn.neural_network import MLPClassifier\n\nfig, axes = plt.subplots(1, 4, figsize=(12, 3))\n\nfor ax, n in zip(axes, [15, 15, 15, 15]):\n    title = &quot;&quot;\n    clf = MLPClassifier(hidden_layer_sizes=[n, n])\n    decision_boundary(clf, X, y, ax, title)<\/code><\/pre><\/div>\n\n\n\n<h4 class=\"wp-block-heading\"><strong>\uff16\uff0e\u6559\u5e2b\u306a\u3057\u5b66\u7fd2<\/strong><\/h4>\n\n\n\n<p>\u3000<strong>k-means<\/strong><br>\u3000\u3000\u3000\u6559\u5e2b\u30c7\u30fc\u30bf\u306a\u3057\u3067\u5206\u985e\u3059\u308b\u624b\u6cd5<br><br>\u3000\u3000\u3000KMeans\u00a0\u3092\u4f7f\u3046<br>\u3000\u3000\u3000\u3000\u3000n_clusters\u3067\u4f55\u500b\u306b\u5206\u985e\u3059\u308b\u304b\u3092\u6307\u5b9a\u3059\u308b<\/p>\n\n\n\n<div class=\"hcb_wrap\"><pre class=\"prism line-numbers lang-python\" data-lang=\"Python\"><code>from sklearn.cluster import KMeans\n\nfig, axes = plt.subplots(1, 4, figsize=(12, 3))\n\nfor ax, n_clusters in zip(axes, [2, 3, 4, 5]):\n    title = &quot;n_clusters=%s&quot;% (n_clusters)\n    clf = KMeans(n_clusters=n_clusters)\n    decision_boundary(clf, X, y, ax, title)<\/code><\/pre><\/div>\n\n\n\n<p><\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u30fb\u300c\u3042\u3084\u3081\u300d\u306e\u7a2e\u985e\u3092\u5224\u5225\u3059\u308b\u6a5f\u68b0\u5b66\u7fd2\u306b\u3064\u3044\u3066<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[54],"tags":[24],"class_list":["post-4958","post","type-post","status-publish","format-standard","hentry","category-99_","tag-24"],"_links":{"self":[{"href":"https:\/\/yorozu.cloudfree.jp\/wordpress\/index.php?rest_route=\/wp\/v2\/posts\/4958","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/yorozu.cloudfree.jp\/wordpress\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/yorozu.cloudfree.jp\/wordpress\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/yorozu.cloudfree.jp\/wordpress\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/yorozu.cloudfree.jp\/wordpress\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=4958"}],"version-history":[{"count":27,"href":"https:\/\/yorozu.cloudfree.jp\/wordpress\/index.php?rest_route=\/wp\/v2\/posts\/4958\/revisions"}],"predecessor-version":[{"id":4990,"href":"https:\/\/yorozu.cloudfree.jp\/wordpress\/index.php?rest_route=\/wp\/v2\/posts\/4958\/revisions\/4990"}],"wp:attachment":[{"href":"https:\/\/yorozu.cloudfree.jp\/wordpress\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=4958"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/yorozu.cloudfree.jp\/wordpress\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=4958"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/yorozu.cloudfree.jp\/wordpress\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=4958"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}