{"id":298864,"date":"2020-02-18T15:00:14","date_gmt":"2020-02-18T15:00:14","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=298864"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=298864","title":{"rendered":"\u041f\u0440\u0435\u0434\u0441\u043a\u0430\u0437\u0430\u043d\u0438\u0435 \u0441\u0442\u043e\u0438\u043c\u043e\u0441\u0442\u0438 \u0431\u0438\u0442\u043a\u043e\u0438\u043d\u0430 \u043f\u043e \u043d\u043e\u0432\u043e\u0441\u0442\u044f\u043c \u043d\u0430 Python"},"content":{"rendered":"\n<div class=\"post__text post__text-html\" id=\"post-content-body\" data-io-article-url=\"https:\/\/habr.com\/ru\/company\/otus\/blog\/488912\/\"><i><b>\u041f\u0435\u0440\u0435\u0432\u043e\u0434 \u0441\u0442\u0430\u0442\u044c\u0438 \u043f\u043e\u0434\u0433\u043e\u0442\u043e\u0432\u043b\u0435\u043d \u0432 \u043f\u0440\u0435\u0434\u0434\u0432\u0435\u0440\u0438\u0438 \u0441\u0442\u0430\u0440\u0442\u0430 \u043a\u0443\u0440\u0441\u0430 <a href=\"https:\/\/otus.pw\/pHAO\/\">\u00abMachine Learning\u00bb<\/a> \u043e\u0442 OTUS.<\/b><\/i><\/p>\n<hr>\n<p>   <\/p>\n<h3>\u0417\u0430\u0434\u0430\u0447\u0430<\/h3>\n<p>   \u0412 \u044d\u0442\u043e\u043c \u0440\u0443\u043a\u043e\u0432\u043e\u0434\u0441\u0442\u0432\u0435 \u043c\u044b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c \u0434\u0430\u0442\u0430\u0441\u0435\u0442 <i><a href=\"https:\/\/www.openblender.io\/#\/dataset\/explore\/5d4c3af79516290b01c83f51\/or\/21\">Bitcoin vs USD<\/a>.<\/i><\/p>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/webt\/wk\/bg\/mn\/wkbgmnndnzujik02hufs9et9m2k.png\"><\/p>\n<p>   \u0412\u044b\u0448\u0435\u043f\u0440\u0438\u0432\u0435\u0434\u0435\u043d\u043d\u044b\u0439 \u0434\u0430\u0442\u0430\u0441\u0435\u0442 \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u0442 \u0435\u0436\u0435\u0434\u043d\u0435\u0432\u043d\u0443\u044e \u0441\u0432\u043e\u0434\u043a\u0443 \u0446\u0435\u043d, \u0433\u0434\u0435 \u043a\u043e\u043b\u043e\u043d\u043a\u0430 CHANGE \u2013 \u044d\u0442\u043e \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u0435 \u0446\u0435\u043d\u044b \u0432 \u043f\u0440\u043e\u0446\u0435\u043d\u0442\u0430\u0445 \u043e\u0442 \u0446\u0435\u043d\u044b \u0437\u0430 \u043f\u0440\u0435\u0434\u044b\u0434\u0443\u0449\u0438\u0439 \u0434\u0435\u043d\u044c (<i>PRICE<\/i>) \u043f\u043e \u043e\u0442\u043d\u043e\u0448\u0435\u043d\u0438\u044e \u043a \u043d\u043e\u0432\u043e\u0439 (<i>OPEN<\/i>).<\/p>\n<p>  <b>\u0426\u0435\u043b\u044c:<\/b> \u0427\u0442\u043e\u0431\u044b \u0443\u043f\u0440\u043e\u0441\u0442\u0438\u0442\u044c \u0437\u0430\u0434\u0430\u0447\u0443, \u043c\u044b \u0441\u043e\u0441\u0440\u0435\u0434\u043e\u0442\u043e\u0447\u0438\u043c\u0441\u044f \u043d\u0430 \u043f\u0440\u043e\u0433\u043d\u043e\u0437\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0438 \u0442\u043e\u0433\u043e, \u0432\u043e\u0437\u0440\u0430\u0441\u0442\u0435\u0442 \u043b\u0438 \u0446\u0435\u043d\u0430 (<i>CHANGE &gt; 0<\/i>) \u0438\u043b\u0438 \u0443\u043f\u0430\u0434\u0435\u0442 (<i>CHANGE &lt; 0<\/i>) \u043d\u0430 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0439 \u0434\u0435\u043d\u044c. (\u0422\u0430\u043a \u043c\u044b \u043f\u043e\u0442\u0435\u043d\u0446\u0438\u0430\u043b\u044c\u043d\u043e \u0441\u043c\u043e\u0436\u0435\u043c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043f\u0440\u0435\u0434\u0441\u043a\u0430\u0437\u0430\u043d\u0438\u044f \u00ab\u0432 \u0440\u0435\u0430\u043b\u044c\u043d\u043e\u0439 \u0436\u0438\u0437\u043d\u0438\u00bb).<\/p>\n<p>  <b>\u0422\u0440\u0435\u0431\u043e\u0432\u0430\u043d\u0438\u044f<\/b><\/p>\n<ul>\n<li>\u0412 \u0441\u0438\u0441\u0442\u0435\u043c\u0435 \u0434\u043e\u043b\u0436\u0435\u043d \u0431\u044b\u0442\u044c \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u043b\u0435\u043d Python 2.6+ \u0438\u043b\u0438 3.1+<\/li>\n<li>\u0423\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u0435 <i>pandas<\/i>, <i>sklearn <\/i>\u0438 <i>openblender <\/i>(\u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e pip)<\/li>\n<\/ul>\n<pre><code class=\"python\">$ pip install pandas OpenBlender scikit-learn<\/code><\/pre>\n<p><a name=\"habracut\"><\/a><\/p>\n<h3>\u0428\u0430\u0433 1. \u041f\u043e\u043b\u0443\u0447\u0438\u043c \u0434\u0430\u043d\u043d\u044b\u0435 \u043e \u0431\u0438\u0442\u043a\u043e\u0438\u043d\u0435<\/h3>\n<p>  \u0414\u043b\u044f \u043d\u0430\u0447\u0430\u043b\u0430 \u0434\u0430\u0432\u0430\u0439\u0442\u0435 \u0438\u043c\u043f\u043e\u0440\u0442\u0438\u0440\u0443\u0435\u043c \u043d\u0443\u0436\u043d\u044b\u0435 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438:<\/p>\n<pre><code class=\"python\">import OpenBlender import pandas as pd import json<\/code><\/pre>\n<p>  \u0410 \u0442\u0435\u043f\u0435\u0440\u044c \u0432\u044b\u0442\u0430\u0449\u0438\u043c \u0434\u0430\u043d\u043d\u044b\u0435 \u0447\u0435\u0440\u0435\u0437 <a href=\"https:\/\/www.openblender.io\/#\/welcome\/or\/21\">OpenBlender API<\/a>. <br \/>  \u0414\u043b\u044f \u043d\u0430\u0447\u0430\u043b\u0430 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u043c \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u044b (\u0432 \u043d\u0430\u0448\u0435\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u044d\u0442\u043e \u043f\u0440\u043e\u0441\u0442\u043e <i>id<\/i> <a href=\"https:\/\/www.openblender.io\/#\/dataset\/explore\/5d4c3af79516290b01c83f51\/or\/21\">\u0434\u0430\u0442\u0430\u0441\u0435\u0442\u0430 \u0431\u0438\u0442\u043a\u043e\u0438\u043d\u0430<\/a>):<\/p>\n<pre><code class=\"python\"># It only contains the id, we'll add more parameters later. parameters = {   'id_dataset':'5d4c3af79516290b01c83f51' }<\/code><\/pre>\n<p>  <b>\u041f\u0440\u0438\u043c\u0435\u0447\u0430\u043d\u0438\u0435:<\/b> \u0432\u0430\u043c \u043d\u0443\u0436\u043d\u043e \u0431\u0443\u0434\u0435\u0442 \u0437\u0430\u0432\u0435\u0441\u0442\u0438 \u0430\u043a\u043a\u0430\u0443\u043d\u0442 \u043d\u0430 <a href=\"https:\/\/www.openblender.io\/#\/welcome\/or\/21\">openblender.io<\/a> (\u044d\u0442\u043e \u0431\u0435\u0441\u043f\u043b\u0430\u0442\u043d\u043e) \u0438 \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u0442\u043e\u043a\u0435\u043d (\u0435\u0433\u043e \u0432\u044b \u043d\u0430\u0439\u0434\u0435\u0442\u0435 \u0432\u043e \u0432\u043a\u043b\u0430\u0434\u043a\u0435 \u00ab\u0423\u0447\u0435\u0442\u043d\u0430\u044f \u0437\u0430\u043f\u0438\u0441\u044c\u00bb):<\/p>\n<pre><code class=\"python\">parameters = {         'token':'your_token',    'id_dataset':'5d4c3af79516290b01c83f51' }<\/code><\/pre>\n<p>  \u0410 \u0442\u0435\u043f\u0435\u0440\u044c \u0434\u0430\u0432\u0430\u0439\u0442\u0435 \u043f\u043e\u043b\u043e\u0436\u0438\u043c \u0434\u0430\u043d\u043d\u044b\u0435 \u0432 Dataframe<i> \u2018df\u2019<\/i>:<\/p>\n<pre><code class=\"python\"># This function pulls the data and orders by timestamp def pullObservationsToDF(parameters):     action = 'API_getObservationsFromDataset'     df = pd.read_json(json.dumps(OpenBlender.call(action,parameters)['sample']), convert_dates=False,convert_axes=False) .sort_values('timestamp', ascending=False)     df.reset_index(drop=True, inplace=True)     return df df = pullObservationsToDF(parameters)<\/code><\/pre>\n<p>  \u0418 \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u043d\u0430 \u043d\u0438\u0445:<\/p>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/webt\/-z\/4h\/-8\/-z4h-8wb3yoirdqzjxo4ppfmn4g.png\"><\/p>\n<p>  <b>\u041f\u0440\u0438\u043c\u0435\u0447\u0430\u043d\u0438\u0435:<\/b> \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u043c\u043e\u0433\u0443\u0442 \u043e\u0442\u043b\u0438\u0447\u0430\u0442\u044c\u0441\u044f, \u043f\u043e\u0441\u043a\u043e\u043b\u044c\u043a\u0443 <i>\u0434\u0430\u0442\u0430\u0441\u0435\u0442 \u043e\u0431\u043d\u043e\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0435\u0436\u0435\u0434\u043d\u0435\u0432\u043d\u043e<\/i>!<\/p>\n<h3>\u0428\u0430\u0433 2. \u041f\u043e\u0434\u0433\u043e\u0442\u043e\u0432\u043a\u0430 \u0434\u0430\u043d\u043d\u044b\u0445<\/h3>\n<p>  \u0414\u043b\u044f \u043d\u0430\u0447\u0430\u043b\u0430 \u043d\u0430\u043c \u043d\u0443\u0436\u043d\u043e \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u0442\u0430\u0440\u0433\u0435\u0442 \u0434\u043b\u044f \u043f\u0440\u043e\u0433\u043d\u043e\u0437\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0431\u0443\u0434\u0435\u0442 \u0437\u0430\u043a\u043b\u044e\u0447\u0430\u0442\u044c\u0441\u044f \u0432 \u0442\u043e\u043c \u0431\u0443\u0434\u0435\u0442 \u043b\u0438 \u00ab<i>CHANGE<\/i>\u00bb \u0443\u0432\u0435\u043b\u0438\u0447\u0438\u0432\u0430\u0442\u044c\u0441\u044f \u0438\u043b\u0438 \u0443\u043c\u0435\u043d\u044c\u0448\u0430\u0442\u044c\u0441\u044f. \u0414\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u0434\u043e\u0431\u0430\u0432\u0438\u043c <i>&#8216;success_thr_over&#8217;: 0<\/i> \u0432 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u044b target threshold:<\/p>\n<pre><code class=\"python\">parameters = {    'token':'your_token',       'id_dataset':'5d4c3af79516290b01c83f51',    'target_threshold':{'feature':'change', 'success_thr_over': 0} }<\/code><\/pre>\n<p>  \u0415\u0441\u043b\u0438 \u043c\u044b \u0441\u043d\u043e\u0432\u0430 \u043f\u043e\u0434\u0442\u044f\u043d\u0435\u043c \u0434\u0430\u043d\u043d\u044b\u0435 \u0438\u0437 API:<\/p>\n<pre><code class=\"python\">df = pullObservationsToDF(parameters) df.head() <\/code><\/pre>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/webt\/qh\/m8\/fo\/qhm8fomikwusfr70hrkbq0ngoxm.png\"><\/p>\n<p>  \u041f\u0440\u0438\u0437\u043d\u0430\u043a \u00abCHANGE\u00bb \u0431\u044b\u043b \u0437\u0430\u043c\u0435\u043d\u0435\u043d \u043d\u0430 \u043d\u043e\u0432\u044b\u0439 \u043f\u0440\u0438\u0437\u043d\u0430\u043a \u2018change_over_0\u2019, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0432\u0441\u0442\u0430\u0435\u0442 \u0432 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 1, \u0435\u0441\u043b\u0438 \u00abCHANGE\u00bb \u043f\u043e\u043b\u043e\u0436\u0438\u0442\u0435\u043b\u0435\u043d \u0438 \u0432 0, \u0435\u0441\u043b\u0438 \u043d\u0435\u0442. \u042d\u0442\u043e \u0431\u0443\u0434\u0435\u0442 \u0442\u0430\u0440\u0433\u0435\u0442\u043e\u043c \u0434\u043b\u044f \u043c\u0430\u0448\u0438\u043d\u043d\u043e\u0433\u043e \u043e\u0431\u0443\u0447\u0435\u043d\u0438\u044f.<\/p>\n<p>  \u0415\u0441\u043b\u0438 \u043c\u044b \u0445\u043e\u0442\u0438\u043c \u043f\u0440\u0435\u0434\u0441\u043a\u0430\u0437\u0430\u0442\u044c \u043d\u0430\u0431\u043b\u044e\u0434\u0435\u043d\u0438\u0435 \u043d\u0430 \u00ab\u0437\u0430\u0432\u0442\u0440\u0430\u00bb, \u043c\u044b \u043d\u0435 \u0441\u043c\u043e\u0436\u0435\u043c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044e \u0438\u0437 \u0437\u0430\u0432\u0442\u0440\u0430\u0448\u043d\u0435\u0433\u043e \u0434\u043d\u044f, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u0434\u0430\u0432\u0430\u0439\u0442\u0435 \u0434\u043e\u0431\u0430\u0432\u0438\u043c \u0437\u0430\u0434\u0435\u0440\u0436\u043a\u0443 \u043d\u0430 \u043e\u0434\u0438\u043d \u043f\u0435\u0440\u0438\u043e\u0434.<\/p>\n<pre><code class=\"python\">parameters = {     'token':'your_token',    'id_dataset':'5d4c3af79516290b01c83f51',    'target_threshold':{'feature':'change','success_thr_over' : 0},    'lag_target_feature':{'feature':'change_over_0', 'periods' : 1} } df = pullObservationsToDF(parameters) df.head()<\/code><\/pre>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/webt\/vc\/5d\/ls\/vc5dlsyp0fwduvl4xysdw3shbn8.png\"><\/p>\n<p>  \u042d\u0442\u043e \u043f\u0440\u043e\u0441\u0442\u043e \u0432\u044b\u0440\u043e\u0432\u043d\u044f\u0435\u0442 <i>\u2018change_over_0\u2019<\/i> \u0441 \u0434\u0430\u043d\u043d\u044b\u043c\u0438 \u0437\u0430 \u043f\u0440\u0435\u0434\u044b\u0434\u0443\u0449\u0438\u0439 \u0434\u0435\u043d\u044c (\u043f\u0435\u0440\u0438\u043e\u0434) \u0438 \u0438\u0437\u043c\u0435\u043d\u0438\u0442 \u0435\u0433\u043e \u0438\u043c\u044f \u043d\u0430 <i>\u2018TARGET_change_over_0\u2019<\/i>.<\/p>\n<p>  \u0414\u0430\u0432\u0430\u0439\u0442\u0435 \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u043d\u0430 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u044c:<\/p>\n<pre><code class=\"python\">target_variable = 'TARGET_change_over_0' df = df.dropna() df.corr()[target_variable].sort_values()<\/code><\/pre>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/webt\/rt\/bw\/th\/rtbwthonochdngu_4g1n3e9bilq.png\"><\/p>\n<p>  \u041e\u043d\u0438 \u043b\u0438\u043d\u0435\u0439\u043d\u043e \u043d\u0435\u0437\u0430\u0432\u0438\u0441\u0438\u043c\u044b \u0438 \u0432\u0440\u044f\u0434 \u043b\u0438 \u0431\u0443\u0434\u0443\u0442 \u043f\u043e\u043b\u0435\u0437\u043d\u044b.<\/p>\n<h3>\u0428\u0430\u0433 3. \u041f\u043e\u043b\u0443\u0447\u0438\u043c \u0434\u0430\u043d\u043d\u044b\u0435 Business News<\/h3>\n<p>  \u041f\u043e\u0441\u043b\u0435 \u043f\u043e\u0438\u0441\u043a\u0430 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0435\u0439 \u0432 <a href=\"https:\/\/www.openblender.io\/#\/welcome\/or\/21\">OpenBlender<\/a>, \u044f \u043d\u0430\u0448\u0435\u043b \u0434\u0430\u0442\u0430\u0441\u0435\u0442 <a href=\"https:\/\/www.openblender.io\/#\/dataset\/explore\/5d571f9e9516293a12ad4f6d\/or\/21\">Fox Business News<\/a>, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043f\u043e\u043c\u043e\u0436\u0435\u0442 \u0433\u0435\u043d\u0435\u0440\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0445\u043e\u0440\u043e\u0448\u0438\u0435 \u043f\u0440\u043e\u0433\u043d\u043e\u0437\u044b \u0434\u043b\u044f \u043d\u0430\u0448\u0435\u0433\u043e \u0442\u0430\u0440\u0433\u0435\u0442\u0430.<\/p>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/webt\/gp\/ew\/0g\/gpew0gbik-c0hp74ankokglcr7g.png\"><\/p>\n<p>  \u041d\u0430\u043c \u043d\u0443\u0436\u043d\u043e \u043d\u0430\u0439\u0442\u0438 \u0441\u043f\u043e\u0441\u043e\u0431 \u043f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u043e\u0432\u0430\u0442\u044c \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u0441\u0442\u043e\u043b\u0431\u0446\u0430 <i>\u2018title\u2019<\/i> \u0432 \u0447\u0438\u0441\u043b\u043e\u0432\u044b\u0435 \u0445\u0430\u0440\u0430\u043a\u0442\u0435\u0440\u0438\u0441\u0442\u0438\u043a\u0438, \u043f\u043e\u0434\u0441\u0447\u0438\u0442\u0430\u0432 \u043f\u043e\u0432\u0442\u043e\u0440\u0435\u043d\u0438\u044f \u0441\u043b\u043e\u0432 \u0438 \u0433\u0440\u0443\u043f\u043f \u0441\u043b\u043e\u0432 \u0432 \u0441\u0432\u043e\u0434\u043a\u0435 \u043d\u043e\u0432\u043e\u0441\u0442\u0435\u0439, \u0438 \u0441\u043e\u043f\u043e\u0441\u0442\u0430\u0432\u0438\u0442\u044c \u0438\u0445 \u043f\u043e \u0432\u0440\u0435\u043c\u0435\u043d\u0438 \u0441 \u043d\u0430\u0448\u0438\u043c \u0434\u0430\u0442\u0430\u0441\u0435\u0442\u043e\u043c \u0431\u0438\u0442\u043a\u043e\u0438\u043d\u0430. \u042d\u0442\u043e \u043f\u0440\u043e\u0449\u0435, \u0447\u0435\u043c \u043a\u0430\u0436\u0435\u0442\u0441\u044f.<\/p>\n<p>  \u0414\u043b\u044f \u043d\u0430\u0447\u0430\u043b\u0430 \u043d\u0443\u0436\u043d\u043e \u0441\u043e\u0437\u0434\u0430\u0442\u044c <i>TextVectorizer <\/i>\u0434\u043b\u044f \u043f\u0440\u0438\u0437\u043d\u0430\u043a\u0430 <i>\u2018title\u2019<\/i> \u0443 \u043d\u043e\u0432\u043e\u0441\u0442\u0438:<\/p>\n<pre><code class=\"python\">action = 'API_createTextVectorizer' vectorizer_parameters = {     'token' : 'your_token',     'name' : 'Fox Business TextVectorizer',     'sources':[{'id_dataset' : '5d571f9e9516293a12ad4f6d',                 'features' : ['title']}],     'ngram_range' : {'min' : 1, 'max' : 2},     'language' : 'en',     'remove_stop_words' : 'on',     'min_count_limit' : 2 }<\/code><\/pre>\n<p>  \u041c\u044b \u0441\u043e\u0437\u0434\u0430\u0434\u0438\u043c \u0432\u0435\u043a\u0442\u043e\u0440\u0438\u0437\u0430\u0442\u043e\u0440, \u0447\u0442\u043e\u0431\u044b \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u0432\u0441\u0435 \u043f\u0440\u0438\u0437\u043d\u0430\u043a\u0438 \u043a\u0430\u043a \u0441\u043b\u043e\u0432\u0430-\u0442\u043e\u043a\u0435\u043d\u044b \u0432 \u0432\u0438\u0434\u0435 \u0447\u0438\u0441\u0435\u043b. \u0412\u044b\u0448\u0435 \u043c\u044b \u0443\u043a\u0430\u0437\u0430\u043b\u0438 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u0435:<\/p>\n<ul>\n<li><i>name<\/i>: \u043d\u0430\u0437\u043e\u0432\u0435\u043c \u0435\u0433\u043e <i>\u2018Fox Business TextVectorizer\u2019<\/i>;<\/li>\n<li><i>anchor<\/i>: id \u0434\u0430\u0442\u0430\u0441\u0435\u0442\u0430 \u0438 \u043d\u0430\u0437\u0432\u0430\u043d\u0438\u044f \u043f\u0440\u0438\u0437\u043d\u0430\u043a\u043e\u0432, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043d\u0430\u043c \u043d\u0443\u0436\u043d\u043e \u0431\u0443\u0434\u0435\u0442 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0432 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u0438\u0441\u0442\u043e\u0447\u043d\u0438\u043a\u0430 (\u0432 \u043d\u0430\u0448\u0435\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u0442\u043e\u043b\u044c\u043a\u043e \u0441\u0442\u043e\u043b\u0431\u0435\u0446 <i>\u2018title\u2019<\/i>);<\/li>\n<li><i>ngram_range<\/i>: \u043c\u0438\u043d\u0438\u043c\u0430\u043b\u044c\u043d\u0430\u044f \u0438 \u043c\u0430\u043a\u0441\u0438\u043c\u0430\u043b\u044c\u043d\u0430\u044f \u0434\u043b\u0438\u043d\u0430 \u043d\u0430\u0431\u043e\u0440\u0430 \u0441\u043b\u043e\u0432 \u0434\u043b\u044f \u0442\u043e\u043a\u0435\u043d\u0438\u0437\u0430\u0446\u0438\u0438;<\/li>\n<li><i>language<\/i>: \u0410\u043d\u0433\u043b\u0438\u0439\u0441\u043a\u0438\u0439<\/li>\n<li><i>remove_stop_words<\/i>: \u0447\u0442\u043e\u0431\u044b \u0443\u0434\u0430\u043b\u0438\u0442\u044c \u0441\u0442\u043e\u043f-\u0441\u043b\u043e\u0432\u0430 \u0438\u0437 \u0438\u0441\u0442\u043e\u0447\u043d\u0438\u043a\u0430;<\/li>\n<li><i>min_count_limit<\/i>: \u043c\u0438\u043d\u0438\u043c\u0430\u043b\u044c\u043d\u043e\u0435 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u043f\u043e\u0432\u0442\u043e\u0440\u0435\u043d\u0438\u0439, \u043a\u043e\u0442\u043e\u0440\u043e\u0435 \u0441\u043b\u0435\u0434\u0443\u0435\u0442 \u0441\u0447\u0438\u0442\u0430\u0442\u044c \u0437\u0430 \u0442\u043e\u043a\u0435\u043d (\u0435\u0434\u0438\u043d\u0438\u0447\u043d\u044b\u0435 \u0432\u0445\u043e\u0436\u0434\u0435\u043d\u0438\u044f \u0440\u0435\u0434\u043a\u043e \u043f\u043e\u043b\u0435\u0437\u043d\u044b).<\/li>\n<\/ul>\n<p>  \u0410 \u0442\u0435\u043f\u0435\u0440\u044c \u0437\u0430\u043f\u0443\u0441\u0442\u0438\u043c \u044d\u0442\u043e:<\/p>\n<pre><code class=\"python\">res = OpenBlender.call(action, vectorizer_parameters) res<\/code><\/pre>\n<p>  \u041e\u0442\u0432\u0435\u0442: <\/p>\n<pre><code class=\"python\">{       'message' : 'TextVectorizer created successfully.'     'id_textVectorizer' : '5dc1a404951629331f6359dd',     'num_ngrams': 4270 }<\/code><\/pre>\n<p>  \u0411\u044b\u043b \u0441\u043e\u0437\u0434\u0430\u043d <i>TextVectorizer<\/i>, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0441\u0433\u0435\u043d\u0435\u0440\u0438\u0440\u043e\u0432\u0430\u043b 4270 n-\u0433\u0440\u0430\u043c \u043f\u043e \u043d\u0430\u0448\u0435\u0439 \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u0438. \u0427\u0443\u0442\u044c \u043f\u043e\u0437\u0436\u0435 \u043d\u0430\u043c \u043f\u043e\u043d\u0430\u0434\u043e\u0431\u0438\u0442\u0441\u044f \u0441\u0433\u0435\u043d\u0435\u0440\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0439 id:<\/p>\n<p>  <b><i>5dc1a404951629331f6359dd<\/i><\/b><\/p>\n<h3>\u0428\u0430\u0433 4. \u0421\u043e\u0432\u043c\u0435\u0441\u0442\u0438\u043c \u043d\u043e\u0432\u043e\u0441\u0442\u043d\u0443\u044e \u0441\u0432\u043e\u0434\u043a\u0443 \u0441 \u0434\u0430\u0442\u0430\u0441\u0435\u0442\u043e\u043c \u0431\u0438\u0442\u043a\u043e\u0438\u043d\u0430<\/h3>\n<p>  \u0422\u0435\u043f\u0435\u0440\u044c \u043d\u0430\u043c \u043d\u0443\u0436\u043d\u043e \u0441\u043e\u043f\u043e\u0441\u0442\u0430\u0432\u0438\u0442\u044c \u043f\u043e \u0432\u0440\u0435\u043c\u0435\u043d\u0438 \u043d\u043e\u0432\u043e\u0441\u0442\u043d\u0443\u044e \u0441\u0432\u043e\u0434\u043a\u0443 \u0438 \u0434\u0430\u043d\u043d\u044b\u0435 \u043e \u043a\u0443\u0440\u0441\u0435 \u0431\u0438\u0442\u043a\u043e\u0438\u043d\u0430. \u0412 \u0446\u0435\u043b\u043e\u043c, \u044d\u0442\u043e \u0437\u043d\u0430\u0447\u0438\u0442, \u0447\u0442\u043e \u043d\u0443\u0436\u043d\u043e \u043e\u0431\u044a\u0435\u0434\u0438\u043d\u0438\u0442\u044c \u0434\u0432\u0430 \u043d\u0430\u0431\u043e\u0440\u0430 \u0434\u0430\u043d\u043d\u044b\u0445, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044f \u0432 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u043a\u043b\u044e\u0447\u0430 \u0432\u0440\u0435\u043c\u0435\u043d\u043d\u0443\u044e \u043c\u0435\u0442\u043a\u0443. \u0414\u0430\u0432\u0430\u0439\u0442\u0435 \u0434\u043e\u0431\u0430\u0432\u0438\u043c \u043e\u0431\u044a\u0435\u0434\u0438\u043d\u0435\u043d\u043d\u044b\u0435 \u0434\u0430\u043d\u043d\u044b\u0435 \u043a \u043d\u0430\u0448\u0438\u043c \u0438\u0441\u0445\u043e\u0434\u043d\u044b\u043c \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u0430\u043c \u0438\u0437\u0432\u043b\u0435\u0447\u0435\u043d\u0438\u044f \u0434\u0430\u043d\u043d\u044b\u0445:<\/p>\n<pre><code class=\"python\">parameters = {     'token':'your_token',      'id_dataset':'5d4c3af79516290b01c83f51',    'target_threshold' : {'feature':'change','success_thr_over':0},    'lag_target_feature' : {'feature':'change_over_0', 'periods':1},    'blends':[{'id_blend':'5dc1a404951629331f6359dd',                'blend_type' : 'text_ts',                'restriction' : 'predictive',                 'specifications':{'time_interval_size' : 3600*12 }}] }<\/code><\/pre>\n<p>  \u0412\u044b\u0448\u0435 \u043c\u044b \u0443\u043a\u0430\u0437\u0430\u043b\u0438 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u0435:<\/p>\n<ul>\n<li><i>id_blend<\/i>: id \u043d\u0430\u0448\u0435\u0433\u043e textVectorizer;<\/li>\n<li><i>blend_type<\/i>: <i>\u2018text_ts\u2019<\/i>, \u0447\u0442\u043e\u0431\u044b Python \u043f\u043e\u043d\u044f\u043b, \u0447\u0442\u043e \u044d\u0442\u043e \u0441\u043c\u0435\u0441\u044c \u0442\u0435\u043a\u0441\u0442\u0430 \u0438 \u0432\u0440\u0435\u043c\u0435\u043d\u043d\u043e\u0439 \u043c\u0435\u0442\u043a\u0438;<\/li>\n<li><i>restriction<\/i>:<i> \u2018predictive\u2019<\/i>, \u0447\u0442\u043e\u0431\u044b \u043d\u0435 \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u043b\u043e \u00ab\u0441\u043c\u0435\u0448\u0438\u0432\u0430\u043d\u0438\u044f\u00bb \u043d\u043e\u0432\u043e\u0441\u0442\u0435\u0439 \u0438\u0437 \u0431\u0443\u0434\u0443\u0449\u0435\u0433\u043e \u0441\u043e \u0432\u0441\u0435\u043c\u0438 \u043d\u0430\u0431\u043b\u044e\u0434\u0435\u043d\u0438\u044f\u043c\u0438, \u0430 \u0442\u043e\u043b\u044c\u043a\u043e \u0441 \u0442\u0435\u043c\u0438, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0431\u044b\u043b\u0438 \u043e\u043f\u0443\u0431\u043b\u0438\u043a\u043e\u0432\u0430\u043d\u044b \u0440\u0430\u043d\u044c\u0448\u0435 \u0443\u043a\u0430\u0437\u0430\u043d\u043d\u043e\u0433\u043e \u0432\u0440\u0435\u043c\u0435\u043d\u0438.<\/li>\n<li><i>blend_class <\/i>: <i>\u2018closest_observation\u2019<\/i>, \u0447\u0442\u043e\u0431\u044b \u00ab\u0441\u043c\u0435\u0448\u0438\u0432\u0430\u043b\u0438\u0441\u044c\u00bb \u0442\u043e\u043b\u044c\u043a\u043e \u0441\u0430\u043c\u044b\u0435 \u0431\u043b\u0438\u0437\u043a\u0438\u0435 \u043f\u043e \u0432\u0440\u0435\u043c\u0435\u043d\u0438 \u043d\u0430\u0431\u043b\u044e\u0434\u0435\u043d\u0438\u044f;<\/li>\n<li><i>specifications<\/i>: \u043c\u0430\u043a\u0441\u0438\u043c\u0430\u043b\u044c\u043d\u043e \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0435 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u043f\u0440\u043e\u0448\u0435\u0434\u0448\u0435\u0433\u043e \u0432\u0440\u0435\u043c\u0435\u043d\u0438 \u0434\u043b\u044f \u043f\u0435\u0440\u0435\u043d\u043e\u0441\u0430 \u043d\u0430\u0431\u043b\u044e\u0434\u0435\u043d\u0438\u044f, \u0432 \u0434\u0430\u043d\u043d\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 12 \u0447\u0430\u0441\u043e\u0432 (3600*12). \u042d\u0442\u043e \u0437\u043d\u0430\u0447\u0438\u0442, \u0447\u0442\u043e \u043a\u0430\u0436\u0434\u043e\u0435 \u043d\u0430\u0431\u043b\u044e\u0434\u0435\u043d\u0438\u0435 \u0437\u0430 \u0446\u0435\u043d\u043e\u0439 \u0431\u0438\u0442\u043a\u043e\u0438\u043d\u0430 \u0431\u0443\u0434\u0435\u0442 \u043f\u0440\u0435\u0434\u0441\u043a\u0430\u0437\u0430\u043d\u043e \u043d\u0430 \u043e\u0441\u043d\u043e\u0432\u0430\u043d\u0438\u0438 \u043d\u043e\u0432\u043e\u0441\u0442\u0435\u0439 \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u0438\u0445 12 \u0447\u0430\u0441\u043e\u0432.<\/li>\n<\/ul>\n<p>  \u041d\u0430\u043a\u043e\u043d\u0435\u0446, \u043f\u0440\u043e\u0441\u0442\u043e \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u043c \u0444\u0438\u043b\u044c\u0442\u0440 \u043f\u043e \u0434\u0430\u0442\u0435 <i>&#8216;date_filter&#8217;<\/i>, \u043d\u0430\u0447\u0438\u043d\u0430\u044f \u0441 20 \u0430\u0432\u0433\u0443\u0441\u0442\u0430, \u043f\u043e\u0441\u043a\u043e\u043b\u044c\u043a\u0443 \u0438\u043c\u0435\u043d\u043d\u043e \u0442\u043e\u0433\u0434\u0430 Fox News \u043d\u0430\u0447\u0430\u043b\u0438 \u0441\u0431\u043e\u0440 \u0434\u0430\u043d\u043d\u044b\u0445, \u0438 <i>\u2018drop_non_numeric\u2019<\/i>, \u0447\u0442\u043e\u0431\u044b \u043c\u044b \u043f\u043e\u043b\u0443\u0447\u0430\u043b\u0438 \u0442\u043e\u043b\u044c\u043a\u043e \u0446\u0438\u0444\u0440\u044b:<\/p>\n<pre><code class=\"python\">parameters = {     'token':'your_token',    'id_dataset':'5d4c3af79516290b01c83f51',    'target_threshold' : {'feature':'change','success_thr_over':0},    'lag_target_feature' : {'feature':'change_over_0', 'periods':1},    'blends':[{'id_blend':'5dc1a404951629331f6359dd',                'blend_type' : 'text_ts',                'restriction' : 'predictive',                'blend_class' : 'closest_observation',                 'specifications':{'time_interval_size' : 3600*12 }}],    'date_filter':{'start_date':'2019-08-20T16:59:35.825Z',                    'end_date':'2019-11-04T17:59:35.825Z'},    'drop_non_numeric' : 1 }<\/code><\/pre>\n<p>  <b>\u041f\u0440\u0438\u043c\u0435\u0447\u0430\u043d\u0438\u0435<\/b>: \u042f \u0443\u043a\u0430\u0437\u0430\u043b 4 \u043d\u043e\u044f\u0431\u0440\u044f \u0432 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 <i>\u2018end_date\u2019<\/i>, \u043f\u043e\u0441\u043a\u043e\u043b\u044c\u043a\u0443 \u044d\u0442\u043e \u0431\u044b\u043b \u0434\u0435\u043d\u044c, \u043a\u043e\u0433\u0434\u0430 \u044f \u043f\u0438\u0441\u0430\u043b \u044d\u0442\u043e\u0442 \u043a\u043e\u0434, \u0432\u044b \u043c\u043e\u0436\u0435\u0442\u0435 \u0438\u0437\u043c\u0435\u043d\u0438\u0442\u044c \u0434\u0430\u0442\u0443. <\/p>\n<p>  \u0414\u0430\u0432\u0430\u0439\u0442\u0435 \u0441\u043d\u043e\u0432\u0430 \u043f\u043e\u043b\u0443\u0447\u0438\u043c \u0434\u0430\u043d\u043d\u044b\u0435:<\/p>\n<pre><code class=\"python\">df = pullObservationsToDF(parameters) print(df.shape) df.head()<\/code><\/pre>\n<p>  (57, 2115)<\/p>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/webt\/wl\/qx\/2e\/wlqx2ejdoq_mmlks8qwsxaigkfm.png\"><\/p>\n<p>  \u0422\u0435\u043f\u0435\u0440\u044c \u0443 \u043d\u0430\u0441 \u0435\u0441\u0442\u044c \u0431\u043e\u043b\u044c\u0448\u0435 2000 \u043f\u0440\u0438\u0437\u043d\u0430\u043a\u043e\u0432 \u0441 \u0442\u043e\u043a\u0435\u043d\u0430\u043c\u0438 \u0438 57 \u043d\u0430\u0431\u043b\u044e\u0434\u0435\u043d\u0438\u0439.<\/p>\n<h3>\u0428\u0430\u0433 5. \u041f\u0440\u0438\u043c\u0435\u043d\u0438\u043c ML \u043a \u0442\u0430\u0440\u0433\u0435\u0442\u0443 \u043f\u0440\u0435\u0434\u0441\u043a\u0430\u0437\u0430\u043d\u0438\u044f<\/h3>\n<p>  \u0422\u0435\u043f\u0435\u0440\u044c \u0443 \u043d\u0430\u0441, \u043d\u0430\u043a\u043e\u043d\u0435\u0446, \u0435\u0441\u0442\u044c \u0447\u0438\u0441\u0442\u044b\u0439 \u0434\u0430\u0442\u0430\u0441\u0435\u0442, \u0438 \u043e\u043d \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u0438\u043c\u0435\u043d\u043d\u043e \u0442\u0430\u043a, \u043a\u0430\u043a \u043d\u0430\u043c \u043d\u0443\u0436\u043d\u043e, \u0441\u043e \u0441\u043c\u0435\u0449\u0435\u043d\u0438\u0435\u043c \u0442\u0430\u0440\u0433\u0435\u0442\u0430 \u043f\u043e \u0432\u0440\u0435\u043c\u0435\u043d\u0438 \u0438 \u0441\u043e\u043f\u043e\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u043d\u044b\u043c\u0438 \u0447\u0438\u0441\u043b\u043e\u0432\u044b\u043c\u0438 \u0434\u0430\u043d\u043d\u044b\u043c\u0438.<\/p>\n<p>  \u0414\u0430\u0432\u0430\u0439\u0442\u0435 \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u043d\u0430 \u0441\u0430\u043c\u044b\u0435 \u0432\u044b\u0441\u043e\u043a\u0438\u0435 \u043a\u043e\u0440\u0440\u0435\u043b\u044f\u0446\u0438\u0438 \u0441 <i>\u2018Target_change_over_0\u2019<\/i>:<\/p>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/webt\/zf\/po\/ro\/zfporoczgftdbl_a5if0h2takt8.png\"><\/p>\n<p>  \u0422\u0435\u043f\u0435\u0440\u044c \u0443 \u043d\u0430\u0441 \u0435\u0441\u0442\u044c \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u043a\u043e\u0440\u0440\u0435\u043b\u0438\u0440\u0443\u044e\u0449\u0438\u0445 \u043f\u0440\u0438\u0437\u043d\u0430\u043a\u043e\u0432. \u0414\u0430\u0432\u0430\u0439\u0442\u0435 \u0440\u0430\u0437\u0434\u0435\u043b\u0438\u043c \u0434\u0430\u0442\u0430\u0441\u0435\u0442 \u043d\u0430 \u0442\u0440\u0435\u043d\u0438\u0440\u043e\u0432\u043e\u0447\u043d\u044b\u0439 \u0438 \u0442\u0435\u0441\u0442\u043e\u0432\u044b\u0439 \u0432 \u0445\u0440\u043e\u043d\u043e\u043b\u043e\u0433\u0438\u0447\u0435\u0441\u043a\u043e\u043c \u043f\u043e\u0440\u044f\u0434\u043a\u0435, \u0447\u0442\u043e\u0431\u044b \u043c\u044b \u043c\u043e\u0433\u043b\u0438 \u043e\u0431\u0443\u0447\u0430\u0442\u044c \u043c\u043e\u0434\u0435\u043b\u044c \u043d\u0430 \u0440\u0430\u043d\u043d\u0438\u0445 \u043d\u0430\u0431\u043b\u044e\u0434\u0435\u043d\u0438\u044f\u0445 \u0438 \u0442\u0435\u0441\u0442\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043d\u0430 \u043f\u043e\u0437\u0434\u043d\u0438\u0445.<\/p>\n<pre><code class=\"python\">X = df.loc[:, df.columns != target_variable].values y = df.loc[:,[target_variable]].values div = int(round(len(X) * 0.29)) # We take the first observations as test and the last as train because the dataset is ordered by timestamp descending. X_test = X[:div] y_test = y[:div] print(X_test.shape) print(y_test.shape) X_train = X[div:] y_train = y[div:] print(X_train.shape) print(y_train.shape)<\/code><\/pre>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/webt\/3o\/0w\/se\/3o0wsepbou0bt4ncscftdyzwtka.png\"><\/p>\n<p>  \u0423 \u043d\u0430\u0441 \u0435\u0441\u0442\u044c 40 \u043d\u0430\u0431\u043b\u044e\u0434\u0435\u043d\u0438\u0439 \u0434\u043b\u044f \u043e\u0431\u0443\u0447\u0435\u043d\u0438\u044f \u0438 17 \u0434\u043b\u044f \u0442\u0435\u0441\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f.<br \/>  \u0422\u0435\u043f\u0435\u0440\u044c \u0438\u043c\u043f\u043e\u0440\u0442\u0438\u0440\u0443\u0435\u043c \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u044b\u0435 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438:<\/p>\n<pre><code class=\"python\">from sklearn.ensemble import RandomForestRegressor from sklearn.metrics import mean_squared_error from sklearn.metrics import accuracy_score from sklearn.metrics import roc_auc_score from sklearn import metrics<\/code><\/pre>\n<p>  \u0410 \u0442\u0435\u043f\u0435\u0440\u044c \u0434\u0430\u0432\u0430\u0439\u0442\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c \u0441\u043b\u0443\u0447\u0430\u0439\u043d\u044b\u0439 \u043b\u0435\u0441 (RandomForest) \u0438 \u0441\u0434\u0435\u043b\u0430\u0435\u043c \u043f\u0440\u0435\u0434\u0441\u043a\u0430\u0437\u0430\u043d\u0438\u0435:<\/p>\n<pre><code class=\"python\">rf = RandomForestRegressor(n_estimators = 1000) rf.fit(X_train, y_train) y_pred = rf.predict(X_test)<\/code><\/pre>\n<p>  \u0427\u0442\u043e\u0431\u044b \u0431\u044b\u043b\u043e \u043f\u0440\u043e\u0449\u0435 \u0440\u0430\u0437\u043e\u0431\u0440\u0430\u0442\u044c\u0441\u044f, \u0434\u0430\u0432\u0430\u0439\u0442\u0435 \u043f\u043e\u043c\u0435\u0441\u0442\u0438\u043c \u043f\u0440\u0435\u0434\u0441\u043a\u0430\u0437\u0430\u043d\u0438\u044f \u0438 <i>y_test<\/i> \u0432 Dataframe:<\/p>\n<pre><code class=\"python\">df_res = pd.DataFrame({'y_test':y_test[:,0], 'y_pred':y_pred}) df_res.head()<\/code><\/pre>\n<p>  \u041d\u0430\u0448 \u0440\u0435\u0430\u043b\u044c\u043d\u044b\u0439<i> \u2018y_test\u2019<\/i> \u2013 \u0431\u0438\u043d\u0430\u0440\u043d\u044b\u0439, \u043d\u043e \u043f\u0440\u043e\u0433\u043d\u043e\u0437\u044b \u0443 \u043d\u0430\u0441 \u0442\u0438\u043f\u0430 <i>float<\/i>, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u0434\u0430\u0432\u0430\u0439\u0442\u0435 \u043e\u043a\u0440\u0443\u0433\u043b\u0438\u043c \u0438\u0445, \u043f\u0440\u0435\u0434\u043f\u043e\u043b\u043e\u0436\u0438\u0432, \u0447\u0442\u043e \u0435\u0441\u043b\u0438 \u043e\u043d\u0438 \u0431\u043e\u043b\u044c\u0448\u0435 0.5, \u0442\u043e \u044d\u0442\u043e \u043e\u0437\u043d\u0430\u0447\u0430\u0435\u0442 \u0440\u043e\u0441\u0442 \u0446\u0435\u043d\u044b, \u0430 \u0435\u0441\u043b\u0438 \u043c\u0435\u043d\u044c\u0448\u0435 0.5 \u2013 \u043f\u043e\u043d\u0438\u0436\u0435\u043d\u0438\u0435.<\/p>\n<pre><code class=\"python\">threshold = 0.5 preds = [1 if val &gt; threshold else 0 for val in df_res['y_pred']]<\/code><\/pre>\n<p>  \u0422\u0435\u043f\u0435\u0440\u044c, \u0447\u0442\u043e\u0431\u044b \u043b\u0443\u0447\u0448\u0435 \u043f\u043e\u043d\u0438\u043c\u0430\u0442\u044c \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u043d\u044b\u0435 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u044b, \u043f\u043e\u043b\u0443\u0447\u0438\u043c AUC, \u043c\u0430\u0442\u0440\u0438\u0446\u0443 \u043e\u0448\u0438\u0431\u043e\u043a \u0438 \u043f\u043e\u043a\u0430\u0437\u0430\u0442\u0435\u043b\u044c \u0442\u043e\u0447\u043d\u043e\u0441\u0442\u0438:<\/p>\n<pre><code class=\"python\">print(roc_auc_score(preds, df_res['y_test'])) print(metrics.confusion_matrix(preds, df_res['y_test'])) print(accuracy_score(preds, df_res['y_test']))<\/code><\/pre>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/webt\/tj\/e3\/vb\/tje3vb7mfbnkdqp018mnagugz3e.png\"><\/p>\n<p>  \u041c\u044b \u043f\u043e\u043b\u0443\u0447\u0438\u043b\u0438 64,7% \u043f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u044b\u0445 \u043f\u0440\u0435\u0434\u0441\u043a\u0430\u0437\u0430\u043d\u0438\u0439 \u0441 0.65 AUC.<\/p>\n<ul>\n<li>9 \u0440\u0430\u0437 \u043c\u044b \u043f\u0440\u0435\u0434\u0441\u043a\u0430\u0437\u0430\u043b\u0438 \u043f\u043e\u043d\u0438\u0436\u0435\u043d\u0438\u0435, \u0438 \u0446\u0435\u043d\u0430 \u0443\u043c\u0435\u043d\u044c\u0448\u0438\u043b\u0430\u0441\u044c (\u0432\u0435\u0440\u043d\u043e);<\/li>\n<li>5 \u0440\u0430\u0437 \u043c\u044b \u043f\u0440\u0435\u0434\u0441\u043a\u0430\u0437\u0430\u043b\u0438 \u043f\u043e\u043d\u0438\u0436\u0435\u043d\u0438\u0435, \u0430 \u0446\u0435\u043d\u0430 \u0443\u0432\u0435\u043b\u0438\u0447\u0438\u043b\u0430\u0441\u044c (\u043d\u0435\u0432\u0435\u0440\u043d\u043e);<\/li>\n<li>1 \u0440\u0430\u0437 \u043c\u044b \u043f\u0440\u0435\u0434\u0441\u043a\u0430\u0437\u0430\u043b\u0438 \u043f\u043e\u0432\u044b\u0448\u0435\u043d\u0438\u0435, \u0430 \u0446\u0435\u043d\u0430 \u0443\u043c\u0435\u043d\u044c\u0448\u0438\u043b\u0430\u0441\u044c \u043d\u0435\u0432\u0435\u0440\u043d\u043e);<\/li>\n<li>2 \u0440\u0430\u0437\u0430 \u043c\u044b \u043f\u0440\u0435\u0434\u0441\u043a\u0430\u0437\u0430\u043b\u0438 \u043f\u043e\u0432\u044b\u0448\u0435\u043d\u0438\u0435, \u0438 \u0446\u0435\u043d\u0430 \u0443\u0432\u0435\u043b\u0438\u0447\u0438\u043b\u0430\u0441\u044c (\u0432\u0435\u0440\u043d\u043e).<\/li>\n<\/ul>\n<p>  <b><a href=\"https:\/\/otus.pw\/pHAO\/\">\u0423\u0437\u043d\u0430\u0442\u044c \u043f\u043e\u0434\u0440\u043e\u0431\u043d\u0435\u0435 \u043e \u043a\u0443\u0440\u0441\u0435<\/a>.<br \/>  <\/b><\/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\/company\/otus\/blog\/488912\/\"> https:\/\/habr.com\/ru\/company\/otus\/blog\/488912\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"\n<div class=\"post__text post__text-html\" id=\"post-content-body\" data-io-article-url=\"https:\/\/habr.com\/ru\/company\/otus\/blog\/488912\/\"><i><b>\u041f\u0435\u0440\u0435\u0432\u043e\u0434 \u0441\u0442\u0430\u0442\u044c\u0438 \u043f\u043e\u0434\u0433\u043e\u0442\u043e\u0432\u043b\u0435\u043d \u0432 \u043f\u0440\u0435\u0434\u0434\u0432\u0435\u0440\u0438\u0438 \u0441\u0442\u0430\u0440\u0442\u0430 \u043a\u0443\u0440\u0441\u0430 <a href=\"https:\/\/otus.pw\/pHAO\/\">\u00abMachine Learning\u00bb<\/a> \u043e\u0442 OTUS.<\/b><\/i><\/p>\n<hr>\n<p>   <\/p>\n<h3>\u0417\u0430\u0434\u0430\u0447\u0430<\/h3>\n<p>   \u0412 \u044d\u0442\u043e\u043c \u0440\u0443\u043a\u043e\u0432\u043e\u0434\u0441\u0442\u0432\u0435 \u043c\u044b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c \u0434\u0430\u0442\u0430\u0441\u0435\u0442 <i><a href=\"https:\/\/www.openblender.io\/#\/dataset\/explore\/5d4c3af79516290b01c83f51\/or\/21\">Bitcoin vs USD<\/a>.<\/i><\/p>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/webt\/wk\/bg\/mn\/wkbgmnndnzujik02hufs9et9m2k.png\"><\/p>\n<p>   \u0412\u044b\u0448\u0435\u043f\u0440\u0438\u0432\u0435\u0434\u0435\u043d\u043d\u044b\u0439 \u0434\u0430\u0442\u0430\u0441\u0435\u0442 \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u0442 \u0435\u0436\u0435\u0434\u043d\u0435\u0432\u043d\u0443\u044e \u0441\u0432\u043e\u0434\u043a\u0443 \u0446\u0435\u043d, \u0433\u0434\u0435 \u043a\u043e\u043b\u043e\u043d\u043a\u0430 CHANGE \u2013 \u044d\u0442\u043e \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u0435 \u0446\u0435\u043d\u044b \u0432 \u043f\u0440\u043e\u0446\u0435\u043d\u0442\u0430\u0445 \u043e\u0442 \u0446\u0435\u043d\u044b \u0437\u0430 \u043f\u0440\u0435\u0434\u044b\u0434\u0443\u0449\u0438\u0439 \u0434\u0435\u043d\u044c (<i>PRICE<\/i>) \u043f\u043e \u043e\u0442\u043d\u043e\u0448\u0435\u043d\u0438\u044e \u043a \u043d\u043e\u0432\u043e\u0439 (<i>OPEN<\/i>).<\/p>\n<p>  <b>\u0426\u0435\u043b\u044c:<\/b> \u0427\u0442\u043e\u0431\u044b \u0443\u043f\u0440\u043e\u0441\u0442\u0438\u0442\u044c \u0437\u0430\u0434\u0430\u0447\u0443, \u043c\u044b \u0441\u043e\u0441\u0440\u0435\u0434\u043e\u0442\u043e\u0447\u0438\u043c\u0441\u044f \u043d\u0430 \u043f\u0440\u043e\u0433\u043d\u043e\u0437\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0438 \u0442\u043e\u0433\u043e, \u0432\u043e\u0437\u0440\u0430\u0441\u0442\u0435\u0442 \u043b\u0438 \u0446\u0435\u043d\u0430 (<i>CHANGE &gt; 0<\/i>) \u0438\u043b\u0438 \u0443\u043f\u0430\u0434\u0435\u0442 (<i>CHANGE &lt; 0<\/i>) \u043d\u0430 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0439 \u0434\u0435\u043d\u044c. (\u0422\u0430\u043a \u043c\u044b \u043f\u043e\u0442\u0435\u043d\u0446\u0438\u0430\u043b\u044c\u043d\u043e \u0441\u043c\u043e\u0436\u0435\u043c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043f\u0440\u0435\u0434\u0441\u043a\u0430\u0437\u0430\u043d\u0438\u044f \u00ab\u0432 \u0440\u0435\u0430\u043b\u044c\u043d\u043e\u0439 \u0436\u0438\u0437\u043d\u0438\u00bb).<\/p>\n<p>  <b>\u0422\u0440\u0435\u0431\u043e\u0432\u0430\u043d\u0438\u044f<\/b><\/p>\n<ul>\n<li>\u0412 \u0441\u0438\u0441\u0442\u0435\u043c\u0435 \u0434\u043e\u043b\u0436\u0435\u043d \u0431\u044b\u0442\u044c \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u043b\u0435\u043d Python 2.6+ \u0438\u043b\u0438 3.1+<\/li>\n<li>\u0423\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u0435 <i>pandas<\/i>, <i>sklearn <\/i>\u0438 <i>openblender <\/i>(\u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e pip)<\/li>\n<\/ul>\n<pre><code class=\"python\">$ pip install pandas OpenBlender scikit-learn<\/code><\/pre>\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-298864","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/298864","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=298864"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/298864\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=298864"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=298864"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=298864"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}