{"id":312545,"date":"2020-11-04T15:00:41","date_gmt":"2020-11-04T15:00:41","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=312545"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=312545","title":{"rendered":"\u041d\u0430\u043f\u0438\u0448\u0435\u043c \u0438 \u043f\u043e\u0439\u043c\u0435\u043c Decision Tree \u043d\u0430 Python \u0441 \u043d\u0443\u043b\u044f! \u0427\u0430\u0441\u0442\u044c 4. \u0421\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u044b \u0434\u0430\u043d\u043d\u044b\u0445"},"content":{"rendered":"\n<div class=\"post__text post__text-html post__text_v1\" id=\"post-content-body\"><i>\u0414\u0430\u043d\u043d\u0430\u044f \u0441\u0442\u0430\u0442\u044c\u044f \u2014 \u0447\u0435\u0442\u0432\u0435\u0440\u0442\u0430\u044f \u0432 \u0441\u0435\u0440\u0438\u0438. \u0421\u0441\u044b\u043b\u043a\u0438 \u043d\u0430 \u043f\u0440\u0435\u0434\u044b\u0434\u0443\u0449\u0438\u0435 \u0441\u0442\u0430\u0442\u044c\u0438: <a href=\"https:\/\/habr.com\/ru\/post\/517556\/\">\u043f\u0435\u0440\u0432\u0430\u044f<\/a>, <a href=\"https:\/\/habr.com\/ru\/post\/518768\/\">\u0432\u0442\u043e\u0440\u0430\u044f<\/a>, <a href=\"https:\/\/habr.com\/ru\/post\/520204\/\">\u0442\u0440\u0435\u0442\u044c\u044f<\/a><\/i><\/p>\n<h2>4.1 \u0421\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u044b \u0434\u0430\u043d\u043d\u044b\u0445<\/h2>\n<p>  \u0421\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0430 \u0434\u0430\u043d\u043d\u044b\u0445 \u2014 \u044d\u0442\u043e \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u0442\u043e\u0433\u043e, \u043a\u0430\u043a \u043e\u0440\u0433\u0430\u043d\u0438\u0437\u043e\u0432\u0430\u043d\u044b \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u044b\u0435 \u0434\u0430\u043d\u043d\u044b\u0435.<\/p>\n<h3>\u041c\u0430\u0441\u0441\u0438\u0432<\/h3>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/webt\/eq\/mg\/p_\/eqmgp_ilgt8y_6ern_e8nwcjmtk.png\" alt=\"image\"><br \/>  <a name=\"habracut\"><\/a><br \/>  \u041e\u0442\u0434\u0435\u043b\u044c\u043d\u044b\u0435 \u0434\u0430\u043d\u043d\u044b\u0435 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u044b \u043e\u0434\u043d\u0438\u043c \u0440\u044f\u0434\u043e\u043c. \u0427\u0442\u043e\u0431\u044b \u0438\u0434\u0435\u043d\u0442\u0438\u0444\u0438\u0446\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043e\u0434\u0438\u043d \u0444\u0440\u0430\u0433\u043c\u0435\u043d\u0442 \u0434\u0430\u043d\u043d\u044b\u0445, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u043a\u0430\u043a\u0438\u043c \u043f\u043e \u043f\u043e\u0440\u044f\u0434\u043a\u0443 \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u044d\u0442\u043e\u0442 \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u044b\u0439 \u0444\u0440\u0430\u0433\u043c\u0435\u043d\u0442 \u043c\u0430\u0441\u0441\u0438\u0432\u0430, \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c \u0435\u0433\u043e \u0438\u0434\u0435\u043d\u0442\u0438\u0444\u0438\u043a\u0430\u0442\u043e\u0440.<\/p>\n<pre><code class=\"python\">#\u041f\u0440\u0438\u043c\u0435\u0440 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u043c\u0430\u0441\u0441\u0438\u0432\u0430 \u0432 Python a = [2,6,4,5,1,8]<\/code><\/pre>\n<p>  <\/p>\n<h3>\u0422\u0430\u0431\u043b\u0438\u0446\u0430, \u0434\u0432\u0443\u043c\u0435\u0440\u043d\u044b\u0439 \u043c\u0430\u0441\u0441\u0438\u0432<\/h3>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/webt\/dz\/to\/bd\/dztobd8arg2nsf6l2tvc5cvhoui.png\" alt=\"image\"><\/p>\n<p>  \u0414\u0430\u043d\u043d\u044b\u0435 \u0432\u044b\u0441\u0442\u0440\u043e\u0435\u043d\u044b \u0432 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0441\u0442\u043e\u043b\u0431\u0446\u043e\u0432, \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u044b\u0435 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u044b \u0434\u0432\u0443\u043c\u0435\u0440\u043d\u043e\u0433\u043e \u043c\u0430\u0441\u0441\u0438\u0432\u0430 \u0442\u0430\u043a\u0436\u0435 \u043e\u0431\u0440\u0430\u0437\u0443\u044e\u0442 \u0441\u0442\u0440\u043e\u043a\u0438.<\/p>\n<p>  \u0427\u0442\u043e\u0431\u044b \u0438\u0434\u0435\u043d\u0442\u0438\u0444\u0438\u0446\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0444\u0440\u0430\u0433\u043c\u0435\u043d\u0442 \u0434\u0430\u043d\u043d\u044b\u0445 \u0432 \u044d\u0442\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435, \u0442\u0440\u0435\u0431\u0443\u044e\u0442\u0441\u044f \u0434\u0432\u0430 \u0438\u0434\u0435\u043d\u0442\u0438\u0444\u0438\u043a\u0430\u0442\u043e\u0440\u0430: \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u043d\u043e\u043c\u0435\u0440 \u0441\u0442\u043e\u043b\u0431\u0446\u0430 \u0438 \u043d\u043e\u043c\u0435\u0440 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u0430.<\/p>\n<pre><code class=\"python\">#\u041f\u0440\u0438\u043c\u0435\u0440 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u0442\u0430\u0431\u043b\u0438\u0446\u044b \u0432 Python a = [ \u3000   [2,6,4,5,1,8], \u3000   [4,4,1,3,4,2], \u3000   [5,3,6,6,5,3], \u3000   [7,8,0,9,5,3], ]<\/code><\/pre>\n<p>  <\/p>\n<h3>Tree, \u0434\u0440\u0435\u0432\u043e\u0432\u0438\u0434\u043d\u0430\u044f \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0430<\/h3>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/webt\/ju\/ll\/0e\/jull0em01v0kcsi-vemunzgsaaq.png\"><\/p>\n<p>  \u042d\u0442\u043e \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0430 \u0434\u0430\u043d\u043d\u044b\u0445, \u0433\u0434\u0435 \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u044b\u0435 \u0434\u0430\u043d\u043d\u044b\u0435 \u043a\u0430\u043a \u0431\u0443\u0434\u0442\u043e \u0441\u0432\u044f\u0437\u0430\u043d\u044b \u043b\u0438\u043d\u0438\u0435\u0439. <\/p>\n<p>  \u042d\u0442\u0438 \u043b\u0438\u043d\u0438\u0438 \u044f\u0432\u043b\u044f\u044e\u0442\u0441\u044f \u043c\u0430\u0440\u0448\u0440\u0443\u0442\u043e\u043c, \u043d\u0430\u043f\u0440\u044f\u043c\u0443\u044e \u0441\u043e\u0435\u0434\u0438\u043d\u044f\u044e\u0449\u0438\u043c \u043e\u0434\u043d\u0438 \u0434\u0430\u043d\u043d\u044b\u0435 \u0441 \u0434\u0440\u0443\u0433\u0438\u043c\u0438. \u0418 \u043e\u0434\u0438\u043d \u0442\u0430\u043a\u043e\u0439 \u043c\u0430\u0440\u0448\u0440\u0443\u0442, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0438 \u0431\u0443\u0434\u0435\u0442 \u044f\u0432\u043b\u044f\u0442\u0441\u044f \u0434\u0440\u0435\u0432\u043e\u0432\u0438\u0434\u043d\u043e\u0439 \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u043e\u0439 \u0434\u0430\u043d\u043d\u044b\u0445.<\/p>\n<p>  \u0427\u0430\u0441\u0442\u043e \u0442\u0430\u043a\u0443\u044e \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0443 \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0430\u044e\u0442 \u043a\u0430\u043a \u0441\u0445\u0435\u043c\u0443, \u043d\u0430\u043f\u043e\u043c\u0438\u043d\u0430\u044e\u0449\u0443\u044e \u0440\u0430\u0441\u0442\u0443\u0449\u0435\u0435 \u0441\u0432\u0435\u0440\u0445\u0443 \u0432\u043d\u0438\u0437 \u0434\u0435\u0440\u0435\u0432\u043e. \u041b\u0438\u043d\u0438\u0438 \u043d\u0430\u0437\u044b\u0432\u0430\u044e\u0442\u0441\u044f \u0440\u0435\u0431\u0440\u0430\u043c\u0438 \u0438\u043b\u0438 \u0432\u0435\u0442\u0432\u044f\u043c\u0438, \u0434\u0430\u043d\u043d\u044b\u0435 \u2014 \u0443\u0437\u043b\u0430\u043c\u0438 (node), \u0434\u0430\u043d\u043d\u044b\u0435, \u043f\u043e\u0441\u043b\u0435 \u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u043b\u0438\u043d\u0438\u044f \u043d\u0435 \u043f\u0440\u043e\u0434\u043e\u043b\u0436\u0430\u0435\u0442\u0441\u044f, \u043d\u0430\u0437\u044b\u0432\u0430\u044e\u0442\u0441\u044f \u043b\u0438\u0441\u0442\u044c\u044f\u043c\u0438(leaf), \u0430 \u0434\u0430\u043d\u043d\u044b\u0435, \u0440\u0430\u0441\u043f\u043e\u043b\u0430\u0433\u0430\u044e\u0449\u0438\u0435\u0441\u044f \u043d\u0430 \u0441\u0430\u043c\u043e\u043c \u0432\u0435\u0440\u0445\u0443 \u2014 \u043a\u043e\u0440\u043d\u0435\u0432\u044b\u043c \u0443\u0437\u043b\u043e\u043c \u0438\u043b\u0438 \u043f\u0440\u043e\u0441\u0442\u043e \u043a\u043e\u0440\u043d\u0435\u043c.<\/p>\n<pre><code class=\"python\"># \u041f\u0440\u0438\u043c\u0435\u0440 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 Tree \u0432 Python, \u0441\u043e\u0434\u0435\u0440\u0436\u0430\u0449\u0438\u0439 \u0441\u043f\u0438\u0441\u043e\u043a \u0434\u043e\u0447\u0435\u0440\u043d\u0438\u0445 \u0443\u0437\u043b\u043e\u0432. # \u0417\u0430\u043f\u0438\u0441\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u0432 \u0444\u043e\u0440\u043c\u0430\u0442\u0435 [\u0417\u043d\u0430\u0447\u0435\u043d\u0438\u0435,\u0441\u043f\u0438\u0441\u043e\u043a \u0434\u043e\u0447\u0435\u0440\u043d\u0438\u0445 \u043c\u0430\u0441\u0441\u0438\u0432\u043e\u0432]. \u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0434\u0435\u0440\u0435\u0432\u043e \u0441 \u043a\u0430\u0440\u0442\u0438\u043d\u043a\u0438 \u0432\u044b\u0448\u0435 \u0431\u0443\u0434\u0435\u0442 \u0437\u0430\u043f\u0438\u0441\u044b\u0432\u0430\u0442\u044c\u0441\u044f \u0432 \u043f\u043e\u0440\u044f\u0434\u043a\u0435 \u0441\u0432\u0435\u0440\u0445\u0443 \u0432\u043d\u0438\u0437, \u0441\u043b\u0435\u0432\u0430 \u043d\u0430\u043f\u0440\u0430\u0432\u043e. # \u041f\u043e\u043c\u0438\u043c\u043e \u043f\u043e\u0434\u043e\u0431\u043d\u043e\u0439 \u0437\u0430\u043f\u0438\u0441\u0438, \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u044e\u0442 \u0432\u0430\u0440\u0438\u0430\u043d\u0442\u044b \u0441 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435\u043c \u043a\u043b\u0430\u0441\u0441\u043e\u0432, \u0440\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u0441\u043a\u0438\u0445 \u043d\u043e\u0434\u043e\u0432 \u0438 \u0434\u0440\u0443\u0433\u0438\u0435. tree = \\ [2,[      [6,[]],      [4,[           [5,[                [6,[]],           ]],           [8,[]],           [1,[]],      ]], ]]  # \u0424\u0443\u043d\u043a\u0446\u0438\u044f \u0434\u043b\u044f \u043f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u043e\u0432\u0430\u043d\u0438\u044f \u0434\u0440\u0435\u0432\u043e\u0432\u0438\u0434\u043d\u043e\u0439 \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u044b \u0432 \u0441\u0438\u043c\u0432\u043e\u043b\u044c\u043d\u0443\u044e def tstr(node,indent=&quot;&quot;):       s = indent+str(node[0])+&quot;\\n&quot;       for c in node[1]: # \u0426\u0438\u043a\u043b \u043d\u0430 \u0434\u043e\u0447\u0435\u0440\u043d\u0435\u043c \u043d\u043e\u0434\u0435            s += tstr(c,indent+&quot;+-&quot;)            pass       return s print(tstr(tree)) # \u0412\u044b\u0432\u043e\u0434 # 2 # +-6 # +-4 # +-+-5 # +-+-+-6 # +-+-8 # +-+-1  # \u041c\u043e\u0436\u043d\u043e \u043d\u0435 \u0441\u043e\u0437\u0434\u0430\u0432\u0430\u0442\u044c \u0432\u0441\u0435 \u0434\u0435\u0440\u0435\u0432\u043e \u0441\u0440\u0430\u0437\u0443, \u0430 \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0445 \u0434\u043b\u044f \u043d\u043e\u0434\u043e\u0432 # \u0421\u043e\u0437\u0434\u0430\u0435\u043c \u0432\u0441\u0435 \u043d\u043e\u0434\u044b-\u043b\u0438\u0441\u0442\u044c\u044f. \u0426\u0438\u0444\u0440\u0430 \u0432 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u043e\u0439 \u0443\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u0442 \u043d\u0430 \u0441\u0442\u0440\u043e\u043a\u0443 \u043d\u043e\u0434\u0430 \u0438 \u0435\u0433\u043e \u043f\u043e\u0440\u044f\u0434\u043a\u043e\u0432\u044b\u0439 \u043d\u043e\u043c\u0435\u0440 \u0432 \u044d\u0442\u043e\u0439 \u0441\u0442\u0440\u043e\u043a\u0435 \u0441\u043b\u0435\u0432\u0430 \u043d\u0430\u043f\u0440\u0430\u0432\u043e. n10 = [6,[]] n21 = [8,[]] n22 = [1,[]] n40 = [6,[]] # \u0421\u043e\u0437\u0434\u0430\u0435\u043c \u0440\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u0441\u043a\u0438\u0435 \u043d\u043e\u0434\u044b \u0434\u043b\u044f \u0443\u0436\u0435 \u0441\u043e\u0437\u0434\u0430\u043d\u043d\u044b\u0445 \u0434\u043e\u0447\u0435\u0440\u043d\u0438\u0445. n20 = [5,[n40]] n11 = [4,[n20,n21,n22]] n00 = [2,[n10,n11]]  # \u0412\u044b\u0432\u043e\u0434\u0438\u043c \u043f\u043e\u043b\u0443\u0447\u0438\u0432\u0448\u0435\u0435\u0441\u044f \u0414\u0440\u0435\u0432\u043e, \u0443\u043a\u0430\u0437\u0430\u0432 \u043d\u043e\u0434, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0441\u0447\u0438\u0442\u0430\u0442\u044c \u043a\u043e\u0440\u043d\u0435\u0432\u044b\u043c. print(tstr(n11)) # \u0412\u044b\u0432\u043e\u0434 # 4 # +-5 # +-+-6 # +-8 # +-1<\/code><\/pre>\n<p>  <\/p>\n<h3>Network \u0438\u043b\u0438 \u0433\u0440\u0430\u0444\u044b<\/h3>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/webt\/c6\/ad\/qp\/c6adqp0y21ztkwzstuhp-hufs4k.png\" alt=\"image\"><\/p>\n<p>  \u042d\u0442\u043e \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0430, \u0432 \u043a\u043e\u0442\u043e\u0440\u043e\u0439 \u0443 \u043e\u0434\u043d\u043e\u0433\u043e \u043d\u043e\u0434\u0430 \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0440\u0435\u0431\u0435\u0440. \u041e\u0442\u0434\u0435\u043b\u044c\u043d\u044b\u0435 \u0434\u0430\u043d\u043d\u044b\u0435 \u0442\u0430\u043a\u0436\u0435 \u043d\u0430\u0437\u044b\u0432\u0430\u044e\u0442\u0441\u044f \u0443\u0437\u043b\u0430\u043c\u0438, \u0430 \u043b\u0438\u043d\u0438\u0438 \u2014 \u0440\u0435\u0431\u0440\u0430\u043c\u0438. \u0417\u0430\u0447\u0430\u0441\u0442\u0443\u044e \u0432 \u0433\u0440\u0430\u0444\u0430\u0445 \u043d\u0435\u0442 \u043a\u043e\u0440\u043d\u0435\u0432\u043e\u0433\u043e \u0443\u0437\u043b\u0430, \u043a\u0430\u043a \u0432 \u0434\u0440\u0435\u0432\u043e\u0432\u0438\u0434\u043d\u043e\u0439 \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0435.<\/p>\n<pre><code class=\"python\"># \u0420\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f \u0433\u0440\u0430\u0444\u0430 \u043d\u0430 Python import pandas as pd  # \u0412 \u043d\u0430\u0448\u0435\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u0438\u043c\u044f \u0443\u0437\u043b\u0430 \u0438 \u0435\u0433\u043e \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u0441\u043e\u0432\u043f\u0430\u0434\u0430\u044e\u0442. # \u0415\u0441\u043b\u0438 \u0438\u043c\u044f \u043d\u043e\u0434\u0430 \u0438 \u0435\u0433\u043e \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u043d\u0435 \u0441\u043e\u0432\u043f\u0430\u0434\u0430\u044e\u0442, \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0431\u0443\u0434\u0435\u0442 \u0434\u043e\u0441\u0442\u0430\u0442\u044c \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u043d\u043e\u0434\u0430. nodes = [2,6,4,5,8,1] # \u0423\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u043c \u0441\u0432\u044f\u0437\u0438 \u043c\u0435\u0436\u0434\u0443 \u043d\u043e\u0434\u0430\u043c\u0438 \u0432 \u0432\u0438\u0434\u0435 \u043c\u0430\u0442\u0440\u0438\u0446\u044b. \u0415\u0441\u043b\u0438 \u043e\u0442 \u043d\u043e\u0434\u0430 2 (\u043f\u0435\u0440\u0432\u0430\u044f \u0441\u0442\u0440\u043e\u043a\u0430)\u043a \u043d\u043e\u0434\u0443 6 (\u0432\u0442\u043e\u0440\u0430\u044f \u0441\u0442\u0440\u043e\u043a\u0430) \u0438\u0441\u0445\u043e\u0434\u0438\u0442 \u0440\u0435\u0431\u0440\u043e,  # \u0417\u043d\u0430\u0447\u0435\u043d\u0438\u0435 1-\u043e\u0439 \u0441\u0442\u0440\u043e\u043a\u0438 2-\u043e\u0433\u043e \u0441\u0442\u043e\u043b\u0431\u0446\u0430 \u043c\u0430\u0442\u0440\u0438\u0446\u044b \u0431\u0443\u0434\u0435\u0442 1, \u0430 \u0435\u0441\u043b\u0438 \u0440\u0435\u0431\u0440\u043e \u043d\u0435 \u043f\u0440\u043e\u0445\u043e\u0434\u0438\u0442, \u0442\u043e - 0. \u0422\u0430\u043a\u0430\u044f \u043c\u0430\u0442\u0440\u0438\u0446\u0430 \u043d\u0430\u0437\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u043c\u0430\u0442\u0440\u0438\u0446\u0430 \u0441\u043c\u0435\u0436\u043d\u043e\u0441\u0442\u0438. df = pd.DataFrame( [ \u3000  # 2,6,4,5,8,1  \u3000  [ 0,1,1,0,0,0], # \u043e\u0442 \u043d\u043e\u0434\u0430 2 \u3000  [ 1,0,0,1,0,0], # \u043e\u0442 \u043d\u043e\u0434\u0430 6 \u3000  [ 1,0,0,1,1,1], # \u043e\u0442 \u043d\u043e\u0434\u0430 4 \u3000  [ 0,1,1,0,0,0], # \u043e\u0442 \u043d\u043e\u0434\u0430 5 \u3000  [ 0,0,1,0,0,0], # \u043e\u0442 \u043d\u043e\u0434\u0430 8 \u3000  [ 0,0,1,0,0,0], # \u043e\u0442 \u043d\u043e\u0434\u0430 1 ],columns=nodes,index=nodes) print(df) # \u0412\u044b\u0432\u043e\u0434 #     2  6  4  5  8  1 # 2  0  1  1  0  0  0 # 6  1  0  0  1  0  0 # 4  1  0  0  1  1  1 # 5  0  1  1  0  0  0 # 8  0  0  1  0  0  0 # 1  0  0  1  0  0  0  # \u0421 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a matplotlib \u0438 networkx \u0440\u0438\u0441\u0443\u0435\u043c \u0433\u0440\u0430\u0444. import matplotlib.pyplot as plt import networkx as nx plt.figure(figsize=(4,4)) plt.axis(&quot;off&quot;) nx.draw_networkx(nx.from_pandas_adjacency(df)) plt.show()<\/code><\/pre>\n<p>  \u0412\u044b\u0432\u043e\u0434:<\/p>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/webt\/qp\/h4\/dp\/qph4dpddfuzincagq0khbkbzbgu.png\" alt=\"image\"><\/p>\n<h2>4.2 \u041f\u0440\u0438\u043c\u0435\u0440 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 Decision Tree \u0432 Python<\/h2>\n<p>  Decision Tree, \u043a\u0430\u043a \u043f\u043e\u043d\u044f\u0442\u043d\u043e \u0438\u0437 \u043d\u0430\u0437\u0432\u0430\u043d\u0438\u044f, \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d \u0432 \u0432\u0438\u0434\u0435 \u0434\u0440\u0435\u0432\u043e\u0432\u0438\u0434\u043d\u043e\u0439 \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u044b. <br \/>  \u0412 \u043d\u043e\u0434\u0430\u0445 \u0445\u0440\u0430\u043d\u044f\u0442\u0441\u044f \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0435 \u0434\u0430\u043d\u043d\u044b\u0435: \u0441\u043f\u0438\u0441\u043e\u043a \u0434\u043e\u0447\u0435\u0440\u043d\u0438\u0445 \u043d\u043e\u0434\u043e\u0432, \u043f\u0440\u0430\u0432\u0438\u043b\u0430 \u0432\u0435\u0442\u0432\u043b\u0435\u043d\u0438\u044f, \u043f\u0443\u0442\u044c \u043e\u0442 \u043e\u0434\u043d\u043e\u0433\u043e \u043d\u043e\u0434\u0430 \u043a \u0434\u0440\u0443\u0433\u043e\u043c\u0443 \u0432 \u0440\u0430\u043c\u043a\u0430\u0445 Decision Tree.<\/p>\n<p>  \u041a\u0430\u043a \u043f\u043e\u043a\u0430\u0437\u0430\u043d\u043e \u043d\u0438\u0436\u0435, \u043a\u043e\u0440\u043d\u0435\u0432\u043e\u0439 \u0443\u0437\u0435\u043b \u0441\u043e\u0435\u0434\u0438\u043d\u044f\u0435\u0442 \u0432\u0441\u0435 \u0434\u0430\u043d\u043d\u044b\u0435. \u0427\u0438\u0441\u043b\u043e\u0432\u043e\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 [&#8230;], \u043f\u0440\u0438\u043a\u0440\u0435\u043f\u043b\u0435\u043d\u043d\u043e\u0435 \u043a \u0443\u0437\u043b\u0443, \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 \u0441\u043e\u0431\u043e\u0439 \u043d\u043e\u043c\u0435\u0440 \u0438\u0441\u0445\u043e\u0434\u043d\u044b\u0445 \u0434\u0430\u043d\u043d\u044b\u0445, \u0438\u0437 \u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u0441\u043e\u0437\u0434\u0430\u0435\u0442\u0441\u044f \u044d\u0442\u043e \u0434\u0435\u0440\u0435\u0432\u043e \u0440\u0435\u0448\u0435\u043d\u0438\u0439. \u0418\u0437 \u043a\u043e\u0440\u043d\u0435\u0432\u043e\u0433\u043e \u0443\u0437\u043b\u0430 \u201c\u0441\u043f\u0443\u0441\u043a\u0430\u044e\u0442\u0441\u044f\u201d \u0432\u043d\u0438\u0437 \u0442\u043e\u043b\u044c\u043a\u043e \u0442\u0435 \u0434\u0430\u043d\u043d\u044b\u0435, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0443\u0434\u043e\u0432\u043b\u0435\u0442\u0432\u043e\u0440\u044f\u044e\u0442 \u0443\u0441\u043b\u043e\u0432\u0438\u044f\u043c \u0434\u043e\u0447\u0435\u0440\u043d\u0438\u0445 \u0443\u0437\u043b\u043e\u0432. \u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u044d\u0442\u043e \u0432\u0438\u0434\u043d\u043e, \u0435\u0441\u043b\u0438 \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0435\u0442\u044c \u043d\u0430 \u0443\u0437\u043b\u044b \u201c\u0438\u0434\u0443 \u043d\u0430 \u0433\u043e\u043b\u044c\u0444\u201d \u0438 \u201c\u043d\u0435 \u0438\u0434\u0443 \u043d\u0430 \u0433\u043e\u043b\u044c\u0444\u201d \u0432 \u043f\u0435\u0440\u0432\u043e\u043c \u0434\u0435\u0440\u0435\u0432\u0435 \u0440\u0435\u0448\u0435\u043d\u0438\u0439.<\/p>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/webt\/9o\/xu\/7h\/9oxu7hb9ze1_4iavjio_kqmnbyg.png\" alt=\"image\"><\/p>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/webt\/kj\/ju\/he\/kjjuhecaqm8hbn4rhw8eetvmize.png\" alt=\"image\"><\/p>\n<p>  \u0420\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f \u0432 python-\u0435 \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c. \u0414\u0435\u043b\u0430\u0435\u043c \u043e\u0434\u0438\u043d \u0443\u0437\u0435\u043b \u0430\u0441\u0441\u043e\u0446\u0438\u0430\u0442\u0438\u0432\u043d\u044b\u043c \u043c\u0430\u0441\u0441\u0438\u0432\u043e\u043c, name \u2014 \u044d\u0442\u043e \u0441\u0438\u043c\u0432\u043e\u043b\u044c\u043d\u043e\u0435 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u044f \u044d\u0442\u043e\u0433\u043e \u0443\u0437\u043b\u0430, df \u2014 \u044d\u0442\u043e \u0434\u0430\u043d\u043d\u044b\u0435, \u0441\u0432\u044f\u0437\u0430\u043d\u043d\u044b\u0435 \u0441 \u044d\u0442\u0438\u043c \u0443\u0437\u043b\u043e\u043c, \u0430 \u0440\u0435\u0431\u0440\u0430 \u2014 \u044d\u0442\u043e \u0441\u043f\u0438\u0441\u043e\u043a \u0434\u043e\u0447\u0435\u0440\u043d\u0438\u0445 \u0443\u0437\u043b\u043e\u0432.<\/p>\n<pre><code class=\"python\"># \u0414\u0430\u043d\u043d\u044b\u0435 \u0434\u0440\u0435\u0432\u043e\u0432\u0438\u0434\u043d\u043e\u0439 \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u044b tree = {       # name: \u043d\u0430\u0437\u0432\u0430\u043d\u0438\u0435 \u044d\u0442\u043e\u0433\u043e \u0443\u0437\u043b\u0430       &quot;name&quot;:&quot;decision tree &quot;+df0.columns[-1]+&quot; &quot;+str(cstr(df0.iloc[:,-1])),       # df: \u0434\u0430\u043d\u043d\u044b\u0435, \u0441\u0432\u044f\u0437\u0430\u043d\u043d\u044b\u0435 \u0441 \u0434\u0430\u043d\u043d\u044b\u043c \u0443\u0437\u043b\u043e\u043c       &quot;df&quot;:df0, # edges: \u0441\u043f\u0438\u0441\u043e\u043a \u0440\u0435\u0431\u0435\u0440 (\u0432\u0435\u0442\u0432\u0435\u0439), \u0432\u044b\u0445\u043e\u0434\u044f\u0449\u0438\u0445 \u0438\u0437 \u0434\u0430\u043d\u043d\u043e\u0433\u043e \u0443\u0437\u043b\u0430. \u0415\u0441\u043b\u0438 \u0443\u0437\u0435\u043b \u043b\u0438\u0441\u0442\u043e\u0432\u043e\u0439, \u0442\u043e \u0435\u0441\u0442\u044c \u0435\u0441\u043b\u0438 \u0440\u0435\u0431\u0435\u0440 \u0443 \u043d\u0435\u0433\u043e \u043d\u0435\u0442, \u043c\u0430\u0441\u0441\u0438\u0432 \u043e\u0441\u0442\u0430\u0435\u0442\u0441\u044f \u043f\u0443\u0441\u0442\u044b\u043c.     &quot;edges&quot;:[], }<\/code><\/pre>\n<p>  \u0424\u0443\u043d\u043a\u0446\u0438\u044f tstr, \u0442\u0435\u043a\u0441\u0442\u0438\u0444\u0438\u0446\u0438\u0440\u0443\u044e\u0449\u0430\u044f \u0434\u0430\u043d\u043d\u0443\u044e \u0434\u0440\u0435\u0432\u043e\u0432\u0438\u0434\u043d\u0443\u044e \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0443, \u0431\u0443\u0434\u0435\u0442 \u0432\u044b\u0433\u043b\u044f\u0434\u0435\u0442\u044c \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c.<\/p>\n<pre><code class=\"python\"># \u041b\u044f\u043c\u0431\u0434\u0430-\u0432\u044b\u0440\u0430\u0436\u0435\u043d\u0438\u0435 \u0434\u043b\u044f \u0440\u0430\u0441\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u044f \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0439, \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442 - pandas.Series,  \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u043c\u043e\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 - \u043c\u0430\u0441\u0441\u0438\u0432 \u0441 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e\u043c \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u0438\u0437 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0439 # \u0418\u0437 \u0432\u0432\u043e\u0434\u043d\u044b\u0445 \u0434\u0430\u043d\u043d\u044b\u0445 s \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e value_counts() \u043d\u0430\u0445\u043e\u0434\u0438\u043c \u0447\u0430\u0441\u0442\u043e\u0442\u0443 \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u0438\u0437 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0439, \u0438 \u043f\u043e\u043a\u0430 \u0432 \u043d\u0430\u0448\u0435\u043c \u0441\u043b\u043e\u0432\u0430\u0440\u0435 \u0435\u0441\u0442\u044c \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u044b, \u0431\u0443\u0434\u0435\u0442 \u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c \u0446\u0438\u043a\u043b, \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0435\u043c\u044b\u0439 items(). # \u0427\u0442\u043e\u0431\u044b \u0432\u044b\u0445\u043e\u0434\u043d\u044b\u0435 \u0434\u0430\u043d\u043d\u044b\u0435 \u043d\u0435 \u043c\u0435\u043d\u044f\u043b\u0438\u0441\u044c \u0441 \u043a\u0430\u0436\u0434\u044b\u043c \u0437\u0430\u043f\u0443\u0441\u043a\u043e\u043c \u0446\u0438\u043a\u043b\u0430, \u043c\u044b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c sorted,  \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043c\u0435\u043d\u044f\u0435\u0442 \u043f\u043e\u0440\u044f\u0434\u043e\u043a \u043e\u0442 \u0431\u043e\u043b\u044c\u0448\u0435\u0433\u043e \u043a \u043c\u0435\u043d\u044c\u0448\u0435\u043c\u0443 # \u0412 \u0438\u0442\u043e\u0433\u0435, \u0433\u0435\u043d\u0435\u0440\u0438\u0440\u0443\u0435\u0442\u0441\u044f \u043c\u0430\u0441\u0441\u0438\u0432, \u0441\u043e\u0434\u0435\u0440\u0436\u0430\u0449\u0438\u0439 \u0441\u0442\u0440\u043e\u043a\u0443 \u0438\u0437 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0445 \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u043e\u0432: \u043a\u043b\u044e\u0447 (k) \u0438 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 (v). cstr = lambda s:[k+&quot;:&quot;+str(v) for k,v in sorted(s.value_counts().items())]  # \u041c\u0435\u0442\u043e\u0434 \u0442\u0435\u043a\u0441\u0442\u0438\u0444\u0438\u043a\u0430\u0446\u0438\u0438 \u0434\u0435\u0440\u0435\u0432\u0430: \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442 - tree (\u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0430 \u0434\u0430\u043d\u043d\u044b\u0445 \u0434\u0435\u0440\u0435\u0432\u0430), indent (\u043e\u0442\u0441\u0442\u0443\u043f \u0434\u043e\u0447\u0435\u0440\u043d\u0438\u0445 \u0443\u0437\u043b\u043e\u0432), # \u0410 \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u043c\u043e\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u0431\u0443\u0434\u0435\u0442 \u0442\u0435\u043a\u0441\u0442\u043e\u0432\u044b\u043c \u043e\u0442\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0435\u043c tree. \u0414\u0430\u043d\u043d\u044b\u0439 \u043c\u0435\u0442\u043e\u0434 \u0432\u044b\u0437\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u0440\u0435\u043a\u0443\u0440\u0441\u0438\u0432\u043d\u043e \u0434\u043b\u044f \u043f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u043e\u0432\u0430\u043d\u0438\u044f \u0432\u0441\u0435\u0433\u043e \u0432 \u0434\u0435\u0440\u0435\u0432\u0435 \u0432 \u0441\u0438\u043c\u0432\u043e\u043b\u044b. def tstr(tree,indent=&quot;&quot;):      # \u0421\u043e\u0437\u0434\u0430\u0435\u043c \u0441\u0438\u043c\u0432\u043e\u043b\u044c\u043d\u043e\u0435 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u044d\u0442\u043e\u0433\u043e \u0443\u0437\u043b\u0430. # \u0415\u0441\u043b\u0438 \u044d\u0442\u043e\u0442 \u0443\u0437\u0435\u043b \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043b\u0438\u0441\u0442\u043e\u0432\u044b\u043c \u0443\u0437\u043b\u043e\u043c (\u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u043e\u0432 \u0432 \u043c\u0430\u0441\u0441\u0438\u0432\u0435 \u0440\u0435\u0431\u0435\u0440 \u0440\u0430\u0432\u043d\u043e 0), # \u0427\u0430\u0441\u0442\u043e\u0442\u043d\u043e\u0435 \u0440\u0430\u0441\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u0435 \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u0435\u0433\u043e \u0441\u0442\u043e\u043b\u0431\u0446\u0430 \u0434\u0430\u043d\u043d\u044b\u0445 df, \u0441\u0432\u044f\u0437\u0430\u043d\u043d\u044b\u0445 \u0441 \u0434\u0435\u0440\u0435\u0432\u043e\u043c, \u043f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u0443\u0435\u0442\u0441\u044f \u0432 \u0441\u0438\u043c\u0432\u043e\u043b\u044b. s = indent+tree[&quot;name&quot;]+str(cstr(tree[&quot;df&quot;].iloc[:,-1]) if len(tree[&quot;edges&quot;])==0 else &quot;&quot;)+&quot;\\n&quot;       # \u0417\u0430\u0446\u0438\u043a\u043b\u0438\u0432\u0430\u0435\u043c \u0432\u0441\u0435 \u0432\u0435\u0442\u0432\u0438 \u044d\u0442\u043e\u0433\u043e \u0443\u0437\u043b\u0430. for e in tree[&quot;edges&quot;]: # \u0414\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u043c \u0441\u0438\u043c\u0432\u043e\u043b\u044c\u043d\u043e\u0435 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u0434\u043e\u0447\u0435\u0440\u043d\u0435\u0433\u043e \u0443\u0437\u043b\u0430 \u043a \u0441\u0438\u043c\u0432\u043e\u043b\u044c\u043d\u043e\u043c\u0443 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u0438\u044e \u0440\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u0441\u043a\u043e\u0433\u043e \u0443\u0437\u043b\u0430. # \u0414\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u043c \u0435\u0449\u0435 \u0431\u043e\u043b\u044c\u0448\u0435 \u0441\u0438\u043c\u0432\u043e\u043b\u043e\u0432 \u043a indent \u044d\u0442\u043e\u0433\u043e \u0443\u0437\u043b\u0430. s += tstr(e,indent+&quot;  &quot;) pass return s<\/code><\/pre>\n<p>  Decision Tree, \u0442\u0435\u043a\u0441\u0442\u0438\u0444\u0438\u0446\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u043e\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u0435\u0439 tstr, \u0431\u0443\u0434\u0435\u0442 \u0432\u044b\u0433\u043b\u044f\u0434\u0435\u0442\u044c \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c. \u0412 \u043a\u043e\u0440\u043d\u0435\u0432\u043e\u043c \u0443\u0437\u043b\u0435 \u043e\u0442\u043e\u0431\u0440\u0430\u0436\u0430\u0435\u0442\u0441\u044f \u0442\u0435\u043a\u0441\u0442 (decision tree \u0413\u043e\u043b\u044c\u0444), \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043c\u044b \u0437\u0430\u0434\u0430\u043b\u0438 \u0432 \u0441\u0430\u043c\u043e\u043c \u043d\u0430\u0447\u0430\u043b\u0435 \u043f\u0440\u0438 \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u0438 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u043e\u0439 tree, \u0430 \u0442\u0430\u043a\u0436\u0435 \u0447\u0430\u0441\u0442\u043e\u0442\u043d\u043e\u0435 \u0440\u0430\u0441\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u0435 \u00ab\u0438\u0434\u0443 \/ \u043d\u0435 \u0438\u0434\u0443 \u043d\u0430 \u0433\u043e\u043b\u044c\u0444\u00bb \u0441\u043e \u0432\u0441\u0435\u0445 \u0434\u0430\u043d\u043d\u044b\u0445. \u041a\u0430\u0436\u0434\u044b\u0439 \u0443\u0437\u0435\u043b \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u043d\u044b\u0439 \u043d\u0438\u0436\u0435, \u043e\u0442\u043e\u0431\u0440\u0430\u0436\u0430\u0435\u0442 \u043f\u0440\u0430\u0432\u0438\u043b\u0430 \u0432\u0435\u0442\u0432\u043b\u0435\u043d\u0438\u044f, \u0438 \u0432 \u0441\u043b\u0443\u0447\u0430\u0435, \u0435\u0441\u043b\u0438 \u0443\u0437\u0435\u043b \u043e\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u043b\u0438\u0441\u0442\u043e\u0432\u044b\u043c, \u043e\u0442\u043e\u0431\u0440\u0430\u0436\u0430\u0435\u0442\u0441\u044f \u0447\u0430\u0441\u0442\u043e\u0442\u043d\u043e\u0435 \u0440\u0430\u0441\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u0435 \u00ab\u0438\u0434\u0443 \/ \u043d\u0435 \u0438\u0434\u0443 \u043d\u0430 \u0433\u043e\u043b\u044c\u0444\u00bb \u043d\u0430 \u043e\u0441\u043d\u043e\u0432\u0435 \u0434\u0430\u043d\u043d\u044b\u0445, \u0441\u0432\u044f\u0437\u0430\u043d\u043d\u044b\u0445 \u0441 \u044d\u0442\u0438\u043c \u0443\u0437\u043b\u043e\u043c.<\/p>\n<pre><code class=\"python\">decision tree \u0413\u043e\u043b\u044c\u0444 ['\u00d7:5', '\u25cb:9']   \u041f\u043e\u0433\u043e\u0434\u0430=\u042f\u0441\u043d\u043e     \u0412\u043b\u0430\u0436\u043d\u043e\u0441\u0442\u044c=\u041d\u043e\u0440\u043c\u0430\u043b\u044c\u043d\u0430\u044f['\u25cb:2']     \u0412\u043b\u0430\u0436\u043d\u043e\u0441\u0442\u044c=\u0412\u044b\u0441\u043e\u043a\u0430\u044f['\u00d7:3']  \u041f\u043e\u0433\u043e\u0434\u0430=\u041e\u0431\u043b\u0430\u0447\u043d\u043e['\u25cb:4']  \u041f\u043e\u0433\u043e\u0434\u0430=\u0414\u043e\u0436\u0434\u044c     \u0412\u0435\u0442\u0435\u0440=\u0415\u0441\u0442\u044c['\u00d7:2']     \u0412\u0435\u0442\u0435\u0440=\u041d\u0435\u0442['\u25cb:3']<\/code><\/pre>\n<p>  <i>\u0421\u043f\u0430\u0441\u0438\u0431\u043e \u0437\u0430 \u043f\u0440\u043e\u0447\u0442\u0435\u043d\u0438\u0435!<\/p>\n<p>  \u041c\u044b \u0431\u0443\u0434\u0435\u043c \u043e\u0447\u0435\u043d\u044c \u0440\u0430\u0434\u044b, \u0435\u0441\u043b\u0438 \u0432\u044b \u0440\u0430\u0441\u0441\u043a\u0430\u0436\u0435\u0442\u0435 \u043d\u0430\u043c, \u043f\u043e\u043d\u0440\u0430\u0432\u0438\u043b\u0430\u0441\u044c \u043b\u0438 \u0432\u0430\u043c \u0434\u0430\u043d\u043d\u0430\u044f \u0441\u0442\u0430\u0442\u044c\u044f, \u043f\u043e\u043d\u044f\u0442\u0435\u043d \u043b\u0438 \u043f\u0435\u0440\u0435\u0432\u043e\u0434, \u0431\u044b\u043b\u0430 \u043b\u0438 \u043e\u043d\u0430 \u0432\u0430\u043c \u043f\u043e\u043b\u0435\u0437\u043d\u0430?<\/i><\/div>\n<p> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"https:\/\/habr.com\/ru\/post\/526316\/\"> https:\/\/habr.com\/ru\/post\/526316\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"\n<div class=\"post__text post__text-html post__text_v1\" id=\"post-content-body\"><i>\u0414\u0430\u043d\u043d\u0430\u044f \u0441\u0442\u0430\u0442\u044c\u044f \u2014 \u0447\u0435\u0442\u0432\u0435\u0440\u0442\u0430\u044f \u0432 \u0441\u0435\u0440\u0438\u0438. \u0421\u0441\u044b\u043b\u043a\u0438 \u043d\u0430 \u043f\u0440\u0435\u0434\u044b\u0434\u0443\u0449\u0438\u0435 \u0441\u0442\u0430\u0442\u044c\u0438: <a href=\"https:\/\/habr.com\/ru\/post\/517556\/\">\u043f\u0435\u0440\u0432\u0430\u044f<\/a>, <a href=\"https:\/\/habr.com\/ru\/post\/518768\/\">\u0432\u0442\u043e\u0440\u0430\u044f<\/a>, <a href=\"https:\/\/habr.com\/ru\/post\/520204\/\">\u0442\u0440\u0435\u0442\u044c\u044f<\/a><\/i><\/p>\n<h2>4.1 \u0421\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u044b \u0434\u0430\u043d\u043d\u044b\u0445<\/h2>\n<p>  \u0421\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0430 \u0434\u0430\u043d\u043d\u044b\u0445 \u2014 \u044d\u0442\u043e \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u0442\u043e\u0433\u043e, \u043a\u0430\u043a \u043e\u0440\u0433\u0430\u043d\u0438\u0437\u043e\u0432\u0430\u043d\u044b \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u044b\u0435 \u0434\u0430\u043d\u043d\u044b\u0435.<\/p>\n<h3>\u041c\u0430\u0441\u0441\u0438\u0432<\/h3>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/webt\/eq\/mg\/p_\/eqmgp_ilgt8y_6ern_e8nwcjmtk.png\" alt=\"image\">  <\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"class_list":["post-312545","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/312545","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=312545"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/312545\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=312545"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=312545"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=312545"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}