{"id":335710,"date":"2022-07-14T09:00:19","date_gmt":"2022-07-14T09:00:19","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=335710"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=335710","title":{"rendered":"<span>\u0421\u0440\u0430\u0432\u043d\u0435\u043d\u0438\u0435 \u0434\u0432\u0443\u0445 \u0441\u0438\u0441\u0442\u0435\u043c \u0434\u043b\u044f \u0442\u043e\u0440\u0433\u043e\u0432\u043b\u0438 \u0430\u043a\u0446\u0438\u044f\u043c\u0438: \u043c\u043e\u0434\u0435\u043b\u0438 \u0431\u043b\u0438\u0436\u0430\u0439\u0448\u0438\u0445 \u0441\u043e\u0441\u0435\u0434\u0435\u0439 \u0438 \u0442\u043e\u0440\u0433\u043e\u0432\u043b\u0438 \u043f\u043e \u0441\u043a\u043e\u043b\u044c\u0437\u044f\u0449\u0435\u0439 \u0441\u0440\u0435\u0434\u043d\u0435\u0439<\/span>"},"content":{"rendered":"<div><\/div>\n<div id=\"post-content-body\">\n<div>\n<div class=\"article-formatted-body article-formatted-body article-formatted-body_version-2\">\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<p>\u041f\u0440\u0438\u0432\u0435\u0442!<\/p>\n<p>\u042f \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u0434\u0430\u0432\u043d\u043e \u0432 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u0445\u043e\u0431\u0431\u0438 \u0437\u0430\u043d\u0438\u043c\u0430\u044e\u0441\u044c \u0430\u043d\u0430\u043b\u0438\u0437\u043e\u043c \u043e\u0442\u043a\u0440\u044b\u0442\u044b\u0445 \u0434\u0430\u043d\u043d\u044b\u0445 \u0432 \u0438\u0433\u0440\u0430\u0445 \u043d\u0430 \u0434\u0435\u043d\u044c\u0433\u0438 (\u0441\u0442\u0430\u0432\u043a\u0438 \u043d\u0430 \u0441\u043f\u043e\u0440\u0442, \u0431\u0438\u0440\u0436\u0435\u0432\u044b\u0435 \u043a\u043e\u0442\u0438\u0440\u043e\u0432\u043a\u0438 \u0438 \u0442\u043f). \u0412 \u043e\u0441\u043d\u043e\u0432\u043d\u043e\u043c \u0440\u0430\u0431\u043e\u0442\u0430\u044e \u0440\u0443\u043a\u0430\u043c\u0438 \u0432 \u044d\u043a\u0441\u0435\u043b\u0435, \u043d\u043e \u0442\u0430\u043a\u0436\u0435 \u0441\u0442\u0430\u0440\u0430\u044e\u0441\u044c \u0431\u044b\u0442\u044c \u0432 \u043a\u0443\u0440\u0441\u0435 \u0442\u043e\u0433\u043e, \u0447\u0442\u043e \u0434\u0435\u043b\u0430\u044e\u0442 \u043c\u0430\u0448\u0438\u043d\u044b. \u0414\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u043f\u0440\u043e\u0448\u0435\u043b \u043a\u0443\u0440\u0441\u044b Kaggle \u043e\u0442 Google. \u0412 \u044d\u0442\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0435 \u044f \u043f\u043e\u043f\u0440\u043e\u0431\u0443\u044e \u0441\u0440\u0430\u0432\u043d\u0438\u0442\u044c \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0438\u0432\u043d\u043e\u0441\u0442\u044c \u043f\u0440\u0435\u0434\u0441\u043a\u0430\u0437\u0430\u043d\u0438\u0439 \u0434\u043d\u0435\u0432\u043d\u043e\u0433\u043e \u0434\u0432\u0438\u0436\u0435\u043d\u0438\u044f \u0446\u0435\u043d\u044b \u0430\u043a\u0446\u0438\u0438 \u043e\u0442 \u0434\u0432\u0443\u0445 \u043f\u0440\u0438\u043c\u0438\u0442\u0438\u0432\u043d\u044b\u0445 \u0441\u0438\u0441\u0442\u0435\u043c \u0442\u043e\u0440\u0433\u043e\u0432\u043b\u0438: <\/p>\n<p>1. \u043f\u0440\u0438\u043c\u0438\u0442\u0438\u0432\u043d\u043e\u0433\u043e \u0442\u0440\u0435\u0439\u0434\u0435\u0440\u0430-\u0447\u0435\u043b\u043e\u0432\u0435\u043a\u0430, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043d\u0430 \u0432\u0432\u043e\u0434\u043d\u043e\u043c \u043a\u0443\u0440\u0441\u0435 \u043f\u043e \u0442\u0440\u0435\u0439\u0434\u0438\u043d\u0433\u0443 \u0443\u0437\u043d\u0430\u043b \u043f\u0440\u043e \u0441\u043a\u043e\u043b\u044c\u0437\u044f\u0449\u0443\u044e \u0441\u0440\u0435\u0434\u043d\u044e\u044e,<\/p>\n<p>\u00a0\u0438<\/p>\n<p>2. \u043f\u0440\u0438\u043c\u0438\u0442\u0438\u0432\u043d\u043e\u0439 \u043c\u043e\u0434\u0435\u043b\u0438, \u043e\u0431\u0443\u0447\u0435\u043d\u043d\u043e\u0439 \u043f\u043e \u043c\u0435\u0442\u043e\u0434\u0443 \u0431\u043b\u0438\u0436\u0430\u0439\u0448\u0438\u0445 \u0441\u043e\u0441\u0435\u0434\u0435\u0439 (\u041a\u043b\u0430\u0441\u0441 KNeighborsClassifier \u0432 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0435 Python Scikit-learn).<\/p>\n<p>\u041e\u0446\u0435\u043d\u0438\u0432\u0430\u0442\u044c\u0441\u044f \u043f\u0440\u0435\u0434\u0441\u043a\u0430\u0437\u0430\u043d\u0438\u044f \u043e\u0431\u0435\u0438\u0445 \u0441\u0438\u0441\u0442\u0435\u043c \u0431\u0443\u0434\u0443\u0442 \u043f\u043e \u0434\u0432\u0443\u043c \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u0430\u043c:<\/p>\n<ol>\n<li>\n<p>\u0420\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u0442\u043e\u0440\u0433\u043e\u0432\u043b\u0438 \u0430\u043a\u0446\u0438\u0435\u0439 \u0432 \u043f\u0440\u043e\u0446\u0435\u043d\u0442\u0430\u0445.<\/p>\n<\/li>\n<li>\n<p>\u041f\u0440\u043e\u0446\u0435\u043d\u0442 \u0432\u0435\u0440\u043d\u044b\u0445 \u043f\u0440\u0435\u0434\u0441\u043a\u0430\u0437\u0430\u043d\u0438\u0439.<\/p>\n<\/li>\n<\/ol>\n<p>\u041c\u043d\u0435 \u043f\u043e\u043a\u0430\u0437\u0430\u043b\u043e\u0441\u044c, \u0447\u0442\u043e \u0431\u0443\u0434\u0443\u0442 \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u0435\u0435 \u043f\u0438\u0441\u0430\u0442\u044c \u0434\u0430\u043d\u043d\u0443\u044e \u0441\u0442\u0430\u0442\u044c\u044e \u043f\u043e\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u043e, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u043d\u0430 \u043c\u043e\u043c\u0435\u043d\u0442 \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u0438\u044f \u044d\u0442\u0438\u0445 \u0441\u043b\u043e\u0432 \u044f \u043d\u0435 \u0437\u043d\u0430\u044e \u0438\u0442\u043e\u0433\u043e\u0432\u044b\u0445 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u043e\u0432. <\/p>\n<h3>\u041a\u0440\u0430\u0442\u043a\u043e \u043e \u0441\u043a\u043e\u043b\u044c\u0437\u044f\u0449\u0435\u0439 \u0441\u0440\u0435\u0434\u043d\u0435\u0439<\/h3>\n<p>\u0421\u043a\u043e\u043b\u044c\u0437\u044f\u0449\u0430\u044f \u0441\u0440\u0435\u0434\u043d\u044f\u044f (moving average) \u0432 \u0440\u0430\u0437\u043b\u0438\u0447\u043d\u044b\u0445 \u0440\u0443\u043a\u043e\u0432\u043e\u0434\u0441\u0442\u0432\u0430\u0445 \u043f\u043e \u0442\u0440\u0435\u0439\u0434\u0438\u043d\u0433\u0443 \u0438 \u0432 \u0431\u0430\u0437\u043e\u0432\u044b\u0445 \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0430\u0445 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c \u0434\u043b\u044f \u0430\u043d\u0430\u043b\u0438\u0437\u0430 \u0438\u043c\u0435\u0435\u0442 \u043f\u0435\u0440\u0438\u043e\u0434 <em>[\u0447\u0438\u0441\u043b\u043e \u0424\u0438\u0431\u043e\u043d\u0430\u0447\u0447\u0438 >=8 + 1]<\/em>, \u0442.\u0435. 9, 14, 22 \u0438 \u0442.\u043f. \u042f \u043d\u0430 \u0442\u0435\u043a\u0443\u0449\u0435\u0439 \u0441\u0442\u0430\u0434\u0438\u0438 \u0440\u0430\u0437\u0432\u0438\u0442\u0438\u044f \u043d\u0435 \u043c\u043e\u0433\u0443 \u043e\u0431\u044a\u044f\u0441\u043d\u0438\u0442\u044c, \u043f\u043e\u0447\u0435\u043c\u0443 \u0438\u043c\u0435\u043d\u043d\u043e \u0442\u0430\u043a\u0438\u0435 \u043f\u0435\u0440\u0438\u043e\u0434\u044b, \u0447\u0435\u0441\u0442\u043d\u043e \u043f\u043e\u0442\u0440\u0430\u0442\u0438\u043b 5 \u043c\u0438\u043d\u0443\u0442, \u0447\u0442\u043e\u0431\u044b \u043d\u0430\u0439\u0442\u0438 \u043e\u0442\u0432\u0435\u0442 \u0432 \u0418\u043d\u0442\u0435\u0440\u043d\u0435\u0442\u0435, \u043d\u043e \u043d\u0435 \u0441\u043c\u043e\u0433. <\/p>\n<p>\u041f\u0435\u0440\u0438\u043e\u0434 \u2013 \u044d\u0442\u043e \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u0443\u044e\u0449\u0438\u0439 \u043d\u0430\u0441 \u0432\u0440\u0435\u043c\u0435\u043d\u043d\u043e\u0439 \u0434\u0438\u0430\u043f\u0430\u0437\u043e\u043d (\u043c\u0435\u0441\u044f\u0446, \u043d\u0435\u0434\u0435\u043b\u044f, \u0434\u0435\u043d\u044c, \u0447\u0430\u0441, 15 \u043c\u0438\u043d\u0443\u0442, 5 \u043c\u0438\u043d\u0443\u0442, 1 \u043c\u0438\u043d\u0443\u0442\u0430). \u0414\u043b\u044f \u043f\u043e\u0441\u0442\u0440\u043e\u0435\u043d\u0438\u044f \u0441\u043a\u043e\u043b\u044c\u0437\u044f\u0449\u0435\u0439 \u0441\u0440\u0435\u0434\u043d\u0435\u0439 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e\u0442 \u0440\u0430\u0437\u043b\u0438\u0447\u043d\u044b\u0435 \u0442\u0438\u043f\u044b \u0446\u0435\u043d \u0437\u0430 \u043f\u0440\u0435\u0434\u044b\u0434\u0443\u0449\u0438\u0435 \u043f\u0435\u0440\u0438\u043e\u0434\u044b: \u043f\u0440\u043e\u0441\u0442\u043e Close (\u0446\u0435\u043d\u0430  \u0430\u043a\u0446\u0438\u0438 \u0432 \u043a\u043e\u043d\u0446\u0435 \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u0443\u044e\u0449\u0435\u0433\u043e \u043d\u0430\u0441 \u043f\u0435\u0440\u0438\u043e\u0434\u0430) \u0438\u043b\u0438 \u0440\u0430\u0437\u043b\u0438\u0447\u043d\u044b\u0435 \u043a\u043e\u043c\u0431\u0438\u043d\u0430\u0446\u0438\u0438 Open (\u0446\u0435\u043d\u0430 \u0432 \u043d\u0430\u0447\u0430\u043b\u0435 \u043f\u0435\u0440\u0438\u043e\u0434\u0430), Close, Hi (\u043c\u0430\u043a\u0441\u0438\u043c\u0430\u043b\u044c\u043d\u0430\u044f \u0446\u0435\u043d\u0430), Low (\u043c\u0438\u043d\u0438\u043c\u0430\u043b\u044c\u043d\u0430\u044f \u0446\u0435\u043d\u0430) \u0442\u0438\u043f\u0430 <em>[&#171;Open + Hi + Low + 2*Close&#187; \/ 5]<\/em>. \/<\/p>\n<p>\u041f\u043e \u0432\u0438\u0434\u0430\u043c \u0441\u043a\u043e\u043b\u044c\u0437\u044f\u0449\u0438\u0435 \u0441\u0440\u0435\u0434\u043d\u0438\u0435 \u0434\u0435\u043b\u044f\u0442\u0441\u044f \u043d\u0430 \u043f\u0440\u043e\u0441\u0442\u044b\u0435 (simple moving average, \u0434\u0430\u043b\u0435\u0435 &#8212; SMA), \u0438 \u044d\u043a\u0441\u043f\u043e\u043d\u0435\u043d\u0446\u0438\u0430\u043b\u044c\u043d\u044b\u0435 (exponential moving average, \u0434\u0430\u043b\u0435\u0435 EMA). SMA \u0440\u0430\u0441\u0441\u0447\u0438\u0442\u044b\u0432\u0430\u044e\u0442\u0441\u044f \u043f\u043e \u043c\u0435\u0442\u043e\u0434\u0443 \u0441\u0440\u0435\u0434\u043d\u0435\u0433\u043e \u0430\u0440\u0438\u0444\u043c\u0435\u0442\u0438\u0447\u0435\u0441\u043a\u043e\u0433\u043e, \u0443 EMA \u0447\u0435\u043c \u043d\u043e\u0432\u0435\u0435 \u0434\u0430\u043d\u043d\u044b\u0435, \u0442\u0435\u043c \u0431\u043e\u043b\u044c\u0448\u0438\u0439 \u0432\u0435\u0441 \u0438\u043c \u043f\u0440\u0438\u0441\u0432\u0430\u0438\u0432\u0430\u0435\u0442\u0441\u044f.<\/p>\n<p>\u0415\u0441\u043b\u0438 \u0446\u0435\u043d\u0430 \u043d\u0430\u0434 \u0441\u043a\u043e\u043b\u044c\u0437\u044f\u0449\u0435\u0439 \u0441\u0440\u0435\u0434\u043d\u0435\u0439, \u0442\u043e \u0441\u0447\u0438\u0442\u0430\u0435\u0442\u0441\u044f, \u0447\u0442\u043e \u0441\u043a\u043e\u0440\u0435\u0435 \u043e\u043d\u0430 \u0431\u0443\u0434\u0435\u0442 \u0440\u0430\u0441\u0442\u0438 \u0434\u0430\u043b\u044c\u0448\u0435, \u0435\u0441\u043b\u0438 \u043f\u043e\u0434 \u0441\u043a\u043e\u043b\u044c\u0437\u044f\u0449\u0435\u0439 \u0441\u0440\u0435\u0434\u043d\u0435\u0439 &#8212; \u043f\u0440\u043e\u0434\u043e\u043b\u0436\u0430\u0442\u044c \u043f\u0430\u0434\u0430\u0442\u044c. <\/p>\n<p>\u042f \u043f\u043b\u0430\u043d\u0438\u0440\u0443\u044e \u0440\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0435\u0442\u044c \u043c\u0430\u043a\u0441\u0438\u043c\u0430\u043b\u044c\u043d\u043e \u043f\u0440\u0438\u043c\u0438\u0442\u0438\u0432\u043d\u0443\u044e \u0441\u043a\u043e\u043b\u044c\u0437\u044f\u0449\u0443\u044e \u0441\u0440\u0435\u0434\u043d\u044e\u044e, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u0442\u0440\u0435\u0439\u0434\u0435\u0440-\u0447\u0435\u043b\u043e\u0432\u0435\u043a \u0431\u0443\u0434\u0435\u0442 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043f\u0440\u043e\u0441\u0442\u0443\u044e \u0441\u043a\u043e\u043b\u044c\u0437\u044f\u0449\u0443\u044e \u0441\u0440\u0435\u0434\u043d\u044e\u044e SMA, \u043f\u043e\u0441\u0442\u0440\u043e\u0435\u043d\u043d\u0443\u044e \u043f\u043e \u0446\u0435\u043d\u0430\u043c Close \u0437\u0430 \u043f\u0435\u0440\u0438\u043e\u0434 9 \u0434\u043d\u0435\u0439.<\/p>\n<h3>\u041a\u0440\u0430\u0442\u043a\u043e \u043e \u043c\u0435\u0442\u043e\u0434\u0435 \u0431\u043b\u0438\u0436\u0430\u0439\u0448\u0438\u0445 \u0441\u043e\u0441\u0435\u0434\u0435\u0439<\/h3>\n<p>\u041c\u0435\u0442\u043e\u0434 \u0431\u043b\u0438\u0436\u0430\u0439\u0448\u0438\u0445 \u0441\u043e\u0441\u0435\u0434\u0435\u0439 &#8212; \u044d\u0442\u043e \u043e\u0434\u0438\u043d \u0438\u0437 \u0441\u0430\u043c\u044b\u0445 \u043f\u0440\u043e\u0441\u0442\u044b\u0445 \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u043e\u0432 \u043a\u043b\u0430\u0441\u0441\u0438\u0444\u0438\u043a\u0430\u0446\u0438\u0438, \u043d\u043e \u0432 \u0442\u043e \u0436\u0435 \u0432\u0440\u0435\u043c\u044f \u043e\u0434\u0438\u043d \u0438\u0437 \u0441\u0430\u043c\u044b\u0445 \u043b\u043e\u0433\u0438\u0447\u0435\u0441\u043a\u0438 \u043e\u0431\u044a\u044f\u0441\u043d\u0438\u043c\u044b\u0445 \u0438, \u0441 \u043c\u043e\u0435\u0439 \u0442\u043e\u0447\u043a\u0438 \u0437\u0440\u0435\u043d\u0438\u044f, \u0441\u0438\u043b\u044c\u043d\u044b\u0445 \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u043e\u0432. \u0412 \u043e\u0441\u043d\u043e\u0432\u043d\u043e\u043c \u043e\u043d \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u0434\u043b\u044f \u0440\u0435\u0448\u0435\u043d\u0438\u044f \u0437\u0430\u0434\u0430\u0447 \u043a\u043b\u0430\u0441\u0441\u0438\u0444\u0438\u043a\u0430\u0446\u0438\u0438. \u041c\u0435\u0442\u043e\u0434 \u043d\u0430\u0445\u043e\u0434\u0438\u0442 \u0432 \u0442\u0435\u0441\u0442\u043e\u0432\u043e\u0439 \u0432\u044b\u0431\u043e\u0440\u043a\u0435, \u0432 \u043a\u043e\u0442\u043e\u0440\u043e\u0439 \u0434\u043b\u044f \u043e\u0431\u044a\u0435\u043a\u0442\u043e\u0432 \u0443\u0436\u0435 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u044b \u043a\u043b\u0430\u0441\u0441\u044b, \u043e\u0431\u044a\u0435\u043a\u0442\u044b, \u0440\u0430\u0441\u0441\u0442\u043e\u044f\u043d\u0438\u0435 \u0434\u043e \u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u043c\u0438\u043d\u0438\u043c\u0430\u043b\u044c\u043d\u043e (\u0442\u043e \u0435\u0441\u0442\u044c \u043d\u0430\u0445\u043e\u0434\u0438\u0442 \u043c\u0430\u043a\u0441\u0438\u043c\u0430\u043b\u044c\u043d\u043e \u043f\u043e\u0445\u043e\u0436\u0438\u0435 \u043e\u0431\u044a\u0435\u043a\u0442\u044b), \u0434\u0430\u043b\u0435\u0435 \u044d\u0442\u0438 \u043e\u0431\u044a\u0435\u043a\u0442\u044b \u043d\u0430\u0437\u044b\u0432\u0430\u044e\u0442\u0441\u044f &#171;\u0441\u043e\u0441\u0435\u0434\u0438&#187;. \u0417\u0430\u0442\u0435\u043c \u043c\u0435\u0442\u043e\u0434 \u043f\u0440\u0438\u0441\u0432\u0430\u0438\u0432\u0430\u0435\u0442 \u043a\u043b\u0430\u0441\u0441\u0438\u0444\u0438\u0446\u0438\u0440\u0443\u0435\u043c\u043e\u043c\u0443 \u043e\u0431\u044a\u0435\u043a\u0442\u0443 \u043a\u043b\u0430\u0441\u0441, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0447\u0430\u0449\u0435 \u0432\u0441\u0442\u0440\u0435\u0447\u0430\u0435\u0442\u0441\u044f \u0443 \u043e\u0442\u043e\u0431\u0440\u0430\u043d\u043d\u044b\u0445 \u0441\u043e\u0441\u0435\u0434\u0435\u0439. <\/p>\n<p>\u041c\u044b\u0448\u043b\u0435\u043d\u0438\u0435 \u0447\u0435\u043b\u043e\u0432\u0435\u043a\u0430 \u0432 \u043f\u043e\u0432\u0442\u043e\u0440\u044f\u044e\u0449\u0438\u0445\u0441\u044f \u0441\u0438\u0442\u0443\u0430\u0446\u0438\u044f\u0445 \u0430\u0431\u0441\u043e\u043b\u044e\u0442\u043d\u043e  \u0442\u0430\u043a\u043e\u0435 \u0436\u0435: \u044f \u0438\u0434\u0443 \u0431\u0435\u0437 \u0433\u043e\u043b\u043e\u0432\u043d\u043e\u0433\u043e \u0443\u0431\u043e\u0440\u0430 \u2013 \u043f\u043e\u0448\u0435\u043b \u0434\u043e\u0436\u0434\u044c \u2013 \u0432 \u043f\u0440\u043e\u0448\u043b\u043e\u043c \u0431\u044b\u043b\u043e 4 \u043e\u043f\u044b\u0442\u0430, \u043a\u043e\u0433\u0434\u0430 \u044f \u0448\u0435\u043b \u0431\u0435\u0437 \u0433\u043e\u043b\u043e\u0432\u043d\u043e\u0433\u043e \u0443\u0431\u043e\u0440\u0430 \u0438 \u043f\u043e\u0448\u0435\u043b \u0434\u043e\u0436\u0434\u044c, \u0438\u0437 \u043d\u0438\u0445 \u044f 3 \u0440\u0430\u0437\u0430 \u043f\u0440\u043e\u043c\u043e\u043a (\u043d\u0435\u0433\u0430\u0442\u0438\u0432\u043d\u044b\u0439 \u043e\u043f\u044b\u0442) \u0438 1 \u0440\u0430\u0437 \u0434\u043e\u0436\u0434\u044c \u0431\u044b\u0441\u0442\u0440\u043e \u043a\u043e\u043d\u0447\u0438\u043b\u0441\u044f. \u0412\u044b\u0432\u043e\u0434: \u0434\u043e\u0436\u0434\u044c \u0432\u0435\u0434\u0435\u0442 \u043a \u043d\u0435\u0433\u0430\u0442\u0438\u0432\u043d\u044b\u043c \u043f\u043e\u0441\u043b\u0435\u0434\u0441\u0442\u0432\u0438\u044f\u043c. <\/p>\n<h3>\u041f\u043e\u0434\u0433\u043e\u0442\u043e\u0432\u043a\u0430 \u0438\u0441\u0445\u043e\u0434\u043d\u044b\u0445 \u0434\u0430\u043d\u043d\u044b\u0445 \u0447\u0435\u043b\u043e\u0432\u0435\u043a\u0430-\u0442\u0440\u0435\u0439\u0434\u0435\u0440\u0430<\/h3>\n<p>\u041d\u0430 \u0441\u0430\u0439\u0442\u0435 \u043e\u0434\u043d\u043e\u0433\u043e \u0440\u043e\u0441\u0441\u0438\u0439\u0441\u043a\u043e\u0433\u043e \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u043e\u043d\u043d\u043e\u0433\u043e \u0430\u0433\u0435\u043d\u0442\u0441\u0442\u0432\u0430 \u043c\u043e\u0436\u043d\u043e \u0431\u044b\u0441\u0442\u0440\u043e \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u0438\u0441\u0442\u043e\u0440\u0438\u044e \u043a\u043e\u0442\u0438\u0440\u043e\u0432\u043e\u043a \u043b\u044e\u0431\u044b\u0445 \u0430\u043a\u0446\u0438\u0439 \u0432 \u0444\u043e\u0440\u043c\u0430\u0442\u0435 .csv. \u0424\u0430\u0439\u043b \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u0442 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0435 \u0441\u0442\u043e\u043b\u0431\u0446\u044b: &lt;TICKER> &#8212; \u043d\u0430\u0437\u0432\u0430\u043d\u0438\u0435 \u0430\u043a\u0446\u0438\u0438, &lt;PER> &#8212; \u043f\u0435\u0440\u0438\u043e\u0434 , &lt;DATE> &#8212; \u0434\u0430\u0442\u0430, &lt;TIME> &#8212; \u0432\u0440\u0435\u043c\u044f, &lt;OPEN> &#8212; \u0446\u0435\u043d\u0430 \u043e\u0442\u043a\u0440\u044b\u0442\u0438\u044f, &lt;HIGH> &#8212; \u043c\u0430\u043a\u0441\u0438\u043c\u0430\u043b\u044c\u043d\u0430\u044f \u0446\u0435\u043d\u0430, &lt;LOW> &#8212; \u043c\u0438\u043d\u0438\u043c\u0430\u043b\u044c\u043d\u0430\u044f \u0446\u0435\u043d\u0430, &lt;CLOSE> &#8212; \u0446\u0435\u043d\u0430 \u0437\u0430\u043a\u0440\u044b\u0442\u0438\u044f, &lt;AMOUNT> &#8212; \u0441\u0443\u043c\u043c\u0430 \u0442\u043e\u0440\u0433\u043e\u0432, &lt;VOL> &#8212; \u043e\u0431\u044a\u0435\u043c \u0442\u043e\u0440\u0433\u043e\u0432. \u0414\u043b\u044f \u043f\u0440\u0438\u043c\u0435\u0440\u0430, \u043d\u0438\u0436\u0435 \u0441\u0442\u0440\u043e\u043a\u0430 \u0444\u0430\u0439\u043b\u0430 .csv \u0434\u043b\u044f \u0434\u043d\u0435\u0432\u043d\u044b\u0445 \u043a\u043e\u0442\u0438\u0440\u043e\u0432\u043e\u043a \u0430\u043a\u0446\u0438\u0439 \u0413\u0430\u0437\u043f\u0440\u043e\u043c\u0430 \u0437\u0430 \u0434\u0430\u0442\u0443 05.01.2015\u0433.:<\/p>\n<p><em>\u00a0[\u0413\u0410\u0417\u041f\u0420\u041e\u041c \u0430\u043e,D,20150105,000000,129.5,133.95,129.15,133.95,18223370,2410730975.5]<\/em><\/p>\n<p>\u0410\u043a\u0446\u0438\u0438 \u0413\u0430\u0437\u043f\u0440\u043e\u043c\u0430 (\u0442\u0438\u043a\u0435\u0440 GAZP) \u2013 \u043d\u0430\u0438\u0431\u043e\u043b\u0435\u0435 \u043b\u0438\u043a\u0432\u0438\u0434\u043d\u044b\u0435 \u0430\u043a\u0446\u0438\u0438 \u0438\u0437 \u0442\u043e\u0440\u0433\u0443\u0435\u043c\u044b\u0445 \u043d\u0430 \u041c\u043e\u0441\u043a\u043e\u0432\u0441\u043a\u043e\u0439 \u0431\u0438\u0440\u0436\u0435. \u0414\u043e\u043b\u0433\u043e\u0435 \u0432\u0440\u0435\u043c\u044f \u044d\u0442\u0438 \u0430\u043a\u0446\u0438\u0438 \u0438\u043c\u0435\u043b\u0438 \u043d\u0430\u0438\u0431\u043e\u043b\u044c\u0448\u0438\u0439 \u0432\u0435\u0441 \u0432 \u0438\u043d\u0434\u0435\u043a\u0441\u0435 iMOEX (\u0442\u043e\u043f-40 \u0440\u043e\u0441\u0441\u0438\u0439\u0441\u043a\u0438\u0445 \u0430\u043a\u0446\u0438\u0439). \u041f\u043e\u044d\u0442\u043e\u043c\u0443 \u043e\u0431\u0435 \u0441\u0438\u0441\u0442\u0435\u043c\u044b \u0431\u0443\u0434\u0443\u0442 \u0434\u0435\u043b\u0430\u0442\u044c \u043f\u0440\u0435\u0434\u0441\u043a\u0430\u0437\u0430\u043d\u0438\u044f \u0446\u0435\u043d\u044b \u0430\u043a\u0446\u0438\u0438 \u0413\u0430\u0437\u043f\u0440\u043e\u043c\u0430 \u0432 \u043f\u0435\u0440\u0438\u043e\u0434 \u0441 03.01.2017\u0433. \u043f\u043e 30.12.2021\u0433. <\/p>\n<p>\u0414\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u0434\u0430\u0442\u0430-\u0444\u0440\u0435\u0439\u043c \u0442\u0440\u0435\u0439\u0434\u0435\u0440\u0430-\u0447\u0435\u043b\u043e\u0432\u0435\u043a\u0430 \u0431\u0443\u0434\u0435\u0442 \u0441\u043e\u0434\u0435\u0440\u0436\u0430\u0442\u044c \u043a\u043e\u0442\u0438\u0440\u043e\u0432\u043a\u0438 \u0432 \u043f\u0435\u0440\u0438\u043e\u0434 \u0441 20.12.2016\u0433., \u0447\u0442\u043e\u0431\u044b \u0438\u043c\u0435\u0442\u044c \u0434\u0430\u043d\u043d\u044b\u0435\u00a0 \u0434\u043b\u044f \u043f\u043e\u0441\u0442\u0440\u043e\u0435\u043d\u0438\u044f \u0441\u043a\u043e\u043b\u044c\u0437\u044f\u0449\u0435\u0439 \u0441\u0440\u0435\u0434\u043d\u0435\u0439 \u043d\u0430 03.01.2017\u0433. \u041c\u043e\u0434\u0435\u043b\u044c \u0436\u0435 \u0431\u0443\u0434\u0435\u0442 \u043e\u0431\u0443\u0447\u0430\u0442\u044c\u0441\u044f \u0434\u043e 30.12.2016\u0433., \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u0434\u0430\u0442\u0430-\u0444\u0440\u0435\u0439\u043c \u043c\u043e\u0434\u0435\u043b\u0438 \u0431\u0443\u0434\u0435\u0442 \u0441\u043e\u0434\u0435\u0440\u0436\u0430\u0442\u044c \u043a\u043e\u0442\u0438\u0440\u043e\u0432\u043a\u0438 \u0432 \u043f\u0435\u0440\u0438\u043e\u0434 \u0441 19.01.2015\u0433 \u043f\u043e 30.12.2021\u0433.<\/p>\n<p>\u0414\u0430\u0442\u0430-\u0444\u0440\u0435\u0439\u043c \u0442\u0440\u0435\u0439\u0434\u0435\u0440\u0430-\u0447\u0435\u043b\u043e\u0432\u0435\u043a\u0430 (human_df) \u0431\u0443\u0434\u0435\u0442 \u0441\u043e\u0434\u0435\u0440\u0436\u0430\u0442\u044c \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0435 \u0441\u0442\u043e\u043b\u0431\u0446\u044b:<\/p>\n<p>&lt;DATE> &#8212; \u0434\u0430\u0442\u0430 <\/p>\n<p>&lt;OPEN> &#8212; \u0446\u0435\u043d\u0430 \u043e\u0442\u043a\u0440\u044b\u0442\u0438\u044f<\/p>\n<p>&lt;CLOSE> &#8212; \u0446\u0435\u043d\u0430 \u0437\u0430\u043a\u0440\u044b\u0442\u0438\u044f<\/p>\n<p>&lt;SMA9> &#8212; \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u0441\u043a\u043e\u043b\u044c\u0437\u044f\u0449\u0435\u0439 \u0441\u0440\u0435\u0434\u043d\u0435\u0439 SMA9<\/p>\n<p>&lt;RESULT> &#8212; \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u0434\u043d\u044f \u043f\u043e \u0444\u043e\u0440\u043c\u0443\u043b\u0435 <em>[(&lt;CLOSE> &#8212; &lt;OPEN>) \/ &lt;OPEN>]<\/em><\/p>\n<p>\u0421\u043e\u0437\u0434\u0430\u044e \u0434\u0430\u0442\u0430-\u0444\u0440\u0435\u0439\u043c \u0442\u0440\u0435\u0439\u0434\u0435\u0440\u0430-\u0447\u0435\u043b\u043e\u0432\u0435\u043a\u0430 (human_df):<\/p>\n<pre><code class=\"python\">#\u0438\u043c\u043f\u043e\u0440\u0442\u0438\u0440\u0443\u044e \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u044b\u0435 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438 import pandas as pd import numpy as np #\u0441\u043e\u0437\u0434\u0430\u044e \u0434\u0430\u0442\u0430-\u0444\u0440\u0435\u0439\u043c \u0441 \u043a\u043e\u0442\u0438\u0440\u043e\u0432\u043a\u0430\u043c\u0438 \u0432 \u043f\u0435\u0440\u0438\u043e\u0434 \u0441 05.01.2015\u0433 \u043f\u043e 30.12.2021\u0433. #\u0438\u0437 \u043f\u0440\u0435\u0434\u0432\u0430\u0440\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u0437\u0430\u0433\u0440\u0443\u0436\u0435\u043d\u043d\u043e\u0433\u043e \u0444\u0430\u0439\u043b\u0430 .csv df = pd.read_csv('\u2026\\csv_files\\GAZP_150105_213012.csv') #\u0432\u044b\u0432\u043e\u0436\u0443 \u043d\u0430 \u044d\u043a\u0440\u0430\u043d \u043f\u0435\u0440\u0432\u0443\u044e \u0441\u0442\u0440\u043e\u043a\u0443 \u0434\u0430\u0442\u0430-\u0444\u0440\u0435\u0439\u043c\u0430 df print(df.iloc[0])<\/code><\/pre>\n<details class=\"spoiler\">\n<summary>Hidden text<\/summary>\n<div class=\"spoiler__content\">\n<figure class=\"\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w780q1\/getpro\/habr\/upload_files\/ce2\/c5e\/b5e\/ce2c5eb5e196f18a29dd34bc4c48765b.jpg\" width=\"196\" height=\"183\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/ce2\/c5e\/b5e\/ce2c5eb5e196f18a29dd34bc4c48765b.jpg\" data-blurred=\"true\"\/><figcaption><\/figcaption><\/figure>\n<\/p>\n<\/div>\n<\/details>\n<pre><code class=\"python\">#\u0438\u0437 \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u043d\u043e\u0433\u043e \u0434\u0430\u0442\u0430-\u0444\u0440\u0435\u0439\u043c\u0430 df \u0441\u043e\u0437\u0434\u0430\u044e \u0434\u0430\u0442\u0430-\u0444\u0440\u0435\u0439\u043c date_open_close_df \u0441\u043e \u0441\u0442\u043e\u043b\u0431\u0446\u0430\u043c\u0438 &lt;DATE>, #&lt;OPEN>, &lt;CLOSE> \u0432 \u043f\u0435\u0440\u0438\u043e\u0434 \u0434\u0430\u0442 \u0441 20.12.2016\u0433. \u043f\u043e 30.12.2021\u0433 date_open_close_df = df.iloc[493:,[2,4,7]] #\u0432\u044b\u0432\u043e\u0436\u0443 \u043d\u0430 \u044d\u043a\u0440\u0430\u043d \u043f\u0435\u0440\u0432\u044b\u0435 5 \u0441\u0442\u0440\u043e\u043a \u0434\u0430\u0442\u0430-\u0444\u0440\u0435\u0439\u043c\u0430 date_open_close_df print(date_open_close_df.head()) <\/code><\/pre>\n<details class=\"spoiler\">\n<summary>Hidden text<\/summary>\n<div class=\"spoiler__content\">\n<figure class=\"\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w780q1\/getpro\/habr\/upload_files\/710\/967\/7cd\/7109677cdf08a870e9da198cc0ea708c.jpg\" width=\"247\" height=\"97\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/710\/967\/7cd\/7109677cdf08a870e9da198cc0ea708c.jpg\" data-blurred=\"true\"\/><figcaption><\/figcaption><\/figure>\n<\/p>\n<\/div>\n<\/details>\n<pre><code class=\"python\">#\u043a\u0430\u0436\u0434\u044b\u0439 \u0441\u0442\u043e\u043b\u0431\u0435\u0446 \u0434\u0430\u0442\u0430-\u0444\u0440\u0435\u0439\u043c\u0430 date_open_close_df \u043f\u0435\u0440\u0435\u0432\u043e\u0436\u0443 \u0432 \u043c\u0430\u0441\u0441\u0438\u0432 numpy \u0434\u043b\u044f #\u043f\u043e\u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u0439 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0438 date_arr = date_open_close_df.iloc[:,0].to_numpy() open_arr = date_open_close_df.iloc[:,1].to_numpy() close_arr = date_open_close_df.iloc[:,2].to_numpy() #\u0441\u043e\u0437\u0434\u0430\u044e \u043c\u0430\u0441\u0441\u0438\u0432 \u0441 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u043e\u043c \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u0434\u043d\u044f \u043f\u043e \u0444\u043e\u0440\u043c\u0443\u043b\u0435 [(close - open) \/ open] res_arr = (close_arr - open_arr) \/ open_arr #\u0441 10-\u0439 \u0441\u0442\u0440\u043e\u043a\u0438 \u0441\u0447\u0438\u0442\u0430\u044e \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u0441\u043a\u043e\u043b\u044c\u0437\u044f\u0449\u0435\u0439 \u0441\u0440\u0435\u0434\u043d\u0435\u0439 \u0437\u0430 9 \u0434\u043d\u0435\u0439 SMA9 sma9_arr = [np.mean(close_arr[i-9:i]) for i in range(9,len(close_arr))] #\u043e\u0431\u044a\u0435\u0434\u0438\u043d\u044f\u044e \u043f\u043e \u0441\u0442\u043e\u043b\u0431\u0446\u0430\u043c \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u043d\u044b\u0435 \u043c\u0430\u0441\u0441\u0438\u0432\u044b \u0432 \u043e\u0434\u0438\u043d \u0434\u043b\u044f \u043f\u043e\u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u0433\u043e \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f \u0438\u0442\u043e\u0433\u043e\u0432\u043e\u0433\u043e #\u0434\u0430\u0442\u0430-\u0444\u0440\u0435\u0439\u043c\u0430, \u043f\u0440\u0438 \u044d\u0442\u043e\u043c \u043d\u0430\u0447\u0430\u043b\u043e \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u0441 10-\u0439 \u0441\u0442\u0440\u043e\u043a\u0438, \u0441 \u043a\u043e\u0442\u043e\u0440\u043e\u0439 \u043d\u0430\u0447\u0438\u043d\u0430\u0435\u0442\u0441\u044f #\u0440\u0430\u0441\u0447\u0435\u0442 SMA9  arr_to_df = np.column_stack([date_arr[9:], open_arr[9:], close_arr[9:], sma9_arr, res_arr[9:]])  #\u0441\u043e\u0437\u0434\u0430\u044e \u0434\u0430\u0442\u0430-\u0444\u0440\u0435\u0439\u043c \u0447\u0435\u043b\u043e\u0432\u0435\u043a\u0430-\u0442\u0440\u0435\u0439\u0434\u0435\u0440\u0430 human_df human_df = pd.DataFrame(data = arr_to_df,                         columns = ['Date', 'Open', 'Close', 'SMA9', 'Result'])  #\u0432\u044b\u0432\u043e\u0436\u0443 \u043d\u0430 \u044d\u043a\u0440\u0430\u043d \u043f\u0435\u0440\u0432\u044b\u0435 5 \u0441\u0442\u0440\u043e\u043a \u0434\u0430\u0442\u0430-\u0444\u0440\u0435\u0439\u043c\u0430 human_df print(human_df.head()) <\/code><\/pre>\n<details class=\"spoiler\">\n<summary>Hidden text<\/summary>\n<div class=\"spoiler__content\">\n<figure class=\"\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w780q1\/getpro\/habr\/upload_files\/fd8\/eff\/197\/fd8eff19769fdaffc0bd2b53e6bed2b8.jpg\" width=\"416\" height=\"99\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/fd8\/eff\/197\/fd8eff19769fdaffc0bd2b53e6bed2b8.jpg\" data-blurred=\"true\"\/><figcaption><\/figcaption><\/figure>\n<\/p>\n<\/div>\n<\/details>\n<pre><code class=\"python\">#\u0417\u0430\u043f\u0438\u0441\u044b\u0432\u0430\u044e \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u043d\u044b\u0439 \u0434\u0430\u0442\u0430-\u0444\u0440\u0435\u0439\u043c \u0447\u0435\u043b\u043e\u0432\u0435\u043a\u0430-\u0442\u0440\u0435\u0439\u0434\u0435\u0440\u0430 \u0432 \u0444\u0430\u0439\u043b gazp_human_df.csv  human_df.to_csv(\u2026\\data-frame\\gazp_human_df.csv')<\/code><\/pre>\n<h3>\u0420\u0430\u0441\u0447\u0435\u0442 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0430 \u0442\u043e\u0440\u0433\u043e\u0432\u043b\u0438 \u0447\u0435\u043b\u043e\u0432\u0435\u043a\u0430-\u0442\u0440\u0435\u0439\u0434\u0435\u0440\u0430<\/h3>\n<p>\u0412 \u043d\u043e\u0432\u043e\u043c \u043e\u043a\u043d\u0435 \u0438\u043c\u043f\u043e\u0440\u0442\u0438\u0440\u0443\u044e \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u044b\u0435 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438 \u0438 \u0437\u0430\u0433\u0440\u0443\u0436\u0430\u044e \u0434\u0430\u0442\u0430-\u0444\u0440\u0435\u0439\u043c \u0442\u0440\u0435\u0439\u0434\u0435\u0440\u0430-\u0447\u0435\u043b\u043e\u0432\u0435\u043a\u0430<\/p>\n<pre><code class=\"python\">import pandas as pd pd.plotting.register_matplotlib_converters() import matplotlib.pyplot as plt import seaborn as sns import numpy as np human_df = pd.read_csv('...\\data-frame\\gazp_human_df.csv',                        index_col = 0)<\/code><\/pre>\n<p>\u0421\u0438\u0441\u0442\u0435\u043c\u0430 \u0442\u043e\u0440\u0433\u043e\u0432\u043b\u0438 \u0442\u0440\u0435\u0439\u0434\u0435\u0440\u0430-\u0447\u0435\u043b\u043e\u0432\u0435\u043a\u0430 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0430\u044f:<\/p>\n<p>\u041a\u0430\u0436\u0434\u044b\u0439 \u0434\u0435\u043d\u044c \u0432 \u043c\u043e\u043c\u0435\u043d\u0442 \u043e\u0442\u043a\u0440\u044b\u0442\u0438\u044f \u0442\u043e\u0440\u0433\u043e\u0432 \u0441\u0440\u0430\u0432\u043d\u0438\u0432\u0430\u044e\u0442\u0441\u044f \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f Open \u0438 SMA9. \u0415\u0441\u043b\u0438 Open > SMA9, \u0442.\u0435. \u0446\u0435\u043d\u0430 \u043d\u0430\u0445\u043e\u0434\u0438\u0442\u0441\u044f \u043d\u0430\u0434 \u0441\u043a\u043e\u043b\u044c\u0437\u044f\u0449\u0435\u0439 \u0441\u0440\u0435\u0434\u043d\u0435\u0439, \u0430\u043a\u0446\u0438\u044f \u043f\u043e\u043a\u0443\u043f\u0430\u0435\u0442\u0441\u044f, \u0435\u0441\u043b\u0438 Open &lt;= SMA9, \u0430\u043a\u0446\u0438\u044f \u043f\u0440\u043e\u0434\u0430\u0435\u0442\u0441\u044f. \u041a\u0430\u0436\u0434\u0430\u044f \u0441\u0434\u0435\u043b\u043a\u0430 \u0437\u0430\u043a\u0440\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u0432 \u043c\u043e\u043c\u0435\u043d\u0442 \u0437\u0430\u043a\u0440\u044b\u0442\u0438\u044f \u0442\u043e\u0440\u0433\u043e\u0432 \u0438 \u0444\u0438\u043a\u0441\u0438\u0440\u0443\u0435\u0442\u0441\u044f \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442. \u0422\u0430\u043a\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c, \u0413\u042d\u041f-\u044b (\u0440\u0430\u0437\u0440\u044b\u0432\u044b), \u043a\u043e\u0433\u0434\u0430 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 Open \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u0433\u043e \u0434\u043d\u044f \u043e\u0442\u043b\u0438\u0447\u0430\u0435\u0442\u0441\u044f \u043e\u0442 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u0421lose \u043f\u0440\u0435\u0434\u044b\u0434\u0443\u0449\u0435\u0433\u043e \u0434\u043d\u044f, \u043d\u0435 \u0443\u0447\u0438\u0442\u044b\u0432\u0430\u044e\u0442\u0441\u044f. \u041e\u0434\u0438\u043d \u0434\u0435\u043d\u044c \u2013 \u043e\u0434\u043d\u0430 \u0441\u0434\u0435\u043b\u043a\u0430.<\/p>\n<pre><code class=\"python\">#\u0441\u043e\u0437\u0434\u0430\u044e \u0444\u0443\u043d\u043a\u0446\u0438\u044e \u0434\u043b\u044f \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u044f \u043f\u0440\u043e\u0433\u043d\u043e\u0437\u0430 \u0447\u0435\u043b\u043e\u0432\u0435\u043a\u0430-\u0442\u0440\u0435\u0439\u0434\u0435\u0440\u0430 def create_human_predict(row):     if row.Open >= row.SMA9:         row.human_predict = 1     else:         row.human_predict = 0             return row.human_predict #\u0441\u043e\u0437\u0434\u0430\u044e \u0441\u0435\u0440\u0438\u044e \u0441 \u043f\u0440\u043e\u0433\u043d\u043e\u0437\u0430\u043c\u0438 \u0447\u0435\u043b\u043e\u0432\u0435\u043a\u0430-\u0442\u0440\u0435\u0439\u0434\u0435\u0440\u0430 human_predict = human_df.apply(create_human_predict, axis='columns') #\u0434\u043e\u0431\u0430\u0432\u043b\u044f\u044e \u0432 \u0434\u0430\u0442\u0430-\u0444\u0440\u0435\u0439\u043c human_df \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u043d\u0443\u044e \u0441\u0435\u0440\u0438\u044e human_df = pd.concat([human_df, human_predict], axis = 1) human_df.columns.values[5]='Predict' #\u0432\u044b\u0432\u043e\u0436\u0443 \u043f\u0435\u0440\u0432\u044b\u0435 5 \u0441\u0442\u0440\u043e\u043a \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u043d\u043e\u0433\u043e \u0434\u0430\u0442\u0430-\u0444\u0440\u0435\u0439\u043c\u0430 print(human_df.head())<\/code><\/pre>\n<details class=\"spoiler\">\n<summary>Hidden text<\/summary>\n<div class=\"spoiler__content\">\n<figure class=\"\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w780q1\/getpro\/habr\/upload_files\/d07\/ee2\/1c8\/d07ee21c80e32cc54cd7eb425099aada.jpg\" width=\"487\" height=\"99\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/d07\/ee2\/1c8\/d07ee21c80e32cc54cd7eb425099aada.jpg\" data-blurred=\"true\"\/><figcaption><\/figcaption><\/figure>\n<\/p>\n<\/div>\n<\/details>\n<p>\u0412\u0441\u0435 \u043a\u043e\u0440\u0440\u0435\u043a\u0442\u043d\u043e, \u0434\u043b\u044f \u0432\u0441\u0435\u0445 5-\u0438 \u0441\u0442\u0440\u043e\u043a Open \u0431\u043e\u043b\u044c\u0448\u0435, \u0447\u0435\u043c SMA9, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u0441\u0442\u043e\u043b\u0431\u0446\u0430 Predict \u20181\u2019.<\/p>\n<pre><code class=\"python\">#\u0441\u043e\u0437\u0434\u0430\u044e \u0444\u0443\u043d\u043a\u0446\u0438\u044e \u0434\u043b\u044f \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u044f \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0430 \u043f\u0440\u043e\u0433\u043d\u043e\u0437\u0430 \u0447\u0435\u043b\u043e\u0432\u0435\u043a\u0430-\u0442\u0440\u0435\u0439\u0434\u0435\u0440\u0430 \u0432 \u043f\u0440\u043e\u0446\u0435\u043d\u0442\u0430\u0445 def create_human_result_perc(row):     return row.Result * 100 if row.Predict == 1 else - row.Result * 100 #\u0441\u043e\u0437\u0434\u0430\u044e \u0441\u0435\u0440\u0438\u044e \u0441 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0430\u043c\u0438 \u043f\u0440\u043e\u0433\u043d\u043e\u0437\u043e\u0432 \u0447\u0435\u043b\u043e\u0432\u0435\u043a\u0430-\u0442\u0440\u0435\u0439\u0434\u0435\u0440\u0430 \u0432 \u043f\u0440\u043e\u0446\u0435\u043d\u0442\u0430\u0445 human_result_perc = human_df.apply(create_human_result_perc, axis='columns') #\u0441\u043e\u0437\u0434\u0430\u044e \u0444\u0443\u043d\u043a\u0446\u0438\u044e \u0434\u043b\u044f \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u044f \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0430 \u043f\u0440\u043e\u0433\u043d\u043e\u0437\u0430 \u0447\u0435\u043b\u043e\u0432\u0435\u043a\u0430-\u0442\u0440\u0435\u0439\u0434\u0435\u0440\u0430 \u0432 \u0431\u0443\u043b\u0435\u0432\u043e\u043c #\u043c\u043d\u043e\u0436\u0435\u0441\u0442\u0432\u0435, \u0433\u0434\u0435 0 - \u043f\u0440\u043e\u0433\u043d\u043e\u0437 \u043d\u0435\u0432\u0435\u0440\u0435\u043d, 1 - \u043f\u0440\u043e\u0433\u043d\u043e\u0437 \u0432\u0435\u0440\u0435\u043d def create_human_result_bool(row):     return 1 if row.Result >= 0 and row.Predict == 1 or row.Result &lt; 0 and row.Predict == 0 else 0 #\u0441\u043e\u0437\u0434\u0430\u044e \u0441\u0435\u0440\u0438\u044e \u0441 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0430\u043c\u0438 \u043f\u0440\u043e\u0433\u043d\u043e\u0437\u043e\u0432 \u0447\u0435\u043b\u043e\u0432\u0435\u043a\u0430-\u0442\u0440\u0435\u0439\u0434\u0435\u0440\u0430 \u0432 \u0431\u0443\u043b\u0435\u0432\u043e\u043c \u043c\u043d\u043e\u0436\u0435\u0441\u0442\u0432\u0435 human_result_bool = human_df.apply(create_human_result_bool, axis='columns') #\u0441\u043e\u0437\u0434\u0430\u044e \u043d\u043e\u0432\u044b\u0439 \u0434\u0430\u0442\u0430-\u0444\u0440\u0435\u0439\u043c human_result_frame \u0441 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0430\u043c\u0438 \u043f\u0440\u043e\u0433\u043d\u043e\u0437\u043e\u0432 \u0447\u0435\u043b\u043e\u0432\u0435\u043a\u0430-\u0442\u0440\u0435\u0439\u0434\u0435\u0440\u0430 human_result_frame = pd.DataFrame({'Human_result_perc' : human_result_perc, 'Human_result_bool' : human_result_bool}) print(human_result_frame.head())<\/code><\/pre>\n<details class=\"spoiler\">\n<summary>Hidden text<\/summary>\n<div class=\"spoiler__content\">\n<figure class=\"\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w780q1\/getpro\/habr\/upload_files\/bf5\/089\/cae\/bf5089cae492f8ce5ba65573119a4753.jpg\" width=\"322\" height=\"96\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/bf5\/089\/cae\/bf5089cae492f8ce5ba65573119a4753.jpg\" data-blurred=\"true\"\/><figcaption><\/figcaption><\/figure>\n<\/p>\n<\/div>\n<\/details>\n<pre><code class=\"python\">#\u0432\u044b\u0432\u043e\u0436\u0443 \u043f\u0440\u043e\u0446\u0435\u043d\u0442 \u0432\u0435\u0440\u043d\u044b\u0445 \u043f\u0440\u043e\u0433\u043d\u043e\u0437\u043e\u0432 \u0447\u0435\u043b\u043e\u0432\u0435\u043a\u0430-\u0442\u0440\u0435\u0439\u0434\u0435\u0440\u0430 print(human_result_frame.Human_result_bool.value_counts('1'))<\/code><\/pre>\n<details class=\"spoiler\">\n<summary>Hidden text<\/summary>\n<div class=\"spoiler__content\">\n<figure class=\"\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w780q1\/getpro\/habr\/upload_files\/a93\/596\/473\/a93596473794a7247f0d873a9676d6b4.jpg\" width=\"128\" height=\"34\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/a93\/596\/473\/a93596473794a7247f0d873a9676d6b4.jpg\" data-blurred=\"true\"\/><figcaption><\/figcaption><\/figure>\n<\/p>\n<\/div>\n<\/details>\n<pre><code class=\"python\">#\u0441\u043e\u0437\u0434\u0430\u044e \u0441\u0435\u0440\u0438\u044e \u0441 \u043a\u0443\u043c\u0443\u043b\u044f\u0442\u0438\u0432\u043d\u043e\u0439 \u0441\u0443\u043c\u043c\u043e\u0439 human_result_perc human_result_cumsum = human_result_frame.Human_result_perc.cumsum() print(human_result_cumsum)<\/code><\/pre>\n<details class=\"spoiler\">\n<summary>Hidden text<\/summary>\n<div class=\"spoiler__content\">\n<figure class=\"\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w780q1\/getpro\/habr\/upload_files\/d06\/bc2\/569\/d06bc2569e9c61b52d2fde288ce12d44.jpg\" width=\"142\" height=\"176\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/d06\/bc2\/569\/d06bc2569e9c61b52d2fde288ce12d44.jpg\" data-blurred=\"true\"\/><figcaption><\/figcaption><\/figure>\n<\/p>\n<\/div>\n<\/details>\n<pre><code class=\"python\">#\u0434\u043e\u0431\u0430\u0432\u043b\u044f\u044e \u0432 \u0434\u0430\u0442\u0430-\u0444\u0440\u0435\u0439\u043c human_df \u043d\u043e\u0432\u044b\u0439 \u0434\u0430\u0442\u0430-\u0444\u0440\u0435\u0439\u043c human_result_frame human_df = pd.concat([human_df, human_result_frame], axis = 1) #\u0434\u043e\u0431\u0430\u0432\u043b\u044f\u044e \u0432 \u0434\u0430\u0442\u0430-\u0444\u0440\u0435\u0439\u043c human_df \u0441\u0435\u0440\u0438\u044e \u0441 \u043a\u0443\u043c\u0443\u043b\u044f\u0442\u0438\u0432\u043d\u043e\u0439 \u0441\u0443\u043c\u043c\u043e\u0439 human_result_perc human_df = pd.concat([human_df, human_result_cumsum], axis = 1) human_df.columns.values[8]='CumSum' #\u0432\u044b\u0432\u043e\u0436\u0443 \u043f\u0435\u0440\u0432\u044b\u0435 5 \u0441\u0442\u0440\u043e\u043a \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u043d\u043e\u0433\u043e \u0434\u0430\u0442\u0430-\u0444\u0440\u0435\u0439\u043c\u0430 print(human_df.head())<\/code><\/pre>\n<details class=\"spoiler\">\n<summary>Hidden text<\/summary>\n<div class=\"spoiler__content\">\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w780q1\/getpro\/habr\/upload_files\/100\/d96\/20e\/100d9620e47a514b95a1749fa9cc5e42.jpg\" width=\"661\" height=\"102\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/100\/d96\/20e\/100d9620e47a514b95a1749fa9cc5e42.jpg\" data-blurred=\"true\"\/><figcaption><\/figcaption><\/figure>\n<\/p>\n<\/div>\n<\/details>\n<pre><code class=\"python\">#\u0414\u043b\u044f \u0432\u0438\u0437\u0443\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u0441\u0442\u0440\u043e\u044e \u0433\u0440\u0430\u0444\u0438\u043a \u0442\u043e\u0440\u0433\u043e\u0432\u043b\u0438 \u0442\u0440\u0435\u0439\u0434\u0435\u0440\u0430-\u0447\u0435\u043b\u043e\u0432\u0435\u043a\u0430: #\u0443\u0441\u0442\u0430\u043d\u0430\u0432\u043b\u0438\u0432\u0430\u044e \u0448\u0438\u0440\u0438\u043d\u0443 \u0438 \u0432\u044b\u0441\u043e\u0442\u0443 \u0433\u0440\u0430\u0444\u0438\u043a\u0430 plt.figure(figsize=(10,6)) # \u0417\u0430\u0433\u043e\u043b\u043e\u0432\u043e\u043a plt.title(\"\u0420\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u0442\u043e\u0440\u0433\u043e\u0432\u043b\u0438 \u0442\u0440\u0435\u0439\u0434\u0435\u0440\u0430-\u0447\u0435\u043b\u043e\u0432\u0435\u043a\u0430\") # \u0441\u0442\u0440\u043e\u044e \u043b\u0438\u043d\u0435\u0439\u043d\u044b\u0439 \u0433\u0440\u0430\u0444\u0438\u043a sns.lineplot(data=human_df['CumSum']) plt.show()<\/code><\/pre>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/a71\/6f3\/0c1\/a716f30c15e9e2dfc9aa365e83ee43e8.png\" width=\"1000\" height=\"600\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/a71\/6f3\/0c1\/a716f30c15e9e2dfc9aa365e83ee43e8.png\"\/><figcaption><\/figcaption><\/figure>\n<p>\u041d\u0438\u0436\u0435 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u0442\u043e\u0440\u0433\u043e\u0432\u043b\u0438 \u0447\u0435\u043b\u043e\u0432\u0435\u043a\u0430 \u2013 \u0442\u0440\u0435\u0439\u0434\u0435\u0440\u0430:<\/p>\n<p><strong>\u041f\u0440\u043e\u0446\u0435\u043d\u0442 \u0443\u0441\u043f\u0435\u0448\u043d\u044b\u0445 \u043f\u0440\u043e\u0433\u043d\u043e\u0437\u043e\u0432 \u0432 %: 50,9%<\/strong><\/p>\n<p><strong>\u0420\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u0442\u043e\u0440\u0433\u043e\u0432\u043b\u0438: +74,51%<\/strong><\/p>\n<p>\u0422.\u0435. \u0437\u0430 5 \u043b\u0435\u0442 \u0441 2017 \u043f\u043e 2021 \u0433\u043e\u0434 \u0442\u0430\u043a\u0430\u044f \u0441\u0438\u0441\u0442\u0435\u043c\u0430 \u0442\u043e\u0440\u0433\u043e\u0432\u043b\u0438 \u043f\u0440\u0438\u043d\u0435\u0441\u043b\u0430 \u043f\u043e\u0447\u0442\u0438 75%. \u0425\u043e\u0440\u043e\u0448\u0438\u0439 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u0441 \u0443\u0447\u0435\u0442\u043e\u043c \u0441\u0440\u0435\u0434\u043d\u0435\u0439 \u0441\u0442\u0430\u0432\u043a\u0438 \u0440\u0435\u0444\u0438\u043d\u0430\u043d\u0441\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u0426\u0411 \u0420\u0424 \u0432 \u0440\u0430\u0439\u043e\u043d\u0435 6% \u0437\u0430 \u044d\u0442\u043e\u0442 \u043f\u0435\u0440\u0438\u043e\u0434? \u041a\u043e\u043d\u0435\u0447\u043d\u043e \u043d\u0435\u0442, \u043f\u043e\u0442\u043e\u043c\u0443 \u0447\u0442\u043e \u044f \u043d\u0435 \u0443\u0447\u0438\u0442\u044b\u0432\u0430\u043b \u043a\u043e\u043c\u0438\u0441\u0441\u0438\u044e \u0431\u0440\u043e\u043a\u0435\u0440\u0430 \u0437\u0430 1263 \u0441\u0434\u0435\u043b\u043a\u0438. \u0422\u043e\u0447\u043d\u0435\u0435, \u043a\u043e\u043c\u0438\u0441\u0441\u0438\u044f \u0432\u0437\u0438\u043c\u0430\u0435\u0442\u0441\u044f \u0434\u0432\u0430 \u0440\u0430\u0437\u0430 \u0437\u0430 \u0441\u0434\u0435\u043b\u043a\u0443: \u043f\u0435\u0440\u0432\u044b\u0439 \u0440\u0430\u0437 \u043f\u0440\u0438 \u043e\u0442\u043a\u0440\u044b\u0442\u0438\u0438 \u0441\u0434\u0435\u043b\u043a\u0438 \u0432\u043e \u0432\u0440\u0435\u043c\u044f \u043d\u0430\u0447\u0430\u043b\u0430 \u0442\u043e\u0440\u0433\u043e\u0432 \u043d\u0430 \u0431\u0438\u0440\u0436\u0435, \u0432\u0442\u043e\u0440\u043e\u0439 \u0440\u0430\u0437 \u043f\u0440\u0438 \u0437\u0430\u043a\u0440\u044b\u0442\u0438\u0438 \u0441\u0434\u0435\u043b\u043a\u0438 \u0432 \u043a\u043e\u043d\u0446\u0435 \u0442\u043e\u0440\u0433\u043e\u0432 \u043d\u0430 \u0431\u0438\u0440\u0436\u0435. \u0420\u0430\u0437\u043c\u0435\u0440 \u043a\u043e\u043c\u0438\u0441\u0441\u0438\u0438 \u0443 \u043c\u043e\u0435\u0433\u043e \u0431\u0440\u043e\u043a\u0435\u0440\u0430 &#8212; 0.039% \u043e\u0442 \u043e\u0431\u044a\u0435\u043c\u0430 \u0441\u0434\u0435\u043b\u043a\u0438 \u043f\u0440\u0438 \u043e\u0431\u044a\u0435\u043c\u0435 \u0441\u0434\u0435\u043b\u043e\u043a \u043e\u0442 100\u0442.\u0440. \u0434\u043e 1\u043c\u043b\u043d \u0440\u0443\u0431\u043b\u0435\u0439.<\/p>\n<p>\u0414\u043b\u044f \u0443\u0442\u043e\u0447\u043d\u0435\u043d\u0438\u044f \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0430 \u0441\u0438\u0441\u0442\u0435\u043c\u044b \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u044e\u0441\u044c \u043d\u0430\u0437\u0430\u0434.<\/p>\n<pre><code class=\"python\">#\u0438\u0437\u043c\u0435\u043d\u044f\u044e \u0444\u0443\u043d\u043a\u0446\u0438\u044e \u0434\u043b\u044f \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u044f \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0430 \u043f\u0440\u043e\u0433\u043d\u043e\u0437\u0430 \u0447\u0435\u043b\u043e\u0432\u0435\u043a\u0430-\u0442\u0440\u0435\u0439\u0434\u0435\u0440\u0430 \u0432 \u043f\u0440\u043e\u0446\u0435\u043d\u0442\u0430\u0445 \u0441 \u0443\u0447\u0435\u0442\u043e\u043c \u043a\u043e\u043c\u0438\u0441\u0441\u0438\u0438 \u0431\u0440\u043e\u043a\u0435\u0440\u0430 def create_human_result_perc(row):     return (row.Result - 0.00039 * 2) * 100 if row.Predict == 1 else (- row.Result - 0.00039 * 2) * 100<\/code><\/pre>\n<p>\u0417\u0430\u043f\u0443\u0441\u043a\u0430\u044e \u043a\u043e\u0434 \u0435\u0449\u0435 \u0440\u0430\u0437 \u0438 \u043f\u043e\u043b\u0443\u0447\u0430\u044e \u043d\u043e\u0432\u0443\u044e \u0441\u0435\u0440\u0438\u044e CumSum<\/p>\n<details class=\"spoiler\">\n<summary>Hidden text<\/summary>\n<div class=\"spoiler__content\">\n<figure class=\"\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w780q1\/getpro\/habr\/upload_files\/814\/840\/faf\/814840faf2fbd850691714c14efeea61.jpg\" width=\"144\" height=\"177\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/814\/840\/faf\/814840faf2fbd850691714c14efeea61.jpg\" data-blurred=\"true\"\/><figcaption><\/figcaption><\/figure>\n<\/p>\n<\/div>\n<\/details>\n<pre><code class=\"python\"># \u0418\u0437\u043c\u0435\u043d\u044f\u044e \u0437\u0430\u0433\u043e\u043b\u043e\u0432\u043e\u043a \u0433\u0440\u0430\u0444\u0438\u043a\u0430 plt.title(\"\u0420\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u0442\u043e\u0440\u0433\u043e\u0432\u043b\u0438 \u0442\u0440\u0435\u0439\u0434\u0435\u0440\u0430-\u0447\u0435\u043b\u043e\u0432\u0435\u043a\u0430 \u0441 \u043a\u043e\u043c\u0438\u0441\u0441\u0438\u0435\u0439 \u0431\u0440\u043e\u043a\u0435\u0440\u0430\")<\/code><\/pre>\n<p>\u041d\u043e\u0432\u044b\u0439 \u0433\u0440\u0430\u0444\u0438\u043a:<\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/1ca\/1e2\/517\/1ca1e25173dc807753a8f8a76a5a0262.png\" width=\"1000\" height=\"600\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/1ca\/1e2\/517\/1ca1e25173dc807753a8f8a76a5a0262.png\"\/><figcaption><\/figcaption><\/figure>\n<p>\u041d\u0438\u0436\u0435 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u0442\u043e\u0440\u0433\u043e\u0432\u043b\u0438 \u0447\u0435\u043b\u043e\u0432\u0435\u043a\u0430 \u2013 \u0442\u0440\u0435\u0439\u0434\u0435\u0440\u0430 \u0441 \u043a\u043e\u043c\u0438\u0441\u0441\u0438\u0435\u0439 \u0431\u0440\u043e\u043a\u0435\u0440\u0430:<\/p>\n<p><strong>\u041f\u0440\u043e\u0446\u0435\u043d\u0442 \u0443\u0441\u043f\u0435\u0448\u043d\u044b\u0445 \u043f\u0440\u043e\u0433\u043d\u043e\u0437\u043e\u0432: 50,9%<\/strong><\/p>\n<p><strong>\u0420\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u0442\u043e\u0440\u0433\u043e\u0432\u043b\u0438 \u0432 %: -24,01%<\/strong><\/p>\n<p>\u0414\u043b\u044f \u0434\u043e\u0442\u043e\u0448\u043d\u044b\u0445 \u0447\u0438\u0442\u0430\u0442\u0435\u043b\u0435\u0439 \u043c\u043e\u0433\u0443 \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c, \u0447\u0442\u043e \u0432 \u044d\u0442\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0435 \u044f \u043d\u0435 \u0443\u0447\u0438\u0442\u044b\u0432\u0430\u044e \u0440\u0430\u0437\u043d\u0438\u0446\u0443 \u043c\u0435\u0436\u0434\u0443 \u0446\u0435\u043d\u0430\u043c\u0438 \u043f\u043e\u043a\u0443\u043f\u043a\u0438 \u0438 \u043f\u0440\u043e\u0434\u0430\u0436\u0438 (Bid \u0438 Ask), \u043f\u043e\u0442\u043e\u043c\u0443 \u0447\u0442\u043e, \u0432\u043e-\u043f\u0435\u0440\u0432\u044b\u0445, \u043d\u0435 \u0441\u043c\u043e\u0433 \u043f\u0440\u0438\u0434\u0443\u043c\u0430\u0442\u044c, \u043a\u0430\u043a \u0443\u0447\u0438\u0442\u044b\u0432\u0430\u0442\u044c \u044d\u0442\u0438 \u043f\u043b\u0430\u0432\u0430\u044e\u0449\u0438\u0435 \u0432\u0435\u043b\u0438\u0447\u0438\u043d\u044b, \u0430 \u0432\u043e-\u0432\u0442\u043e\u0440\u044b\u0445 \u043f\u043e\u043d\u044f\u0442\u0438\u0435 \u00ab\u043a\u043e\u0442\u0438\u0440\u043e\u0432\u043a\u0438\u00bb \u0432\u043e\u043e\u0431\u0449\u0435 \u0434\u043e\u0432\u043e\u043b\u044c\u043d\u043e-\u0442\u0430\u043a\u0438 \u0441\u043a\u043e\u043b\u044c\u0437\u043a\u043e\u0435: \u0432 \u0430\u0440\u0445\u0438\u0432\u0435 \u043a\u043e\u0442\u0438\u0440\u043e\u0432\u043e\u043a \u0444\u0438\u043a\u0441\u0438\u0440\u0443\u0435\u0442\u0441\u044f \u043b\u0443\u0447\u0448\u0430\u044f \u0446\u0435\u043d\u0430 \u043f\u043e\u043a\u0443\u043f\u043a\u0438 \/ \u043f\u0440\u043e\u0434\u0430\u0436\u0438, \u043d\u043e \u0432\u043f\u043e\u043b\u043d\u0435 \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c, \u0447\u0442\u043e \u043f\u043e \u044d\u0442\u043e\u0439 \u0446\u0435\u043d\u0435 \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u0441\u044f \u043a\u0443\u043f\u0438\u0442\u044c \u0442\u043e\u043b\u044c\u043a\u043e \u043d\u0435\u0431\u043e\u043b\u044c\u0448\u0443\u044e \u0447\u0430\u0441\u0442\u044c \u0430\u043a\u0446\u0438\u0439, \u0430 \u043e\u0441\u0442\u0430\u043b\u044c\u043d\u0443\u044e \u0447\u0430\u0441\u0442\u044c \u0430\u043a\u0446\u0438\u0439 \u043f\u043e \u0431\u043e\u043b\u0435\u0435 \u043d\u0435\u0432\u044b\u0433\u043e\u0434\u043d\u043e\u0439 \u0446\u0435\u043d\u0435.<\/p>\n<h3>\u041f\u043e\u0434\u0433\u043e\u0442\u043e\u0432\u043a\u0430 \u0438\u0441\u0445\u043e\u0434\u043d\u044b\u0445 \u0434\u0430\u043d\u043d\u044b\u0445 \u043c\u043e\u0434\u0435\u043b\u0438, \u043e\u0431\u0443\u0447\u0435\u043d\u043d\u043e\u0439 \u043f\u043e \u043c\u0435\u0442\u043e\u0434\u0443 \u0431\u043b\u0438\u0436\u0430\u0439\u0448\u0438\u0445 \u0441\u043e\u0441\u0435\u0434\u0435\u0439<\/h3>\n<p>\u0411\u0443\u0434\u0435\u0442 \u0441\u043f\u0440\u0430\u0432\u0435\u0434\u043b\u0438\u0432\u043e, \u0435\u0441\u043b\u0438 \u043c\u043e\u0434\u0435\u043b\u044c \u043f\u043e\u043b\u0443\u0447\u0438\u0442 \u043d\u0430 \u0432\u0445\u043e\u0434 \u0442\u0435 \u0436\u0435 \u0434\u0430\u043d\u043d\u044b\u0435, \u043a\u043e\u0442\u043e\u0440\u044b\u043c\u0438 \u0440\u0430\u0441\u043f\u043e\u043b\u0430\u0433\u0430\u0435\u0442 \u0447\u0435\u043b\u043e\u0432\u0435\u043a-\u0442\u0440\u0435\u0439\u0434\u0435\u0440: \u0446\u0435\u043d\u044b \u043e\u0442\u043a\u0440\u044b\u0442\u0438\u044f \u0438 \u0437\u0430\u043a\u0440\u044b\u0442\u0438\u044f \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u0438\u0445 9-\u0438 \u0434\u043d\u0435\u0439 \u0438 SMA9.<\/p>\n<p>\u041f\u0440\u0438 \u044d\u0442\u043e\u043c \u043c\u0435\u0442\u043e\u0434 \u0431\u043b\u0438\u0436\u0430\u0439\u0448\u0438\u0445 \u0441\u043e\u0441\u0435\u0434\u0435\u0439 \u2013 \u044d\u0442\u043e \u043a\u0430\u0442\u0435\u0433\u043e\u0440\u0438\u0430\u043b\u044c\u043d\u044b\u0439 \u043c\u0435\u0442\u043e\u0434, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u044f \u0441\u0438\u043b\u044c\u043d\u043e \u0441\u043e\u043c\u043d\u0435\u0432\u0430\u044e\u0441\u044c, \u0447\u0442\u043e \u0434\u0430\u043d\u043d\u044b\u0435 \u043d\u0430 \u0432\u0445\u043e\u0434 \u0447\u0438\u0441\u043b\u043e\u0432\u044b\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u0446\u0435\u043d\u044b \u0430\u043a\u0446\u0438\u0438 \u0441\u043c\u043e\u0433\u0443\u0442 \u0441\u0438\u043b\u044c\u043d\u043e \u043f\u043e\u043c\u043e\u0447\u044c \u043e\u0431\u0443\u0447\u0435\u043d\u0438\u044e \u043c\u043e\u0434\u0435\u043b\u0438. \u0415\u0441\u043b\u0438 \u0432 \u0434\u0430\u0442\u0430-\u0444\u0440\u0435\u0439\u043c\u0435 \u0431\u0443\u0434\u0443\u0442 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f Open \u0438 Close \u0442\u0438\u043f\u0430 129.5 \u0438 133.95 (\u0434\u043b\u044f 05.01.2015) \u043c\u043e\u0434\u0435\u043b\u044c \u0431\u0443\u0434\u0435\u0442 \u0438\u0441\u043a\u0430\u0442\u044c \u0431\u043b\u0438\u0436\u0430\u0439\u0448\u0438\u0445 \u0441\u043e\u0441\u0435\u0434\u0435\u0439 \u043d\u0435 \u0432 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438 \u043e\u0442 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0430 \u0434\u043d\u044f (Close &#8212; Open), \u0430 \u0441\u0440\u0435\u0434\u0438 \u0434\u043d\u0435\u0439, \u043a\u043e\u0433\u0434\u0430 \u0446\u0435\u043d\u0430 \u0430\u043a\u0446\u0438\u0438 \u0431\u044b\u043b\u0430 \u043f\u043e\u0434\u043e\u0431\u043d\u043e\u0439. \u041f\u043e\u044d\u0442\u043e\u043c\u0443 \u044f \u0441\u043e\u0437\u0434\u0430\u043c \u0434\u0430\u0442\u0430-\u0444\u0440\u0435\u0439\u043c \u0441\u043e \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u043c\u0438 \u0441\u0442\u043e\u043b\u0431\u0446\u0430\u043c\u0438:<\/p>\n<p>Date \u2013 \u0434\u0430\u0442\u0430<\/p>\n<p>Res_9_day \u2013 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 <em>[(Close \u2013 Open) \/ Open]<\/em> \u0434\u043b\u044f \u0434\u0430\u0442\u044b 9 \u0434\u043d\u0435\u0439 \u043d\u0430\u0437\u0430\u0434<\/p>\n<p>Res_8_day \u2013 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 <em>[(Close \u2013 Open) \/ Open]<\/em> \u0434\u043b\u044f \u0434\u0430\u0442\u044b 8 \u0434\u043d\u0435\u0439 \u043d\u0430\u0437\u0430\u0434<\/p>\n<p>\u2026<\/p>\n<p>Res_1_day \u2013 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 <em>[(Close \u2013 Open) \/ Open]<\/em> \u0434\u043b\u044f \u0434\u0430\u0442\u044b 1 \u0434\u0435\u043d\u044c \u043d\u0430\u0437\u0430\u0434<\/p>\n<p>Open &#8212; SMA9 \u2013 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u00a0<em>[(Open \u2013 SMA9) \/ Open]<\/em><\/p>\n<p>Result \u2013 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u0434\u043d\u044f <em>[(Close \u2013 Open) \/ Open]<\/em><\/p>\n<p>\u0412 \u043d\u043e\u0432\u043e\u043c \u043e\u043a\u043d\u0435:<\/p>\n<pre><code class=\"python\">#\u0438\u043c\u043f\u043e\u0440\u0442\u0438\u0440\u0443\u044e \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u044b\u0435 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438 import pandas as pd import numpy as np #\u0441\u043e\u0437\u0434\u0430\u044e \u0434\u0430\u0442\u0430-\u0444\u0440\u0435\u0439\u043c \u0441 \u043a\u043e\u0442\u0438\u0440\u043e\u0432\u043a\u0430\u043c\u0438 \u0432 \u043f\u0435\u0440\u0438\u043e\u0434 \u0441 05.01.2015\u0433 \u043f\u043e 30.12.2021\u0433. #\u0438\u0437 \u043f\u0440\u0435\u0434\u0432\u0430\u0440\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u0437\u0430\u0433\u0440\u0443\u0436\u0435\u043d\u043d\u043e\u0433\u043e \u0444\u0430\u0439\u043b\u0430 df = pd.read_csv('...\\csv_files\\GAZP_150105_213012.csv') #\u0438\u0437 \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u043d\u043e\u0433\u043e \u0434\u0430\u0442\u0430-\u0444\u0440\u0435\u0439\u043c\u0430 \u0441\u043e\u0437\u0434\u0430\u044e \u0434\u0430\u0442\u0430-\u0444\u0440\u0435\u0439\u043c \u0441\u043e \u0441\u0442\u043e\u043b\u0431\u0446\u0430\u043c\u0438 &lt;DATE>, &lt;OPEN>, #&lt;CLOSE> \u0432 \u043f\u0435\u0440\u0438\u043e\u0434 \u0434\u0430\u0442 \u0441 05.01.2015\u0433. \u043f\u043e 30.12.2021\u0433 date_open_close_df = df.iloc[:,[2,4,7]] #\u043a\u0430\u0436\u0434\u044b\u0439 \u0441\u0442\u043e\u043b\u0431\u0435\u0446 \u0434\u0430\u0442\u0430-\u0444\u0440\u0435\u0439\u043c\u0430 date_open_close_df \u043f\u0435\u0440\u0435\u0432\u043e\u0436\u0443 \u0432 \u043c\u0430\u0441\u0441\u0438\u0432 numpy \u0434\u043b\u044f #\u043f\u043e\u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u0439 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0438 date_arr = date_open_close_df.iloc[:,0].to_numpy() open_arr = date_open_close_df.iloc[:,1].to_numpy() close_arr = date_open_close_df.iloc[:,2].to_numpy() #\u0441\u043e\u0437\u0434\u0430\u044e \u043c\u0430\u0441\u0441\u0438\u0432 \u0441 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u043e\u043c \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u0434\u043d\u044f \u043f\u043e \u0444\u043e\u0440\u043c\u0443\u043b\u0435 [(close - open) \/ open] res_arr = (close_arr - open_arr) \/ open_arr #\u0441 10-\u0439 \u0441\u0442\u0440\u043e\u043a\u0438 \u0441\u0447\u0438\u0442\u0430\u044e \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u0441\u043a\u043e\u043b\u044c\u0437\u044f\u0449\u0435\u0439 \u0441\u0440\u0435\u0434\u043d\u0435\u0439 \u0437\u0430 9 \u0434\u043d\u0435\u0439 SMA9 sma9_arr = [np.mean(close_arr[i-9:i]) for i in range(9,len(close_arr))] #\u0441 10-\u0439 \u0441\u0442\u0440\u043e\u043a\u0438 \u0441\u0447\u0438\u0442\u0430\u044e \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u0440\u0430\u0437\u043d\u0438\u0446\u044b Open \u0438 SMA open10_arr = open_arr[9:] open_sma_arr = (open10_arr - sma9_arr) \/ open10_arr #\u0441\u043e\u0437\u0434\u0430\u044e \u0438\u0442\u043e\u0433\u043e\u0432\u044b\u0439 \u043c\u0430\u0441\u0441\u0438\u0432 \u0441 \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u0443\u044e\u0449\u0438\u043c\u0438 \u043c\u0435\u043d\u044f \u0434\u0430\u043d\u043d\u044b\u043c\u0438 \u0434\u043b\u044f \u043f\u043e\u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u0433\u043e \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f #\u0434\u0430\u0442\u0430-\u0444\u0440\u0435\u0439\u043c\u0430, \u043f\u0440\u0438 \u044d\u0442\u043e\u043c \u043d\u0430\u0447\u0430\u043b\u043e \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u0441\u0442\u043e\u043b\u0431\u0446\u0430 \u0441 10-\u0439 \u0441\u0442\u0440\u043e\u043a\u0438, \u0441 \u043a\u043e\u0442\u043e\u0440\u043e\u0439 #\u043d\u0430\u0447\u0438\u043d\u0430\u0435\u0442\u0441\u044f \u0440\u0430\u0441\u0447\u0435\u0442 SMA9 arr_to_df = np.column_stack([date_arr[9:], res_arr[:-9], res_arr[1:-8], res_arr[2:-7],                              res_arr[3:-6], res_arr[4:-5], res_arr[5:-4],                              res_arr[6:-3], res_arr[7:-2], res_arr[8:-1],                              open_sma_arr, res_arr[9:]]) #\u0441\u043e\u0437\u0434\u0430\u044e \u0434\u0430\u0442\u0430-\u0444\u0440\u0435\u0439\u043c \u043c\u043e\u0434\u0435\u043b\u0438 machine_df machine_df = pd.DataFrame(data = arr_to_df,                         columns = ['Date', 'Res_9_day', 'Res_8_day', 'Res_7_day',                                    'Res_6_day', 'Res_5_day', 'Res_4_day',                                    'Res_3_day', 'Res_2_day', 'Res_1_day',                                    'Open-SMA9', 'Result']) print(machine_df.head())<\/code><\/pre>\n<details class=\"spoiler\">\n<summary>Hidden text<\/summary>\n<div class=\"spoiler__content\">\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w780q1\/getpro\/habr\/upload_files\/9f9\/b44\/de1\/9f9b44de1f5b25efc7fa27f89fd1e95c.jpg\" width=\"586\" height=\"96\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/9f9\/b44\/de1\/9f9b44de1f5b25efc7fa27f89fd1e95c.jpg\" data-blurred=\"true\"\/><figcaption><\/figcaption><\/figure>\n<\/p>\n<\/div>\n<\/details>\n<pre><code class=\"python\">#\u0437\u0430\u043f\u0438\u0441\u044b\u0432\u0430\u044e \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u043d\u044b\u0439 \u0434\u0430\u0442\u0430-\u0444\u0440\u0435\u0439\u043c \u0447\u0435\u043b\u043e\u0432\u0435\u043a\u0430-\u0442\u0440\u0435\u0439\u0434\u0435\u0440\u0430 \u0432 \u0444\u0430\u0439\u043b gazp_machine_df.csv  machine_df.to_csv('...\\data-frame\\gazp_machine_df.csv')<\/code><\/pre>\n<h3>\u0420\u0430\u0441\u0447\u0435\u0442 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0430 \u043c\u043e\u0434\u0435\u043b\u0438<\/h3>\n<pre><code class=\"python\">#\u0438\u043c\u043f\u043e\u0440\u0442\u0438\u0440\u0443\u044e \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u044b\u0435 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438 from sklearn.model_selection import train_test_split, StratifiedKFold from sklearn.neighbors import KNeighborsClassifier from sklearn.metrics import accuracy_score import pandas as pd pd.plotting.register_matplotlib_converters() import matplotlib.pyplot as plt import seaborn as sns import numpy as np #\u0417\u0430\u0433\u0440\u0443\u0436\u0430\u044e \u0434\u0430\u0442\u0430-\u0444\u0440\u0435\u0439\u043c \u043c\u043e\u0434\u0435\u043b\u0438 machine_df = pd.read_csv('...\\data-frame\\gazp_machine_df.csv', index_col = 0) print(machine_df.head()) print(machine_df.shape)<\/code><\/pre>\n<details class=\"spoiler\">\n<summary>Hidden text<\/summary>\n<div class=\"spoiler__content\">\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w780q1\/getpro\/habr\/upload_files\/d82\/157\/c3e\/d82157c3e5c022c9a40bb1fcaac56a9d.jpg\" width=\"582\" height=\"151\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/d82\/157\/c3e\/d82157c3e5c022c9a40bb1fcaac56a9d.jpg\" data-blurred=\"true\"\/><figcaption><\/figcaption><\/figure>\n<\/p>\n<\/div>\n<\/details>\n<p>\u041c\u043e\u0434\u0435\u043b\u044c \u0431\u043b\u0438\u0436\u0430\u0439\u0448\u0438\u0445 \u0441\u043e\u0441\u0435\u0434\u0435\u0439 \u043f\u0440\u043e\u0433\u043d\u043e\u0437\u0438\u0440\u0443\u0435\u0442 \u043a\u043b\u0430\u0441\u0441, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u0441\u043e\u0437\u0434\u0430\u044e \u0441\u0442\u043e\u043b\u0431\u0435\u0446 \u0441 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u043e\u043c \u0434\u043d\u044f \u0432 \u0431\u0443\u043b\u0435\u0432\u043e\u043c \u043c\u043d\u043e\u0436\u0435\u0441\u0442\u0432\u0435, \u0433\u0434\u0435 0 &#8212; \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u0434\u043d\u044f &lt; 0, 1 &#8212; \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u0434\u043d\u044f >= 0<\/p>\n<pre><code class=\"python\">#\u0441\u043e\u0437\u0434\u0430\u044e \u0444\u0443\u043d\u043a\u0446\u0438\u044e \u0434\u043b\u044f \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u044f \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0430 \u0434\u043d\u044f \u0432 \u0431\u0443\u043b\u0435\u0432\u043e\u043c \u043c\u043d\u043e\u0436\u0435\u0441\u0442\u0432\u0435 def create_result_bool(row):     return 1 if row.Result >= 0 else 0 #\u0441\u043e\u0437\u0434\u0430\u044e \u0441\u0435\u0440\u0438\u044e \u0441 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0430\u043c\u0438 \u0434\u043d\u044f \u0432 \u0431\u0443\u043b\u0435\u0432\u043e\u043c \u043c\u043d\u043e\u0436\u0435\u0441\u0442\u0432\u0435 result_bool = machine_df.apply(create_result_bool, axis='columns') #\u0434\u043e\u0431\u0430\u0432\u043b\u044f\u044e \u0432 \u0434\u0430\u0442\u0430-\u0444\u0440\u0435\u0439\u043c machine_df \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u043d\u0443\u044e \u0441\u0435\u0440\u0438\u044e machine_df = pd.concat([machine_df, result_bool], axis = 1) machine_df.columns.values[12]='Result_bool' #\u0432 \u0434\u0430\u0442\u0430-\u0444\u0440\u0435\u0439\u043c\u0435 1756 \u0441\u0442\u0440\u043e\u043a. \u042f \u0440\u0430\u0437\u0434\u0435\u043b\u044e \u0435\u0433\u043e \u043d\u0430 \u0434\u0432\u0430 \u0434\u0430\u0442\u0430-\u0444\u0440\u0435\u0439\u043c\u0430: #machine_df_train (493 \u0441\u0442\u0440\u043e\u043a\u0438, \u0441 19.01.2015 \u043f\u043e 30.12.2016) \u0438 #machine_df_test (1263 \u0441\u0442\u0440\u043e\u043a\u0438 \u0441 03.01.2017 \u043f\u043e 30.12.2021).  machine_df_train = machine_df.iloc[:493] machine_df_test = machine_df.iloc[493:] # \u041e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u044e \u0446\u0435\u043b\u044c \u0438 \u043e\u0442\u0434\u0435\u043b\u044f\u044e \u0446\u0435\u043b\u044c \u043e\u0442 \u043f\u0440\u0435\u0434\u0438\u043a\u0442\u043e\u0440\u043e\u0432, \u0442\u0430\u043a\u0436\u0435 \u0443\u0431\u0438\u0440\u0430\u044e \u0441\u0442\u043e\u043b\u0431\u0435\u0446 Date, \u0442.\u043a. #\u043e\u043d \u043d\u0438\u043a\u0430\u043a \u043d\u0435 \u043f\u043e\u043c\u043e\u0436\u0435\u0442 \u043c\u043e\u0434\u0435\u043b\u0438 y = machine_df_train.Result_bool X = machine_df_train.drop(['Date','Result', 'Result_bool'], axis=1) # \u0414\u0435\u043b\u044e \u0434\u0430\u043d\u043d\u044b\u0435 \u0434\u043b\u044f \u043f\u043e\u0441\u0442\u0440\u043e\u0435\u043d\u0438\u044f \u043c\u043e\u0434\u0435\u043b\u0438 \u0438 \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0438 X \u0438 y X_train, X_valid, y_train, y_valid = train_test_split(X, y, test_size=0.3,                                                       random_state=42,                                                       shuffle = False                                                       ) #\u0432\u044b\u0432\u043e\u0436\u0443 \u043d\u0430 \u044d\u043a\u0440\u0430\u043d \u043f\u0435\u0440\u0432\u044b\u0435 5 \u0441\u0442\u0440\u043e\u043a \u0434\u0430\u043d\u043d\u044b\u0445 x_train #print(X_train.head()) #\u041e\u0431\u0443\u0447\u0443 \u043c\u043e\u0434\u0435\u043b\u044c \u043f\u043e \u043c\u0435\u0442\u043e\u0434\u0443 \u0431\u043b\u0438\u0436\u0430\u0439\u0448\u0438\u0445 \u0441\u043e\u0441\u0435\u0434\u0435\u0439, \u0447\u0438\u0441\u043b\u043e \u0441\u043e\u0441\u0435\u0434\u0435\u0439 \u0432\u043e\u0437\u044c\u043c\u0443 9  knn = KNeighborsClassifier(n_neighbors=9) knn.fit(X_train, y_train) #\u0432\u044b\u043f\u043e\u043b\u043d\u044e \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0443 \u043f\u043e \u0434\u043e\u043b\u0435 \u043f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u044b\u0445 \u043e\u0442\u0432\u0435\u0442\u043e\u0432 knn_pred = knn.predict(X_valid) print(accuracy_score(y_valid, knn_pred)) <\/code><\/pre>\n<details class=\"spoiler\">\n<summary>Hidden text<\/summary>\n<div class=\"spoiler__content\">\n<figure class=\"\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w780q1\/getpro\/habr\/upload_files\/c40\/ded\/42a\/c40ded42a4e03807a6b88b6eaa256799.jpg\" width=\"159\" height=\"21\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/c40\/ded\/42a\/c40ded42a4e03807a6b88b6eaa256799.jpg\" data-blurred=\"true\"\/><figcaption><\/figcaption><\/figure>\n<\/p>\n<\/div>\n<\/details>\n<pre><code class=\"python\">#\u041f\u043e\u043b\u0443\u0447\u0438\u043b \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 49,3% \u0432\u0435\u0440\u043d\u044b\u0445 \u043f\u0440\u043e\u0433\u043d\u043e\u0437\u043e\u0432, \u043d\u0435 \u0432\u043f\u0435\u0447\u0430\u0442\u043b\u044f\u0435\u0442. \u041d\u043e \u0432\u0441\u0435 \u0436\u0435 \u043f\u043e\u043f\u0440\u043e\u0431\u0443\u044e \u043d\u0430 #\u0442\u0435\u0441\u0442\u043e\u0432\u043e\u043c \u0434\u0430\u0442\u0430-\u0444\u0440\u0435\u0439\u043c\u0435 y = machine_df_test.Result_bool X = machine_df_test.drop(['Date','Result', 'Result_bool'], axis=1) knn_pred_test = knn.predict(X) print(accuracy_score(y, knn_pred_test))<\/code><\/pre>\n<details class=\"spoiler\">\n<summary>Hidden text<\/summary>\n<div class=\"spoiler__content\">\n<figure class=\"\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w780q1\/getpro\/habr\/upload_files\/8c2\/525\/8d2\/8c25258d20f1352ba7064c0669ac43a8.jpg\" width=\"148\" height=\"19\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/8c2\/525\/8d2\/8c25258d20f1352ba7064c0669ac43a8.jpg\" data-blurred=\"true\"\/><figcaption><\/figcaption><\/figure>\n<\/p>\n<\/div>\n<\/details>\n<pre><code class=\"python\">#\u041d\u0430 \u0442\u0435\u0441\u0442\u043e\u0432\u043e\u043c \u0434\u0430\u0442\u0430-\u0444\u0440\u0435\u0439\u043c\u0435 \u043f\u043e\u043b\u0443\u0447\u0438\u043b \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u0446\u0435\u043b\u044b\u0445 53,4% \u0432\u0435\u0440\u043d\u044b\u0445 \u043f\u0440\u043e\u0433\u043d\u043e\u0437\u043e\u0432! #\u0422\u0435\u043f\u0435\u0440\u044c \u0441\u0447\u0438\u0442\u0430\u044e \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u0442\u043e\u0440\u0433\u043e\u0432\u043b\u0438 \u043c\u043e\u0434\u0435\u043b\u0438 #\u0441\u043e\u0437\u0434\u0430\u044e \u0434\u0430\u0442\u0430-\u0444\u0440\u0435\u0439\u043c machine_predict_df \u0441 \u043f\u0440\u043e\u0433\u043d\u043e\u0437\u0430\u043c\u0438 \u043c\u043e\u0434\u0435\u043b\u0438 machine_predict_df = pd.DataFrame({'machine_predict' : knn_pred_test}) print(machine_df_test.head()) print(machine_predict_df.head())<\/code><\/pre>\n<details class=\"spoiler\">\n<summary>Hidden text<\/summary>\n<div class=\"spoiler__content\">\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w780q1\/getpro\/habr\/upload_files\/bd8\/a22\/836\/bd8a22836a6fe114e9f4c2b8a6ff4cd7.jpg\" width=\"614\" height=\"225\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/bd8\/a22\/836\/bd8a22836a6fe114e9f4c2b8a6ff4cd7.jpg\" data-blurred=\"true\"\/><figcaption><\/figcaption><\/figure>\n<\/p>\n<\/div>\n<\/details>\n<pre><code class=\"python\"># \u0447\u0442\u043e\u0431\u044b \u043e\u0431\u044a\u0435\u0434\u0438\u043d\u0438\u0442\u044c \u0434\u0430\u0442\u0430-\u0444\u0440\u0435\u0439\u043c\u044b machine_predict_df \u0438 machine_df_test \u043d\u0443\u0436\u043d\u043e #\u0443\u0440\u0430\u0432\u043d\u044f\u0442\u044c \u0438\u0445 \u0438\u043d\u0434\u0435\u043a\u0441\u044b index_list = machine_df_test.index.tolist() machine_predict_df.index = index_list machine_df_test = pd.concat([machine_df_test, machine_predict_df], axis = 1) print(machine_df_test.head())<\/code><\/pre>\n<details class=\"spoiler\">\n<summary>Hidden text<\/summary>\n<div class=\"spoiler__content\">\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w780q1\/getpro\/habr\/upload_files\/fdc\/abe\/e6b\/fdcabee6b5b82c6b8cf2d1eb5b0d5fc1.jpg\" width=\"665\" height=\"104\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/fdc\/abe\/e6b\/fdcabee6b5b82c6b8cf2d1eb5b0d5fc1.jpg\" data-blurred=\"true\"\/><figcaption><\/figcaption><\/figure>\n<\/p>\n<\/div>\n<\/details>\n<pre><code class=\"python\">#\u0441\u043e\u0437\u0434\u0430\u044e \u0444\u0443\u043d\u043a\u0446\u0438\u044e \u0434\u043b\u044f \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u044f \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0430 \u043f\u0440\u043e\u0433\u043d\u043e\u0437\u0430 \u043c\u043e\u0434\u0435\u043b\u0438 \u0432 \u043f\u0440\u043e\u0446\u0435\u043d\u0442\u0430\u0445 \u0441 \u0443\u0447\u0435\u0442\u043e\u043c \u043a\u043e\u043c\u0438\u0441\u0441\u0438\u0438 \u0431\u0440\u043e\u043a\u0435\u0440\u0430 def create_machine_result_perc(row):     return (abs(row.Result)-0.00039*2)*100 if row.Result_bool==row.machine_predict else (-abs(row.Result)-0.00039*2)*100 #\u0441\u043e\u0437\u0434\u0430\u044e \u0441\u0435\u0440\u0438\u044e \u0441 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0430\u043c\u0438 \u043f\u0440\u043e\u0433\u043d\u043e\u0437\u043e\u0432 \u043c\u043e\u0434\u0435\u043b\u0438 \u0432 \u043f\u0440\u043e\u0446\u0435\u043d\u0442\u0430\u0445 machine_result_perc = machine_df_test.apply(create_machine_result_perc, axis='columns') #\u0441\u043e\u0437\u0434\u0430\u044e \u0441\u0435\u0440\u0438\u044e \u0441 \u043a\u0443\u043c\u0443\u043b\u044f\u0442\u0438\u0432\u043d\u043e\u0439 \u0441\u0443\u043c\u043c\u043e\u0439 human_result_perc machine_result_cumsum = machine_result_perc.cumsum() print(machine_result_cumsum)<\/code><\/pre>\n<details class=\"spoiler\">\n<summary>Hidden text<\/summary>\n<div class=\"spoiler__content\">\n<figure class=\"\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w780q1\/getpro\/habr\/upload_files\/191\/2ec\/4ce\/1912ec4ce646140b8fee39be9b6cdbf3.jpg\" width=\"232\" height=\"193\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/191\/2ec\/4ce\/1912ec4ce646140b8fee39be9b6cdbf3.jpg\" data-blurred=\"true\"\/><figcaption><\/figcaption><\/figure>\n<\/p>\n<\/div>\n<\/details>\n<pre><code class=\"python\">#\u0414\u043b\u044f \u0432\u0438\u0437\u0443\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u0441\u0442\u0440\u043e\u044e \u0433\u0440\u0430\u0444\u0438\u043a \u0442\u043e\u0440\u0433\u043e\u0432\u043b\u0438 \u043c\u043e\u0434\u0435\u043b\u0438: #\u0443\u0441\u0442\u0430\u043d\u0430\u0432\u043b\u0438\u0432\u0430\u044e \u0448\u0438\u0440\u0438\u043d\u0443 \u0438 \u0432\u044b\u0441\u043e\u0442\u0443 \u0433\u0440\u0430\u0444\u0438\u043a\u0430 plt.figure(figsize=(10,6)) # \u0421\u043e\u0437\u0434\u0430\u044e \u0437\u0430\u0433\u043e\u043b\u043e\u0432\u043e\u043a \u0433\u0440\u0430\u0444\u0438\u043a\u0430 plt.title(\"\u0420\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u0442\u043e\u0440\u0433\u043e\u0432\u043b\u0438 \u043c\u043e\u0434\u0435\u043b\u0438 \u0441 \u043a\u043e\u043c\u0438\u0441\u0441\u0438\u0435\u0439 \u0431\u0440\u043e\u043a\u0435\u0440\u0430\") # \u0441\u0442\u0440\u043e\u044e \u043b\u0438\u043d\u0435\u0439\u043d\u044b\u0439 \u0433\u0440\u0430\u0444\u0438\u043a sns.lineplot(data=machine_result_cumsum) plt.show()<\/code><\/pre>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/1b6\/ae5\/dc9\/1b6ae5dc933d762e55b18f690d82538d.png\" width=\"1000\" height=\"600\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/1b6\/ae5\/dc9\/1b6ae5dc933d762e55b18f690d82538d.png\"\/><figcaption><\/figcaption><\/figure>\n<p>\u0420\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 -6,4% \u043d\u0435 \u0432\u043f\u0435\u0447\u0430\u0442\u043b\u044f\u0435\u0442, \u043d\u043e \u043e\u043d \u043b\u0443\u0447\u0448\u0435 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0430 \u043f\u0440\u043e\u0433\u043d\u043e\u0437\u043e\u0432<\/p>\n<p>\u043f\u043e \u0441\u043a\u043e\u043b\u044c\u0437\u044f\u0449\u0435\u0439 \u0441\u0440\u0435\u0434\u043d\u0435\u0439. \u041c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u0435 \u0440\u0430\u0437\u043c\u0435\u0440\u0430 \u0442\u0435\u0441\u0442\u043e\u0432\u043e\u0439 \u0432\u044b\u0431\u043e\u0440\u043a\u0438 \u0438 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u0430<\/p>\n<p>\u0441\u043e\u0441\u0435\u0434\u0435\u0439 \u043f\u0440\u0438\u0432\u0435\u0434\u0435\u0442 \u043a \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0435\u043d\u043d\u043e\u043c\u0443 \u0443\u043b\u0443\u0447\u0448\u0435\u043d\u0438\u044e?<\/p>\n<p>\u0414\u043b\u044f \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0438 \u043e\u0431\u0435\u0440\u043d\u0443 \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u0438\u0435 \u0441\u0442\u0440\u043e\u043a\u0438 \u043a\u043e\u0434\u0430 \u0432 \u0444\u0443\u043d\u043a\u0446\u0438\u044e \u0432 \u043d\u043e\u0432\u043e\u043c \u043e\u043a\u043d\u0435<\/p>\n<pre><code class=\"python\">#\u0438\u043c\u043f\u043e\u0440\u0442\u0438\u0440\u0443\u044e \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u044b\u0435 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438 from sklearn.model_selection import train_test_split, StratifiedKFold from sklearn.neighbors import KNeighborsClassifier from sklearn.metrics import accuracy_score import pandas as pd  #\u0417\u0430\u0433\u0440\u0443\u0436\u0430\u044e \u0434\u0430\u0442\u0430-\u0444\u0440\u0435\u0439\u043c \u043c\u043e\u0434\u0435\u043b\u0438 machine_df = pd.read_csv('...\\data-frame\\gazp_machine_df.csv', index_col = 0) #\u0441\u043e\u0437\u0434\u0430\u044e \u0444\u0443\u043d\u043a\u0446\u0438\u044e \u0434\u043b\u044f \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u044f \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0430 \u0434\u043d\u044f \u0432 \u0431\u0443\u043b\u0435\u0432\u043e\u043c \u043c\u043d\u043e\u0436\u0435\u0441\u0442\u0432\u0435 def create_result_bool(row):     return 1 if row.Result >= 0 else 0 #\u0441\u043e\u0437\u0434\u0430\u044e \u0441\u0435\u0440\u0438\u044e \u0441 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0430\u043c\u0438 \u0434\u043d\u044f \u0432 \u0431\u0443\u043b\u0435\u0432\u043e\u043c \u043c\u043d\u043e\u0436\u0435\u0441\u0442\u0432\u0435 result_bool = machine_df.apply(create_result_bool, axis='columns') #\u0434\u043e\u0431\u0430\u0432\u043b\u044f\u044e \u0432 \u0434\u0430\u0442\u0430-\u0444\u0440\u0435\u0439\u043c machine_df \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u043d\u0443\u044e \u0441\u0435\u0440\u0438\u044e machine_df = pd.concat([machine_df, result_bool], axis = 1) machine_df.columns.values[12]='Result_bool' #\u0432 \u0434\u0430\u0442\u0430-\u0444\u0440\u0435\u0439\u043c\u0435 1756 \u0441\u0442\u0440\u043e\u043a. \u042f \u0440\u0430\u0437\u0434\u0435\u043b\u044e \u0435\u0433\u043e \u043d\u0430 \u0434\u0432\u0430 \u0434\u0430\u0442\u0430-\u0444\u0440\u0435\u0439\u043c\u0430: #machine_df_train (493 \u0441\u0442\u0440\u043e\u043a\u0438, \u0441 19.01.2015 \u043f\u043e 30.12.2016) \u0438 #machine_df_test (1263 \u0441\u0442\u0440\u043e\u043a\u0438 \u0441 03.01.2017 \u043f\u043e 30.12.2021).  machine_df_train = machine_df.iloc[:493] machine_df_test = machine_df.iloc[493:] #print(machine_df_test.head()) # \u041e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u044e \u0446\u0435\u043b\u044c \u0438 \u043e\u0442\u0434\u0435\u043b\u044f\u044e \u0446\u0435\u043b\u044c \u043e\u0442 \u043f\u0440\u0435\u0434\u0438\u043a\u0442\u043e\u0440\u043e\u0432, \u0442\u0430\u043a\u0436\u0435 \u0443\u0431\u0438\u0440\u0430\u044e \u0441\u0442\u043e\u043b\u0431\u0435\u0446 Date, \u0442.\u043a. #\u043e\u043d \u043d\u0438\u043a\u0430\u043a \u043d\u0435 \u043f\u043e\u043c\u043e\u0436\u0435\u0442 \u043c\u043e\u0434\u0435\u043b\u0438 y = machine_df_train.Result_bool X = machine_df_train.drop(['Date','Result', 'Result_bool'], axis=1)  #\u0441\u043e\u0437\u0434\u0430\u044e \u0444\u0443\u043d\u043a\u0446\u0438\u044e \u0434\u043b\u044f \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u044f \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0430 \u043f\u0440\u043e\u0433\u043d\u043e\u0437\u0430 \u043c\u043e\u0434\u0435\u043b\u0438 \u0432 \u043f\u0440\u043e\u0446\u0435\u043d\u0442\u0430\u0445 \u0441 \u0443\u0447\u0435\u0442\u043e\u043c \u043a\u043e\u043c\u0438\u0441\u0441\u0438\u0438 \u0431\u0440\u043e\u043a\u0435\u0440\u0430 def create_machine_result_perc(row):     return (abs(row.Result) - 0.00039 * 2) * 100 if row.Result_bool == row.machine_predict else (- abs(row.Result) - 0.00039 * 2) * 100 #\u0421\u043e\u0437\u0434\u0430\u044e \u0444\u0443\u043d\u043a\u0446\u0438\u044e \u0434\u043b\u044f \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0438 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u043e\u0432 \u043c\u043e\u0434\u0435\u043b\u0438 def machine_test_parameter(y, X, test_size, n_neighbors, machine_df_test): # \u0414\u0435\u043b\u044e \u0434\u0430\u043d\u043d\u044b\u0435 \u0434\u043b\u044f \u043f\u043e\u0441\u0442\u0440\u043e\u0435\u043d\u0438\u044f \u043c\u043e\u0434\u0435\u043b\u0438 \u0438 \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0438 X \u0438 y     X_train, X_valid, y_train, y_valid = train_test_split(X, y,                                                           test_size=test_size,                                                           random_state=42,                                                           shuffle = False                                                           )     knn = KNeighborsClassifier(n_neighbors=n_neighbors)     knn.fit(X_train, y_train)     knn_pred = knn.predict(X_valid)     y = machine_df_test.Result_bool     X = machine_df_test.drop(['Date','Result', 'Result_bool'], axis=1)     knn_pred_test = knn.predict(X)     machine_predict_df = pd.DataFrame({'machine_predict' : knn_pred_test})     index_list = machine_df_test.index.tolist()     machine_predict_df.index = index_list     machine_df_test = pd.concat([machine_df_test, machine_predict_df], axis = 1)     machine_result_perc = machine_df_test.apply(create_machine_result_perc, axis='columns')       return [test_size, n_neighbors, accuracy_score(y_valid, knn_pred),             accuracy_score(y, knn_pred_test), machine_result_perc.sum()] test_size_list = [] n_neighbors_list = [] accuracy_valid_list = [] accuracy_test_list = [] cumsum_list = [] #\u0434\u043b\u044f \u043f\u043e\u0438\u0441\u043a\u0430 \u043d\u0430\u0438\u043b\u0443\u0447\u0448\u0435\u0439 \u043a\u043e\u043c\u0431\u0438\u043d\u0430\u0446\u0438\u0438 \u043d\u0430\u0431\u043e\u0440\u0430 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u043e\u0432 \u0441\u043e\u0437\u0434\u0430\u043c \u0434\u0430\u0442\u0430-\u0444\u0440\u0435\u0439\u043c \u0441 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0430\u043c\u0438 #\u043c\u043e\u0434\u0435\u043b\u0438 \u0434\u043b\u044f \u0440\u0430\u0437\u043c\u0435\u0440\u0430 \u0442\u0435\u0441\u0442\u043e\u0432\u043e\u0439 \u0432\u044b\u0431\u043e\u0440\u043a\u0438 test_size [0.2,0.3,0.4,0.5] \u0438 # \u0447\u0438\u0441\u043b\u0430 \u0441\u043e\u0441\u0435\u0434\u0435\u0439 \u043e\u0442 1 \u0434\u043e 13 \u0432\u043a\u043b\u044e\u0447\u0438\u0442\u0435\u043b\u044c\u043d\u043e for test_size in [0.2,0.3,0.4,0.5]:     for n_neighbors in range(1,14):         res = machine_test_parameter(y, X, test_size, n_neighbors, machine_df_test)         test_size_list.append(res[0])         n_neighbors_list.append(res[1])         accuracy_valid_list.append(res[2])         accuracy_test_list.append(res[3])         cumsum_list.append(res[4]) #\u0414\u043b\u044f \u043e\u0446\u0435\u043d\u043a\u0438 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u043e\u0432 \u0441\u043e\u0437\u0434\u0430\u044e \u0434\u0430\u0442\u0430-\u0444\u0440\u0435\u0439\u043c parameter_df d = {'test_size': test_size_list,      'n_neighbors': n_neighbors_list,      'accuracy_valid' : accuracy_valid_list,      'accuracy_test' : accuracy_test_list,      'cumsum' : cumsum_list} parameter_df = pd.DataFrame(data=d) print(parameter_df)<\/code><\/pre>\n<details class=\"spoiler\">\n<summary>Hidden text<\/summary>\n<div class=\"spoiler__content\">\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w780q1\/getpro\/habr\/upload_files\/80e\/731\/c70\/80e731c70dbca10d25498069115df4cd.jpg\" width=\"566\" height=\"857\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/80e\/731\/c70\/80e731c70dbca10d25498069115df4cd.jpg\" data-blurred=\"true\"\/><figcaption><\/figcaption><\/figure>\n<\/p>\n<\/div>\n<\/details>\n<p>\u041f\u043e\u043b\u0443\u0447\u0435\u043d\u043d\u044b\u0439 \u043e\u0433\u0440\u043e\u043c\u043d\u044b\u0439 \u0440\u0430\u0437\u0431\u0440\u043e\u0441 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u043e\u0432 \u0434\u0430\u043b \u043b\u0443\u0447\u0448\u0435\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 +14,95% \u0438 \u0445\u0443\u0434\u0448\u0435\u0435 -120,2%. <\/p>\n<p>\u0421\u0440\u0435\u0434\u043d\u0435\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0430 \u043c\u043e\u0434\u0435\u043b\u0438 -52,2%, \u0447\u0442\u043e \u0445\u0443\u0436\u0435 \u0441\u0438\u0441\u0442\u0435\u043c\u044b \u0438\u0433\u0440\u044b \u043f\u043e \u0441\u043a\u043e\u043b\u044c\u0437\u044f\u0449\u0435\u0439 \u0441\u0440\u0435\u0434\u043d\u0435\u0439. \u0421\u043c\u043e\u0442\u0440\u044e, \u043a\u0430\u043a \u0434\u0435\u043b\u0430 \u0441 \u043f\u0440\u043e\u0446\u0435\u043d\u0442\u043e\u043c \u0432\u0435\u0440\u043d\u044b\u0445 \u043f\u0440\u043e\u0433\u043d\u043e\u0437\u043e\u0432:<\/p>\n<pre><code class=\"python\">print(parameter_df.accuracy_test.describe())<\/code><\/pre>\n<details class=\"spoiler\">\n<summary>Hidden text<\/summary>\n<div class=\"spoiler__content\">\n<figure class=\"\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w780q1\/getpro\/habr\/upload_files\/aa1\/ff8\/261\/aa1ff8261f5ea5d033e032ba875df6b7.jpg\" width=\"287\" height=\"147\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/aa1\/ff8\/261\/aa1ff8261f5ea5d033e032ba875df6b7.jpg\" data-blurred=\"true\"\/><figcaption><\/figcaption><\/figure>\n<\/p>\n<\/div>\n<\/details>\n<p>\u0421\u0440\u0435\u0434\u043d\u0435\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 51,8% \u0432\u0435\u0440\u043d\u044b\u0445 \u043f\u0440\u043e\u0433\u043d\u043e\u0437\u043e\u0432, \u044d\u0442\u043e \u043b\u0443\u0447\u0448\u0435, \u0447\u0435\u043c \u0443 \u0441\u0438\u0441\u0442\u0435\u043c\u044b \u0438\u0433\u0440\u044b \u043f\u043e \u0441\u043a\u043e\u043b\u044c\u0437\u044f\u0449\u0435\u0439 \u0441\u0440\u0435\u0434\u043d\u0435\u0439.<\/p>\n<pre><code class=\"python\">accuracy_test_rating_size = parameter_df.groupby('test_size').accuracy_test.mean() print(accuracy_test_rating_size)<\/code><\/pre>\n<details class=\"spoiler\">\n<summary>Hidden text<\/summary>\n<div class=\"spoiler__content\">\n<figure class=\"\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w780q1\/getpro\/habr\/upload_files\/de8\/128\/f95\/de8128f95021015b071a73d4188fefff.jpg\" width=\"287\" height=\"95\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/de8\/128\/f95\/de8128f95021015b071a73d4188fefff.jpg\" data-blurred=\"true\"\/><figcaption><\/figcaption><\/figure>\n<\/p>\n<\/div>\n<\/details>\n<pre><code class=\"python\">accuracy_test_rating_neig = parameter_df.groupby('n_neighbors').accuracy_test.mean() print(accuracy_test_rating_neig)<\/code><\/pre>\n<details class=\"spoiler\">\n<summary>Hidden text<\/summary>\n<div class=\"spoiler__content\">\n<figure class=\"\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w780q1\/getpro\/habr\/upload_files\/86a\/163\/c27\/86a163c2749716518b322ebc4a090128.jpg\" width=\"287\" height=\"244\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/86a\/163\/c27\/86a163c2749716518b322ebc4a090128.jpg\" data-blurred=\"true\"\/><figcaption><\/figcaption><\/figure>\n<\/p>\n<\/div>\n<\/details>\n<p>\u041b\u0443\u0447\u0448\u0438\u0439 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u043f\u0440\u0438 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f\u0445 test_size = 0,3 \u0438 \u0447\u0438\u0441\u043b\u0435 \u0441\u043e\u0441\u0435\u0434\u0435\u0439 \u00a0n_neighbors = 3. \u00a0\u041d\u043e \u0441 \u044d\u0442\u0438\u043c\u0438 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u0430\u043c\u0438 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u0442\u043e\u0440\u0433\u043e\u0432\u043b\u0438 \u0441\u0438\u0441\u0442\u0435\u043c\u044b -20,97%. \u041c\u043e\u0436\u043d\u043e \u043b\u0438 \u0434\u043e\u0432\u0435\u0440\u044f\u0442\u044c \u0442\u0430\u043a\u043e\u0439 \u043c\u043e\u0434\u0435\u043b\u0438? \u0421\u043e\u043c\u043d\u0435\u0432\u0430\u044e\u0441\u044c.<\/p>\n<p>\u0421\u0434\u0435\u043b\u0430\u044e \u043f\u0430\u0440\u0443 \u043f\u043e\u043f\u044b\u0442\u043e\u043a \u0443\u043b\u0443\u0447\u0448\u0438\u0442\u044c \u043c\u043e\u0434\u0435\u043b\u044c.<\/p>\n<h3>\u0423\u043b\u0443\u0447\u0448\u0435\u043d\u0438\u0435 \u043c\u043e\u0434\u0435\u043b\u0438 \u043f\u0443\u0442\u0435\u043c \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u0438\u0437\u0430\u0446\u0438\u0438 \u0438\u0441\u0445\u043e\u0434\u043d\u044b\u0445 \u0434\u0430\u043d\u043d\u044b\u0445<\/h3>\n<p>\u0412\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u044e\u0441\u044c \u043a \u043f\u043e\u0434\u0433\u043e\u0442\u043e\u0432\u043a\u0435 \u0438\u0441\u0445\u043e\u0434\u043d\u044b\u0445 \u0434\u0430\u043d\u043d\u044b\u0445 \u043c\u043e\u0434\u0435\u043b\u0438 \u0432 \u043d\u043e\u0432\u043e\u043c \u043e\u043a\u043d\u0435<\/p>\n<pre><code class=\"python\">#\u0438\u043c\u043f\u043e\u0440\u0442\u0438\u0440\u0443\u044e \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u044b\u0435 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438 import pandas as pd import numpy as np #\u0441\u043e\u0437\u0434\u0430\u044e \u0434\u0430\u0442\u0430-\u0444\u0440\u0435\u0439\u043c \u0441 \u043a\u043e\u0442\u0438\u0440\u043e\u0432\u043a\u0430\u043c\u0438 \u0432 \u043f\u0435\u0440\u0438\u043e\u0434 \u0441 05.01.2015\u0433 \u043f\u043e 30.12.2021\u0433. #\u0438\u0437 \u043f\u0440\u0435\u0434\u0432\u0430\u0440\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u0437\u0430\u0433\u0440\u0443\u0436\u0435\u043d\u043d\u043e\u0433\u043e \u0444\u0430\u0439\u043b\u0430 df = pd.read_csv('...\\csv_files\\GAZP_150105_213012.csv') #\u0438\u0437 \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u043d\u043e\u0433\u043e \u0434\u0430\u0442\u0430-\u0444\u0440\u0435\u0439\u043c\u0430 \u0441\u043e\u0437\u0434\u0430\u044e \u0434\u0430\u0442\u0430-\u0444\u0440\u0435\u0439\u043c \u0441\u043e \u0441\u0442\u043e\u043b\u0431\u0446\u0430\u043c\u0438 &lt;DATE>, &lt;OPEN>, #&lt;CLOSE> \u0432 \u043f\u0435\u0440\u0438\u043e\u0434 \u0434\u0430\u0442 \u0441 05.01.2015\u0433. \u043f\u043e 30.12.2021\u0433 date_open_close_df = df.iloc[:,[2,4,7]] print(date_open_close_df.head()) #\u043a\u0430\u0436\u0434\u044b\u0439 \u0441\u0442\u043e\u043b\u0431\u0435\u0446 \u0434\u0430\u0442\u0430-\u0444\u0440\u0435\u0439\u043c\u0430 date_open_close_df \u043f\u0435\u0440\u0435\u0432\u043e\u0436\u0443 \u0432 \u043c\u0430\u0441\u0441\u0438\u0432 numpy \u0434\u043b\u044f #\u043f\u043e\u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u0439 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0438 date_arr = date_open_close_df.iloc[:,0].to_numpy() open_arr = date_open_close_df.iloc[:,1].to_numpy() close_arr = date_open_close_df.iloc[:,2].to_numpy() #\u0441\u043e\u0437\u0434\u0430\u044e \u043c\u0430\u0441\u0441\u0438\u0432 \u0441 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u043e\u043c \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u0434\u043d\u044f \u043f\u043e \u0444\u043e\u0440\u043c\u0443\u043b\u0435 [(close - open) \/ open] res_arr = (close_arr - open_arr) \/ open_arr #\u0441 10-\u0439 \u0441\u0442\u0440\u043e\u043a\u0438 \u0441\u0447\u0438\u0442\u0430\u044e \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u0441\u043a\u043e\u043b\u044c\u0437\u044f\u0449\u0435\u0439 \u0441\u0440\u0435\u0434\u043d\u0435\u0439 \u0437\u0430 9 \u0434\u043d\u0435\u0439 SMA9 sma9_arr = [np.mean(close_arr[i-9:i]) for i in range(9,len(close_arr))] open10_arr = open_arr[9:] open_sma_arr = (open10_arr - sma9_arr) \/ open10_arr #\u0441\u043e\u0437\u0434\u0430\u044e \u0438\u0442\u043e\u0433\u043e\u0432\u044b\u0439 \u043c\u0430\u0441\u0441\u0438\u0432 \u0441 \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u0443\u044e\u0449\u0438\u043c\u0438 \u043c\u0435\u043d\u044f \u0434\u0430\u043d\u043d\u044b\u043c\u0438 \u0434\u043b\u044f \u043f\u043e\u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u0433\u043e \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f #\u0434\u0430\u0442\u0430-\u0444\u0440\u0435\u0439\u043c\u0430, \u043f\u0440\u0438 \u044d\u0442\u043e\u043c \u043d\u0430\u0447\u0430\u043b\u043e \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u0441\u0442\u043e\u043b\u0431\u0446\u0430 \u0441 10-\u0439 \u0441\u0442\u0440\u043e\u043a\u0438, \u0441 \u043a\u043e\u0442\u043e\u0440\u043e\u0439 #\u043d\u0430\u0447\u0438\u043d\u0430\u0435\u0442\u0441\u044f \u0440\u0430\u0441\u0447\u0435\u0442 SMA9 #\u041d\u043e\u0440\u043c\u0430\u043b\u0438\u0437\u0443\u044e \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u043d\u044b\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u043c\u0430\u0441\u0441\u0438\u0432\u043e\u0432 res_arr \u0438 open_sma_arr \u0434\u043e 5-\u0438 \u0440\u0430\u0437\u043b\u0438\u0447\u043d\u044b\u0445 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0439. #\u042d\u0442\u0430 \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u044f \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0435\u043d\u043d\u043e \u0443\u043c\u0435\u043d\u044c\u0448\u0438\u0442 \u0440\u0430\u0437\u0431\u0440\u043e\u0441 \u0432 \u0441\u0442\u043e\u043b\u0431\u0446\u0430\u0445 \u0438, \u043d\u0430 \u043c\u043e\u0439 \u0432\u0437\u0433\u043b\u044f\u0434, \u043e\u0431\u043b\u0435\u0433\u0447\u0438\u0442 \u0440\u0430\u0431\u043e\u0442\u0443  #\u043c\u043e\u0434\u0435\u043b\u0438. \u0421\u043d\u0430\u0447\u0430\u043b\u0430 \u043f\u043e\u043b\u0443\u0447\u0443 \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044e \u043e \u0440\u0430\u0437\u0431\u0440\u043e\u0441\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0439 \u043c\u0430\u0441\u0441\u0438\u0432\u043e\u0432 arr_to_describe = np.column_stack([res_arr[9:], open_sma_arr]) df_describe = pd.DataFrame(data = arr_to_describe,                            columns = ['Result', 'Open-SMA9']) print(df_describe.describe())<\/code><\/pre>\n<details class=\"spoiler\">\n<summary>Hidden text<\/summary>\n<div class=\"spoiler__content\">\n<figure class=\"\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w780q1\/getpro\/habr\/upload_files\/a86\/c12\/bb5\/a86c12bb50c175569e971d878916922a.jpg\" width=\"262\" height=\"146\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/a86\/c12\/bb5\/a86c12bb50c175569e971d878916922a.jpg\" data-blurred=\"true\"\/><figcaption><\/figcaption><\/figure>\n<\/p>\n<\/div>\n<\/details>\n<p>\u041f\u043e\u0441\u043b\u0435 \u0438\u0437\u0443\u0447\u0435\u043d\u0438\u044f \u0432\u044b\u0432\u043e\u0434\u0430 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u044e \u0433\u0440\u0430\u043d\u0438\u0446\u044b \u0434\u043b\u044f \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u0438\u0437\u0430\u0446\u0438\u0438:<\/p>\n<p>\u0414\u043b\u044f res_arr<\/p>\n<p>0 &#8212; \u0435\u0441\u043b\u0438 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 > -0.008 \u0438 &lt; 0.008 <\/p>\n<p>0.01 >=0.008 &lt; 0.016<\/p>\n<p>0.02 >=0.016<\/p>\n<p>-0.01 &lt;=-0.008 >-0.016<\/p>\n<p>-0.02 &lt;=-0.016<\/p>\n<p>\u00a0\u0414\u043b\u044f open_sma_arr<\/p>\n<p>0 &#8212; \u0435\u0441\u043b\u0438 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 > -0.015 \u0438 &lt; 0.015 <\/p>\n<p>0.01 >=0.015 &lt; 0.03<\/p>\n<p>0.02 >=0.03<\/p>\n<p>-0.01 &lt;=-0.015 >-0.03<\/p>\n<p>-0.02 &lt;=-0.03<\/p>\n<pre><code class=\"python\">#\u0421\u043e\u0437\u0434\u0430\u044e \u0444\u0443\u043d\u043a\u0446\u0438\u044e \u0434\u043b\u044f \u043d\u043e\u0440\u043c\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u043c\u0430\u0441\u0441\u0438\u0432\u043e\u0432 def standart_arr(arr, min2, min1, max2, max1):     arr = np.where((arr > min1) &amp; (arr &lt; max1), 0, arr)     arr = np.where(arr >= max2, 0.02, arr)     arr = np.where((arr >= max1) &amp; (arr &lt; max2), 0.01, arr)     arr = np.where(arr &lt;= min2, -0.02, arr)     arr = np.where((arr > min2) &amp; (arr &lt;= min1), -0.01, arr)     return arr #\u0447\u0442\u043e-\u0442\u043e \u043c\u043d\u0435 \u043f\u043e\u0434\u0441\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u0442, \u0447\u0442\u043e \u043a\u043e\u0434 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u043c\u043e\u0436\u043d\u043e \u043d\u0430\u043f\u0438\u0441\u0430\u0442\u044c \u0433\u043e\u0440\u0430\u0437\u0434\u043e \u0431\u043e\u043b\u0435\u0435 \u0440\u0430\u0446\u0438\u043e\u043d\u0430\u043b\u044c\u043d\u043e.  #\u0415\u0441\u043b\u0438 \u043a\u0442\u043e-\u0442\u043e \u043f\u043e\u0434\u0441\u043a\u0430\u0436\u0435\u0442 \u0432 \u043a\u043e\u043c\u043c\u0435\u043d\u0442\u0430\u0440\u0438\u044f\u0445 \u043a\u0430\u043a, \u0431\u0443\u0434\u0443 \u043f\u0440\u0438\u0437\u043d\u0430\u0442\u0435\u043b\u0435\u043d res_arr_std = standart_arr(res_arr, -0.016, -0.008, 0.016, 0.008) open_sma_arr_std = standart_arr(open_sma_arr, -0.03, -0.015, 0.03, 0.015) print('res_arr_std',res_arr_std) print('open_sma_arr_std',open_sma_arr_std)<\/code><\/pre>\n<figure class=\"\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w780q1\/getpro\/habr\/upload_files\/07e\/db6\/9d0\/07edb69d09d73451d75ce22c36cebae5.jpg\" width=\"428\" height=\"36\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/07e\/db6\/9d0\/07edb69d09d73451d75ce22c36cebae5.jpg\" data-blurred=\"true\"\/><figcaption><\/figcaption><\/figure>\n<pre><code class=\"python\">#\u0441\u043e\u0437\u0434\u0430\u044e \u0434\u0430\u0442\u0430-\u0444\u0440\u0435\u0439\u043c \u043c\u043e\u0434\u0435\u043b\u0438 machine_df_mod arr_to_df = np.column_stack([date_arr[9:], res_arr_std[:-9], res_arr_std[1:-8], res_arr_std[2:-7],                              res_arr_std[3:-6], res_arr_std[4:-5], res_arr_std[5:-4],                              res_arr_std[6:-3], res_arr_std[7:-2], res_arr_std[8:-1],                              open_sma_arr_std, res_arr[9:]]) machine_df_mod = pd.DataFrame(data = arr_to_df,                         columns = ['Date', 'Res_9_day', 'Res_8_day', 'Res_7_day',                                    'Res_6_day', 'Res_5_day', 'Res_4_day',                                    'Res_3_day', 'Res_2_day', 'Res_1_day',                                    'Open-SMA9', 'Result']) print(machine_df_mod.head())<\/code><\/pre>\n<details class=\"spoiler\">\n<summary>Hidden text<\/summary>\n<div class=\"spoiler__content\">\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w780q1\/getpro\/habr\/upload_files\/5a1\/4a0\/448\/5a14a04488df5e401045af9185a6e292.jpg\" width=\"591\" height=\"128\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/5a1\/4a0\/448\/5a14a04488df5e401045af9185a6e292.jpg\" data-blurred=\"true\"\/><figcaption><\/figcaption><\/figure>\n<\/p>\n<\/div>\n<\/details>\n<pre><code class=\"python\">#\u0437\u0430\u043f\u0438\u0441\u044b\u0432\u0430\u044e \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u043d\u044b\u0439 \u0434\u0430\u0442\u0430-\u0444\u0440\u0435\u0439\u043c \u0447\u0435\u043b\u043e\u0432\u0435\u043a\u0430-\u0442\u0440\u0435\u0439\u0434\u0435\u0440\u0430 \u0432 \u0444\u0430\u0439\u043b gazp_machine_df_mod.csv  machine_df_mod.to_csv('...\\data-frame\\gazp_machine_df_mod.csv')<\/code><\/pre>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u044e\u0441\u044c \u043a \u043c\u043e\u0434\u0435\u043b\u0438 \u0441 \u043d\u043e\u0432\u044b\u043c \u0434\u0430\u0442\u0430-\u0444\u0440\u0435\u0439\u043c\u043e\u043c machine_df_mod \u0432 \u043d\u043e\u0432\u043e\u043c \u043e\u043a\u043d\u0435<\/p>\n<pre><code class=\"python\">#\u0438\u043c\u043f\u043e\u0440\u0442\u0438\u0440\u0443\u044e \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u044b\u0435 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438 from sklearn.model_selection import train_test_split, StratifiedKFold from sklearn.neighbors import KNeighborsClassifier from sklearn.metrics import accuracy_score import pandas as pd  #\u0417\u0430\u0433\u0440\u0443\u0436\u0430\u044e \u0434\u0430\u0442\u0430-\u0444\u0440\u0435\u0439\u043c \u043c\u043e\u0434\u0435\u043b\u0438 machine_df_mod = pd.read_csv('...\\data-frame\\gazp_machine_df_mod.csv', index_col = 0) #\u0441\u043e\u0437\u0434\u0430\u044e \u0444\u0443\u043d\u043a\u0446\u0438\u044e \u0434\u043b\u044f \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u044f \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0430 \u0434\u043d\u044f \u0432 \u0431\u0443\u043b\u0435\u0432\u043e\u043c \u043c\u043d\u043e\u0436\u0435\u0441\u0442\u0432\u0435 def create_result_bool(row):     return 1 if row.Result >= 0 else 0 #\u0441\u043e\u0437\u0434\u0430\u044e \u0441\u0435\u0440\u0438\u044e \u0441 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0430\u043c\u0438 \u0434\u043d\u044f \u0432 \u0431\u0443\u043b\u0435\u0432\u043e\u043c \u043c\u043d\u043e\u0436\u0435\u0441\u0442\u0432\u0435 result_bool = machine_df_mod.apply(create_result_bool, axis='columns') #\u0434\u043e\u0431\u0430\u0432\u043b\u044f\u044e \u0432 \u0434\u0430\u0442\u0430-\u0444\u0440\u0435\u0439\u043c machine_df \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u043d\u0443\u044e \u0441\u0435\u0440\u0438\u044e machine_df_mod = pd.concat([machine_df_mod, result_bool], axis = 1) machine_df_mod.columns.values[12]='Result_bool' #\u0432 \u0434\u0430\u0442\u0430-\u0444\u0440\u0435\u0439\u043c\u0435 1756 \u0441\u0442\u0440\u043e\u043a. \u042f \u0440\u0430\u0437\u0434\u0435\u043b\u044e \u0435\u0433\u043e \u043d\u0430 \u0434\u0432\u0430 \u0434\u0430\u0442\u0430-\u0444\u0440\u0435\u0439\u043c\u0430: #machine_df_train (493 \u0441\u0442\u0440\u043e\u043a\u0438, \u0441 19.01.2015 \u043f\u043e 30.12.2016) \u0438 #machine_df_test (1263 \u0441\u0442\u0440\u043e\u043a\u0438 \u0441 03.01.2017 \u043f\u043e 30.12.2021).  machine_df_train = machine_df_mod.iloc[:493] machine_df_test = machine_df_mod.iloc[493:] # \u041e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u044e \u0446\u0435\u043b\u044c \u0438 \u043e\u0442\u0434\u0435\u043b\u044f\u044e \u0446\u0435\u043b\u044c \u043e\u0442 \u043f\u0440\u0435\u0434\u0438\u043a\u0442\u043e\u0440\u043e\u0432, \u0442\u0430\u043a\u0436\u0435 \u0443\u0431\u0440\u0430\u043b \u0441\u0442\u043e\u043b\u0431\u0435\u0446 Date, \u0442.\u043a. #\u043e\u043d \u043d\u0438\u043a\u0430\u043a \u043d\u0435 \u043f\u043e\u043c\u043e\u0436\u0435\u0442 \u043c\u043e\u0434\u0435\u043b\u0438 y = machine_df_train.Result_bool X = machine_df_train.drop(['Date','Result', 'Result_bool'], axis=1) #\u0441\u043e\u0437\u0434\u0430\u044e \u0444\u0443\u043d\u043a\u0446\u0438\u044e \u0434\u043b\u044f \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u044f \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0430 \u043f\u0440\u043e\u0433\u043d\u043e\u0437\u0430 \u043c\u043e\u0434\u0435\u043b\u0438 \u0432 \u043f\u0440\u043e\u0446\u0435\u043d\u0442\u0430\u0445 \u0441 \u0443\u0447\u0435\u0442\u043e\u043c \u043a\u043e\u043c\u0438\u0441\u0441\u0438\u0438 \u0431\u0440\u043e\u043a\u0435\u0440\u0430 def create_machine_result_perc(row):     return (abs(row.Result) - 0.00039 * 2) * 100 if row.Result_bool == row.machine_predict else (- abs(row.Result) - 0.00039 * 2) * 100 #\u0421\u043e\u0437\u0434\u0430\u044e \u0444\u0443\u043d\u043a\u0446\u0438\u044e \u0434\u043b\u044f \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0438 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u043e\u0432 \u043c\u043e\u0434\u0435\u043b\u0438 def machine_test_parameter(y, X, test_size, n_neighbors, machine_df_test): # \u0414\u0435\u043b\u044e \u0434\u0430\u043d\u043d\u044b\u0435 \u0434\u043b\u044f \u043f\u043e\u0441\u0442\u0440\u043e\u0435\u043d\u0438\u044f \u043c\u043e\u0434\u0435\u043b\u0438 \u0438 \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0438 X \u0438 y     X_train, X_valid, y_train, y_valid = train_test_split(X, y,                                                           test_size=test_size,                                                           random_state=42,                                                           shuffle = False                                                           )     knn = KNeighborsClassifier(n_neighbors=n_neighbors)     knn.fit(X_train, y_train)     knn_pred = knn.predict(X_valid)     y = machine_df_test.Result_bool     X = machine_df_test.drop(['Date','Result', 'Result_bool'], axis=1)     knn_pred_test = knn.predict(X)     machine_predict_df = pd.DataFrame({'machine_predict' : knn_pred_test})     index_list = machine_df_test.index.tolist()     machine_predict_df.index = index_list     machine_df_test = pd.concat([machine_df_test, machine_predict_df], axis = 1)     machine_result_perc = machine_df_test.apply(create_machine_result_perc, axis='columns')        return [test_size, n_neighbors, accuracy_score(y_valid, knn_pred),             accuracy_score(y, knn_pred_test), machine_result_perc.sum()]  test_size_list = [] n_neighbors_list = [] accuracy_valid_list = [] accuracy_test_list = [] cumsum_list = [] #\u0434\u043b\u044f \u043f\u043e\u0438\u0441\u043a\u0430 \u043d\u0430\u0438\u043b\u0443\u0447\u0448\u0435\u0439 \u043a\u043e\u043c\u0431\u0438\u043d\u0430\u0446\u0438\u0438 \u043d\u0430\u0431\u043e\u0440\u0430 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u043e\u0432 \u0441\u043e\u0437\u0434\u0430\u043c \u0434\u0430\u0442\u0430-\u0444\u0440\u0435\u0439\u043c \u0441 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0430\u043c\u0438 #\u043c\u043e\u0434\u0435\u043b\u0438 \u0434\u043b\u044f \u0440\u0430\u0437\u043c\u0435\u0440\u0430 \u0442\u0435\u0441\u0442\u043e\u0432\u043e\u0439 \u0432\u044b\u0431\u043e\u0440\u043a\u0438 test_size [0.2,0.3,0.4,0.5] \u0438 # \u0447\u0438\u0441\u043b\u0430 \u0441\u043e\u0441\u0435\u0434\u0435\u0439 \u043e\u0442 1 \u0434\u043e 13 \u0432\u043a\u043b\u044e\u0447\u0438\u0442\u0435\u043b\u044c\u043d\u043e for test_size in [0.2,0.3,0.4,0.5]:     for n_neighbors in range(1,14):         res = machine_test_parameter(y, X, test_size, n_neighbors, machine_df_test)         test_size_list.append(res[0])         n_neighbors_list.append(res[1])         accuracy_valid_list.append(res[2])         accuracy_test_list.append(res[3])         cumsum_list.append(res[4])  d = {'test_size': test_size_list,      'n_neighbors': n_neighbors_list,      'accuracy_valid' : accuracy_valid_list,      'accuracy_test' : accuracy_test_list,      'cumsum' : cumsum_list} parameter_df = pd.DataFrame(data=d) print(parameter_df) print(parameter_df.accuracy_test.describe()) accuracy_test_rating_size = parameter_df.groupby('test_size').accuracy_test.mean() print(accuracy_test_rating_size) accuracy_test_rating_neig = parameter_df.groupby('n_neighbors').accuracy_test.mean() print(accuracy_test_rating_neig)<\/code><\/pre>\n<details class=\"spoiler\">\n<summary>Hidden text<\/summary>\n<div class=\"spoiler__content\">\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w780q1\/getpro\/habr\/upload_files\/021\/eb6\/e7f\/021eb6e7f27c219b718ad5e871ce8702.jpg\" width=\"566\" height=\"858\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/021\/eb6\/e7f\/021eb6e7f27c219b718ad5e871ce8702.jpg\" data-blurred=\"true\"\/><figcaption><\/figcaption><\/figure>\n<\/p>\n<\/div>\n<\/details>\n<p>\u0421\u0440\u0435\u0434\u043d\u0435\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0430 \u043c\u043e\u0434\u0435\u043b\u0438 -130,6%, \u0442\u043e \u0435\u0441\u0442\u044c \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u043d\u0435 \u0443\u043b\u0443\u0447\u0448\u0438\u043b\u0441\u044f, \u0430 \u043f\u043e\u0447\u0442\u0438 \u0432 3 \u0440\u0430\u0437\u0430 \u0443\u0445\u0443\u0434\u0448\u0438\u043b\u0441\u044f.<\/p>\n<h3>\u0423\u043b\u0443\u0447\u0448\u0435\u043d\u0438\u0435 \u043c\u043e\u0434\u0435\u043b\u0438 \u043f\u0443\u0442\u0435\u043c \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0438\u044f \u043d\u043e\u0432\u043e\u0433\u043e \u043a\u043b\u0430\u0441\u0441\u0430 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0430<\/h3>\n<p>\u041f\u043e\u043f\u0440\u043e\u0431\u0443\u044e \u043f\u043e\u0439\u0442\u0438 \u0434\u0440\u0443\u0433\u0438\u043c \u043f\u0443\u0442\u0435\u043c: \u0440\u0430\u043d\u0435\u0435 \u043c\u043e\u0434\u0435\u043b\u044c \u0443\u0447\u0438\u043b\u0430\u0441\u044c \u0441 \u0446\u0435\u043b\u0435\u0432\u044b\u043c \u0441\u0442\u043e\u043b\u0431\u0446\u043e\u043c Result_bool, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0441\u043e\u0434\u0435\u0440\u0436\u0430\u043b \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 1, \u0435\u0441\u043b\u0438 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u0434\u043d\u044f \u0431\u044b\u043b \u043f\u043e\u043b\u043e\u0436\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u043c \u0438 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 0, \u0435\u0441\u043b\u0438 \u043e\u0442\u0440\u0438\u0446\u0430\u0442\u0435\u043b\u044c\u043d\u044b\u043c. \u041f\u043e\u043f\u0440\u043e\u0431\u0443\u044e \u0432\u0432\u0435\u0441\u0442\u0438 \u043d\u0435 2, \u0430 3 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u0446\u0435\u043b\u0435\u0432\u043e\u0433\u043e \u0441\u0442\u043e\u043b\u0431\u0446\u0430:<\/p>\n<p>0 \u2013 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u0434\u043d\u044f \u043e\u0442 -0.01 \u0434\u043e 0.01 (\u0434\u0435\u043d\u044c, \u043d\u0435 \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u044b\u0439 \u0434\u043b\u044f \u0442\u043e\u0440\u0433\u043e\u0432\u043b\u0438, \u043a\u043e\u0433\u0434\u0430 \u0446\u0435\u043d\u0430 \u0430\u043a\u0446\u0438\u0438 \u043c\u0435\u043d\u044f\u043b\u0430\u0441\u044c \u0432 \u0434\u0438\u0430\u043f\u0430\u0437\u043e\u043d\u0435 \u043c\u0435\u043d\u0435\u0435 1%)<\/p>\n<p>1 \u2013 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u0434\u043d\u044f \u0431\u043e\u043b\u044c\u0448\u0435 0.01<\/p>\n<p>-1 \u2013 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u0434\u043d\u044f \u043c\u0435\u043d\u044c\u0448\u0435 -0.01<\/p>\n<p>\u041c\u0435\u043d\u044f \u0431\u0443\u0434\u0443\u0442 \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043e\u0432\u0430\u0442\u044c \u0442\u043e\u043b\u044c\u043a\u043e \u043f\u0440\u043e\u0433\u043d\u043e\u0437\u044b \u043c\u043e\u0434\u0435\u043b\u0438 \u00ab-1\u00bb \u0438 \u00ab1\u00bb. \u0422\u0430\u043a\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c \u043c\u043e\u0434\u0435\u043b\u044c \u0431\u0443\u0434\u0435\u0442 \u0442\u043e\u0440\u0433\u043e\u0432\u0430\u0442\u044c \u0440\u0435\u0436\u0435 \u0438, \u0431\u044b\u0442\u044c \u043c\u043e\u0436\u0435\u0442, \u0442\u043e\u0447\u043d\u0435\u0435. \u0412 \u043d\u043e\u0432\u043e\u043c \u043e\u043a\u043d\u0435:<\/p>\n<pre><code class=\"python\">#\u0438\u043c\u043f\u043e\u0440\u0442\u0438\u0440\u0443\u044e \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u044b\u0435 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438 from sklearn.model_selection import train_test_split, StratifiedKFold from sklearn.neighbors import KNeighborsClassifier from sklearn.metrics import accuracy_score import pandas as pd  machine_df = pd.read_csv('...\\data-frame\\gazp_machine_df.csv', index_col = 0) #\u0441\u043e\u0437\u0434\u0430\u044e \u0444\u0443\u043d\u043a\u0446\u0438\u044e \u0434\u043b\u044f \u043f\u0440\u0438\u0441\u0432\u043e\u0435\u043d\u0438\u044f \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0443 \u0434\u043d\u044f \u043e\u0434\u043d\u043e\u0433\u043e \u0438\u0437 \u0442\u0440\u0435\u0445 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0439 def create_result_3way(row):     if abs(row.Result) &lt; 0.01:         return 0     elif row.Result >= 0.01:         return 1     else:         return -1 #\u0441\u043e\u0437\u0434\u0430\u044e \u0441\u0435\u0440\u0438\u044e \u0441 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0430\u043c\u0438 \u0434\u043d\u044f \u0432 \u0431\u0443\u043b\u0435\u0432\u043e\u043c \u043c\u043d\u043e\u0436\u0435\u0441\u0442\u0432\u0435 result_3way = machine_df.apply(create_result_3way, axis='columns') #\u0434\u043e\u0431\u0430\u0432\u043b\u044f\u044e \u0432 \u0434\u0430\u0442\u0430-\u0444\u0440\u0435\u0439\u043c machine_df \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u043d\u0443\u044e \u0441\u0435\u0440\u0438\u044e machine_df = pd.concat([machine_df, result_3way], axis = 1) machine_df.columns.values[12]='Result_3way' #\u0432\u044b\u0432\u043e\u0436\u0443 \u043f\u0435\u0440\u0432\u044b\u0435 5 \u0441\u0442\u0440\u043e\u043a \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u043d\u043e\u0433\u043e \u0434\u0430\u0442\u0430-\u0444\u0440\u0435\u0439\u043c\u0430 print(machine_df.head()) #print(machine_df.shape) #\u0432 \u0434\u0430\u0442\u0430-\u0444\u0440\u0435\u0439\u043c\u0435 1756 \u0441\u0442\u0440\u043e\u043a. \u042f \u0440\u0430\u0437\u0434\u0435\u043b\u044e \u0435\u0433\u043e \u043d\u0430 \u0434\u0432\u0430 \u0434\u0430\u0442\u0430-\u0444\u0440\u0435\u0439\u043c\u0430: #machine_df_train (493 \u0441\u0442\u0440\u043e\u043a\u0438, \u0441 19.01.2015 \u043f\u043e 30.12.2016) \u0438 #machine_df_test (1263 \u0441\u0442\u0440\u043e\u043a\u0438 \u0441 03.01.2017 \u043f\u043e 30.12.2021).  machine_df_train = machine_df.iloc[:493] machine_df_test = machine_df.iloc[493:] #print(machine_df_test.head()) # \u041e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u044e \u0446\u0435\u043b\u044c \u0438 \u043e\u0442\u0434\u0435\u043b\u044f\u044e \u0446\u0435\u043b\u044c \u043e\u0442 \u043f\u0440\u0435\u0434\u0438\u043a\u0442\u043e\u0440\u043e\u0432, \u0442\u0430\u043a\u0436\u0435 \u0443\u0431\u0440\u0430\u043b \u0441\u0442\u043e\u043b\u0431\u0435\u0446 Date, \u0442.\u043a. #\u043e\u043d \u043d\u0438\u043a\u0430\u043a \u043d\u0435 \u043f\u043e\u043c\u043e\u0436\u0435\u0442 \u043c\u043e\u0434\u0435\u043b\u0438 y = machine_df_train.Result_3way X = machine_df_train.drop(['Date','Result', 'Result_3way'], axis=1)  #\u0441\u043e\u0437\u0434\u0430\u044e \u0444\u0443\u043d\u043a\u0446\u0438\u044e \u0434\u043b\u044f \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u044f \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0430 \u043f\u0440\u043e\u0433\u043d\u043e\u0437\u0430 \u043c\u043e\u0434\u0435\u043b\u0438 \u0432 \u043f\u0440\u043e\u0446\u0435\u043d\u0442\u0430\u0445 \u0441 \u0443\u0447\u0435\u0442\u043e\u043c \u043a\u043e\u043c\u0438\u0441\u0441\u0438\u0438 \u0431\u0440\u043e\u043a\u0435\u0440\u0430 def create_machine_result_perc(row):     if row.Result > 0 and row.machine_predict == 1 or row.Result &lt; 0 and row.machine_predict == -1:         return (abs(row.Result) - 0.00039 * 2) * 100     elif row.Result &lt; 0 and row.machine_predict == 1 or row.Result > 0 and row.machine_predict == -1:         return (-abs(row.Result) - 0.00039 * 2) * 100            #\u0421\u043e\u0437\u0434\u0430\u044e \u0444\u0443\u043d\u043a\u0446\u0438\u044e \u0434\u043b\u044f \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0438 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u043e\u0432 \u043c\u043e\u0434\u0435\u043b\u0438 def machine_test_parameter(y, X, test_size, n_neighbors, machine_df_test): # \u0414\u0435\u043b\u044e \u0434\u0430\u043d\u043d\u044b\u0435 \u0434\u043b\u044f \u043f\u043e\u0441\u0442\u0440\u043e\u0435\u043d\u0438\u044f \u043c\u043e\u0434\u0435\u043b\u0438 \u0438 \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0438 X \u0438 y     X_train, X_valid, y_train, y_valid = train_test_split(X, y,                                                           test_size=test_size,                                                           random_state=42,                                                           shuffle = False                                                           )     knn = KNeighborsClassifier(n_neighbors=n_neighbors)     knn.fit(X_train, y_train)     knn_pred = knn.predict(X_valid) #    print(accuracy_score(y_valid, knn_pred))     y = machine_df_test.Result_3way     X = machine_df_test.drop(['Date','Result', 'Result_3way'], axis=1)     knn_pred_test = knn.predict(X) #    print(accuracy_score(y, knn_pred))     machine_predict_df = pd.DataFrame({'machine_predict' : knn_pred_test})     index_list = machine_df_test.index.tolist()     machine_predict_df.index = index_list     machine_df_test = pd.concat([machine_df_test, machine_predict_df], axis = 1)     print(machine_df_test.head())     machine_result_perc = machine_df_test.apply(create_machine_result_perc, axis='columns')     #    machine_result_cumsum = machine_result_perc.cumsum() #    print(machine_result_cumsum) #    print('test_size ',test_size) #    print('n_neighbors', n_neighbors) #    print('accuracy_score(y_valid, knn_pred_test)', accuracy_score(y_valid, knn_pred_test)) #    print('',) #    print('',)          return [test_size, n_neighbors, accuracy_score(y_valid, knn_pred),             accuracy_score(y, knn_pred_test), machine_result_perc.sum()]  a = machine_test_parameter(y, X, 0.3, 9, machine_df_test) print(a) test_size_list = [] n_neighbors_list = [] accuracy_valid_list = [] accuracy_test_list = [] cumsum_list = [] #\u0434\u043b\u044f \u043f\u043e\u0438\u0441\u043a\u0430 \u043d\u0430\u0438\u043b\u0443\u0447\u0448\u0435\u0439 \u043a\u043e\u043c\u0431\u0438\u043d\u0430\u0446\u0438\u0438 \u043d\u0430\u0431\u043e\u0440\u0430 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u043e\u0432 \u0441\u043e\u0437\u0434\u0430\u043c \u0434\u0430\u0442\u0430-\u0444\u0440\u0435\u0439\u043c \u0441 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0430\u043c\u0438 #\u043c\u043e\u0434\u0435\u043b\u0438 \u0434\u043b\u044f \u0440\u0430\u0437\u043c\u0435\u0440\u0430 \u0442\u0435\u0441\u0442\u043e\u0432\u043e\u0439 \u0432\u044b\u0431\u043e\u0440\u043a\u0438 test_size [0.2,0.3,0.4,0.5] \u0438 # \u0447\u0438\u0441\u043b\u0430 \u0441\u043e\u0441\u0435\u0434\u0435\u0439 \u043e\u0442 1 \u0434\u043e 13 \u0432\u043a\u043b\u044e\u0447\u0438\u0442\u0435\u043b\u044c\u043d\u043e for test_size in [0.2,0.3,0.4,0.5]:     for n_neighbors in range(1,14):         res = machine_test_parameter(y, X, test_size, n_neighbors, machine_df_test)         test_size_list.append(res[0])         n_neighbors_list.append(res[1])         accuracy_valid_list.append(res[2])         accuracy_test_list.append(res[3])         cumsum_list.append(res[4]) #\u0414\u043b\u044f \u043e\u0446\u0435\u043d\u043a\u0438 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u043e\u0432 \u0441\u043e\u0437\u0434\u0430\u044e \u0434\u0430\u0442\u0430-\u0444\u0440\u0435\u0439\u043c parameter_df d = {'test_size': test_size_list,      'n_neighbors': n_neighbors_list,      'accuracy_valid' : accuracy_valid_list,      'accuracy_test' : accuracy_test_list,      'cumsum' : cumsum_list} parameter_df = pd.DataFrame(data=d) print(parameter_df)<\/code><\/pre>\n<details class=\"spoiler\">\n<summary>Hidden text<\/summary>\n<div class=\"spoiler__content\">\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w780q1\/getpro\/habr\/upload_files\/910\/01c\/971\/91001c97157fed404decc97b4dde60b9.jpg\" width=\"602\" height=\"114\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/910\/01c\/971\/91001c97157fed404decc97b4dde60b9.jpg\" data-blurred=\"true\"\/><figcaption><\/figcaption><\/figure>\n<\/p>\n<\/div>\n<\/details>\n<pre><code class=\"python\">#\u0432 \u0434\u0430\u0442\u0430-\u0444\u0440\u0435\u0439\u043c\u0435 1756 \u0441\u0442\u0440\u043e\u043a. \u042f \u0440\u0430\u0437\u0434\u0435\u043b\u044e \u0435\u0433\u043e \u043d\u0430 \u0434\u0432\u0430 \u0434\u0430\u0442\u0430-\u0444\u0440\u0435\u0439\u043c\u0430: #machine_df_train (493 \u0441\u0442\u0440\u043e\u043a\u0438, \u0441 19.01.2015 \u043f\u043e 30.12.2016) \u0438 #machine_df_test (1263 \u0441\u0442\u0440\u043e\u043a\u0438 \u0441 03.01.2017 \u043f\u043e 30.12.2021). machine_df_train = machine_df.iloc[:493] machine_df_test = machine_df.iloc[493:] #\u041e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u044e \u0446\u0435\u043b\u044c \u0438 \u043e\u0442\u0434\u0435\u043b\u044f\u044e \u0446\u0435\u043b\u044c \u043e\u0442 \u043f\u0440\u0435\u0434\u0438\u043a\u0442\u043e\u0440\u043e\u0432, \u0442\u0430\u043a\u0436\u0435 \u0443\u0431\u0440\u0430\u043b \u0441\u0442\u043e\u043b\u0431\u0435\u0446 Date, \u0442.\u043a. #\u043e\u043d \u043d\u0438\u043a\u0430\u043a \u043d\u0435 \u043f\u043e\u043c\u043e\u0436\u0435\u0442 \u043c\u043e\u0434\u0435\u043b\u0438 y = machine_df_train.Result_3way X = machine_df_train.drop(['Date','Result', 'Result_3way'], axis=1) #\u0441\u043e\u0437\u0434\u0430\u044e \u0444\u0443\u043d\u043a\u0446\u0438\u044e \u0434\u043b\u044f \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u044f \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0430 \u043f\u0440\u043e\u0433\u043d\u043e\u0437\u0430 \u043c\u043e\u0434\u0435\u043b\u0438 \u0432 \u043f\u0440\u043e\u0446\u0435\u043d\u0442\u0430\u0445 \u0441 \u0443\u0447\u0435\u0442\u043e\u043c \u043a\u043e\u043c\u0438\u0441\u0441\u0438\u0438 \u0431\u0440\u043e\u043a\u0435\u0440\u0430 def create_machine_result_perc(row):     if row.Result > 0 and row.machine_predict == 1 or row.Result &lt; 0 and row.machine_predict == -1:         return (abs(row.Result) - 0.00039 * 2) * 100     elif row.Result &lt; 0 and row.machine_predict == 1 or row.Result > 0 and row.machine_predict == -1:         return (-abs(row.Result) - 0.00039 * 2) * 100     else: return 0 #\u0421\u043e\u0437\u0434\u0430\u044e \u0444\u0443\u043d\u043a\u0446\u0438\u044e \u0434\u043b\u044f \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0438 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u043e\u0432 \u043c\u043e\u0434\u0435\u043b\u0438 def machine_test_parameter(y, X, test_size, n_neighbors, machine_df_test): # \u0414\u0435\u043b\u044e \u0434\u0430\u043d\u043d\u044b\u0435 \u0434\u043b\u044f \u043f\u043e\u0441\u0442\u0440\u043e\u0435\u043d\u0438\u044f \u043c\u043e\u0434\u0435\u043b\u0438 \u0438 \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0438 X \u0438 y     X_train, X_valid, y_train, y_valid = train_test_split(X, y,                                                           test_size=test_size,                                                           random_state=42,                                                           shuffle = False                                                           )     knn = KNeighborsClassifier(n_neighbors=n_neighbors)     knn.fit(X_train, y_train)     knn_pred = knn.predict(X_valid)     y = machine_df_test.Result_3way     X = machine_df_test.drop(['Date','Result', 'Result_3way'], axis=1)     knn_pred_test = knn.predict(X)     machine_predict_df = pd.DataFrame({'machine_predict' : knn_pred_test})     index_list = machine_df_test.index.tolist()     machine_predict_df.index = index_list     machine_df_test = pd.concat([machine_df_test, machine_predict_df], axis = 1)     machine_result_perc = machine_df_test.apply(create_machine_result_perc, axis='columns')             return [test_size, n_neighbors, accuracy_score(y_valid, knn_pred),             accuracy_score(y, knn_pred_test), machine_result_perc.sum()]  test_size_list = [] n_neighbors_list = [] accuracy_valid_list = [] accuracy_test_list = [] cumsum_list = [] #\u0434\u043b\u044f \u043f\u043e\u0438\u0441\u043a\u0430 \u043d\u0430\u0438\u043b\u0443\u0447\u0448\u0435\u0439 \u043a\u043e\u043c\u0431\u0438\u043d\u0430\u0446\u0438\u0438 \u043d\u0430\u0431\u043e\u0440\u0430 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u043e\u0432 \u0441\u043e\u0437\u0434\u0430\u043c \u0434\u0430\u0442\u0430-\u0444\u0440\u0435\u0439\u043c \u0441 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0430\u043c\u0438 #\u043c\u043e\u0434\u0435\u043b\u0438 \u0434\u043b\u044f \u0440\u0430\u0437\u043c\u0435\u0440\u0430 \u0442\u0435\u0441\u0442\u043e\u0432\u043e\u0439 \u0432\u044b\u0431\u043e\u0440\u043a\u0438 test_size [0.2,0.3,0.4,0.5] \u0438 # \u0447\u0438\u0441\u043b\u0430 \u0441\u043e\u0441\u0435\u0434\u0435\u0439 \u043e\u0442 1 \u0434\u043e 13 \u0432\u043a\u043b\u044e\u0447\u0438\u0442\u0435\u043b\u044c\u043d\u043e for test_size in [0.2,0.3,0.4,0.5]:     for n_neighbors in range(1,14):         res = machine_test_parameter(y, X, test_size, n_neighbors, machine_df_test)         test_size_list.append(res[0])         n_neighbors_list.append(res[1])         accuracy_valid_list.append(res[2])         accuracy_test_list.append(res[3])         cumsum_list.append(res[4]) #\u0414\u043b\u044f \u043e\u0446\u0435\u043d\u043a\u0438 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u043e\u0432 \u0441\u043e\u0437\u0434\u0430\u044e \u0434\u0430\u0442\u0430-\u0444\u0440\u0435\u0439\u043c parameter_df d = {'test_size': test_size_list,      'n_neighbors': n_neighbors_list,      'accuracy_valid' : accuracy_valid_list,      'accuracy_test' : accuracy_test_list,      'cumsum' : cumsum_list} parameter_df = pd.DataFrame(data=d) print(parameter_df)<\/code><\/pre>\n<details class=\"spoiler\">\n<summary>Hidden text<\/summary>\n<div class=\"spoiler__content\">\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w780q1\/getpro\/habr\/upload_files\/8ee\/9a7\/6f8\/8ee9a76f89cf6ccf58cc92a86fae5041.jpg\" width=\"559\" height=\"859\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/8ee\/9a7\/6f8\/8ee9a76f89cf6ccf58cc92a86fae5041.jpg\" data-blurred=\"true\"\/><figcaption><\/figcaption><\/figure>\n<\/p>\n<\/div>\n<\/details>\n<p>\u0421\u0440\u0435\u0434\u043d\u0435\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 -23,79%, \u0447\u0442\u043e \u043d\u0435 \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u0433\u043e\u0432\u043e\u0440\u0438\u0442\u044c \u043e \u043a\u0430\u043a\u043e\u043c-\u0442\u043e \u0443\u043b\u0443\u0447\u0448\u0435\u043d\u0438\u0438 \u0440\u0430\u0431\u043e\u0442\u044b \u043c\u043e\u0434\u0435\u043b\u0438.<\/p>\n<h3>\u0412\u044b\u0432\u043e\u0434\u044b<\/h3>\n<p>\u041f\u043e\u043b\u0443\u0447\u0435\u043d\u043d\u044b\u0439 \u043e\u043f\u044b\u0442 \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u0435\u043d \u0434\u043b\u044f \u043c\u0435\u043d\u044f \u0438, \u043d\u0430\u0434\u0435\u044e\u0441\u044c, \u043d\u0435 \u0442\u043e\u043b\u044c\u043a\u043e \u0434\u043b\u044f \u043c\u0435\u043d\u044f. \u0427\u0442\u043e\u0431\u044b \u0432\u043e\u0441\u043f\u0440\u043e\u0438\u0437\u0432\u0435\u0441\u0442\u0438 \u0432 \u043b\u044e\u0431\u0438\u043c\u043e\u043c Excel-\u0435 \u0442\u043e, \u0447\u0442\u043e \u0434\u0435\u043b\u0430\u0435\u0442 \u043c\u043e\u0434\u0435\u043b\u044c, \u043c\u043d\u0435 \u043f\u043e\u043d\u0430\u0434\u043e\u0431\u0438\u043b\u043e\u0441\u044c \u0431\u044b \u043a\u0440\u0430\u0442\u043d\u043e \u0431\u043e\u043b\u044c\u0448\u0435 \u0432\u0440\u0435\u043c\u0435\u043d\u0438.<\/p>\n<p>\u0421\u0438\u0441\u0442\u0435\u043c\u0430 \u0438\u0433\u0440\u044b \u043f\u043e \u0441\u043a\u043e\u043b\u044c\u0437\u044f\u0449\u0435\u0439 \u0441\u0440\u0435\u0434\u043d\u0435\u0439 \u043f\u043e\u043a\u0430\u0437\u0430\u043b\u0430 \u0430\u043a\u043a\u0443\u0440\u0430\u0442\u043d\u043e\u0441\u0442\u044c 50,9% \u0438 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u0442\u043e\u0440\u0433\u043e\u0432\u043b\u0438 -24,01%.<\/p>\n<p>\u041c\u043e\u0434\u0435\u043b\u044c \u0443\u043b\u0443\u0447\u0448\u0438\u0442\u044c \u043d\u0435 \u0443\u0434\u0430\u043b\u043e\u0441\u044c, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u0431\u0443\u0434\u0443 \u0440\u0430\u0441\u0441\u043c\u0430\u0442\u0440\u0438\u0432\u0430\u0442\u044c \u043f\u0435\u0440\u0432\u044b\u0435 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u044b: \u0430\u043a\u043a\u0443\u0440\u0430\u0442\u043d\u043e\u0441\u0442\u044c 51,8%, \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u0442\u043e\u0440\u0433\u043e\u0432\u043b\u0438 -52,2%.<\/p>\n<p>\u041f\u0440\u0438 \u0442\u043e\u043c, \u0447\u0442\u043e \u0441\u0443\u043c\u043c\u0430\u0440\u043d\u0430\u044f \u043a\u043e\u043c\u0438\u0441\u0441\u0438\u044f \u0431\u0440\u043e\u043a\u0435\u0440\u0430 \u0441\u043e\u0441\u0442\u0430\u0432\u0438\u043b\u0430 95,52%, \u043e\u0431\u0435 \u0441\u0438\u0441\u0442\u0435\u043c\u044b \u043f\u043e\u043a\u0430\u0437\u0430\u043b\u0438 \u043f\u043e\u043b\u043e\u0436\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0439 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u0442\u043e\u0440\u0433\u043e\u0432\u043b\u0438, \u0435\u0441\u043b\u0438 \u043a\u043e\u043c\u0438\u0441\u0441\u0438\u044e \u0431\u0440\u043e\u043a\u0435\u0440\u0430 \u043d\u0435 \u0443\u0447\u0438\u0442\u044b\u0432\u0430\u0442\u044c. \u0422\u043e \u0435\u0441\u0442\u044c \u0432 \u0432\u0430\u043a\u0443\u0443\u043c\u0435 \u043e\u0431\u0435 \u0441\u0438\u0441\u0442\u0435\u043c\u044b \u043f\u043e\u043b\u0435\u0437\u043d\u044b \u0438 \u043c\u043e\u0433\u0443\u0442 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c\u0441\u044f \u0434\u043b\u044f \u0440\u0435\u0430\u043b\u044c\u043d\u043e\u0439 \u0442\u043e\u0440\u0433\u043e\u0432\u043b\u0438 \u0432 \u0441\u043e\u0441\u0442\u0430\u0432\u0435 \u043a\u0430\u043a\u043e\u0439-\u0442\u043e \u0441\u0442\u0440\u0430\u0442\u0435\u0433\u0438\u0438. \u042d\u0442\u043e \u0432 \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u043e\u0439 \u0441\u0442\u0435\u043f\u0435\u043d\u0438 \u043c\u0435\u043d\u044f \u0443\u0434\u0438\u0432\u0438\u043b\u043e.<\/p>\n<p>\u0412 \u0434\u0430\u043b\u044c\u043d\u0435\u0439\u0448\u0435\u043c \u044f \u043d\u0435 \u043e\u0441\u0442\u0430\u0432\u043b\u044e \u043f\u043e\u043f\u044b\u0442\u043e\u043a \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0438 \u0440\u0430\u0437\u043b\u0438\u0447\u043d\u044b\u0445 \u043c\u043e\u0434\u0435\u043b\u0435\u0439, \u0435\u0441\u043b\u0438 \u043d\u0430\u0439\u0434\u0443 \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u0443\u044e \u0442\u0435\u043c\u0443, \u043d\u0430\u043f\u0438\u0448\u0443 \u0435\u0449\u0435. \u0411\u0443\u0434\u0443 \u043f\u0440\u043e\u0434\u043e\u043b\u0436\u0430\u0442\u044c \u043d\u0430\u0431\u043b\u044e\u0434\u0435\u043d\u0438\u0435, \u043a\u0430\u043a \u0433\u043e\u0432\u043e\u0440\u0438\u0442\u0441\u044f.<\/p>\n<p>\u041f\u0421 \u0418\u0441\u0445\u043e\u0434\u043d\u044b\u0439 \u0444\u0430\u0439\u043b .csv \u0432\u044b\u043b\u043e\u0436\u0438\u043b \u043d\u0430 <a href=\"https:\/\/disk.yandex.ru\/d\/0EalbhrgapfhyA\" rel=\"noopener noreferrer nofollow\"><strong>\u044f\u043d\u0434\u0435\u043a\u0441-\u0434\u0438\u0441\u043a, \u0435\u0441\u043b\u0438 \u043a\u0442\u043e-\u0442\u043e \u0437\u0430\u0445\u043e\u0447\u0435\u0442 \u043f\u043e\u043a\u0440\u0443\u0442\u0438\u0442\u044c \u0435\u0433\u043e \u0441\u0430\u043c\u043e\u0441\u0442\u043e\u044f\u0442\u0435\u043b\u044c\u043d\u043e, welcome.<\/strong><\/a><\/p>\n<\/p>\n<\/div>\n<\/div>\n<\/div>\n<div class=\"v-portal\" style=\"display:none;\"><\/div>\n<\/div>\n<p> <!----> <!----><br \/> \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\/676878\/\"> https:\/\/habr.com\/ru\/post\/676878\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<div><\/div>\n<div id=\"post-content-body\">\n<div>\n<div class=\"article-formatted-body article-formatted-body article-formatted-body_version-2\">\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<p>\u041f\u0440\u0438\u0432\u0435\u0442!<\/p>\n<p>\u042f \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u0434\u0430\u0432\u043d\u043e \u0432 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u0445\u043e\u0431\u0431\u0438 \u0437\u0430\u043d\u0438\u043c\u0430\u044e\u0441\u044c \u0430\u043d\u0430\u043b\u0438\u0437\u043e\u043c \u043e\u0442\u043a\u0440\u044b\u0442\u044b\u0445 \u0434\u0430\u043d\u043d\u044b\u0445 \u0432 \u0438\u0433\u0440\u0430\u0445 \u043d\u0430 \u0434\u0435\u043d\u044c\u0433\u0438 (\u0441\u0442\u0430\u0432\u043a\u0438 \u043d\u0430 \u0441\u043f\u043e\u0440\u0442, \u0431\u0438\u0440\u0436\u0435\u0432\u044b\u0435 \u043a\u043e\u0442\u0438\u0440\u043e\u0432\u043a\u0438 \u0438 \u0442\u043f). \u0412 \u043e\u0441\u043d\u043e\u0432\u043d\u043e\u043c \u0440\u0430\u0431\u043e\u0442\u0430\u044e \u0440\u0443\u043a\u0430\u043c\u0438 \u0432 \u044d\u043a\u0441\u0435\u043b\u0435, \u043d\u043e \u0442\u0430\u043a\u0436\u0435 \u0441\u0442\u0430\u0440\u0430\u044e\u0441\u044c \u0431\u044b\u0442\u044c \u0432 \u043a\u0443\u0440\u0441\u0435 \u0442\u043e\u0433\u043e, \u0447\u0442\u043e \u0434\u0435\u043b\u0430\u044e\u0442 \u043c\u0430\u0448\u0438\u043d\u044b. \u0414\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u043f\u0440\u043e\u0448\u0435\u043b \u043a\u0443\u0440\u0441\u044b Kaggle \u043e\u0442 Google. \u0412 \u044d\u0442\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0435 \u044f \u043f\u043e\u043f\u0440\u043e\u0431\u0443\u044e \u0441\u0440\u0430\u0432\u043d\u0438\u0442\u044c \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0438\u0432\u043d\u043e\u0441\u0442\u044c \u043f\u0440\u0435\u0434\u0441\u043a\u0430\u0437\u0430\u043d\u0438\u0439 \u0434\u043d\u0435\u0432\u043d\u043e\u0433\u043e \u0434\u0432\u0438\u0436\u0435\u043d\u0438\u044f \u0446\u0435\u043d\u044b \u0430\u043a\u0446\u0438\u0438 \u043e\u0442 \u0434\u0432\u0443\u0445 \u043f\u0440\u0438\u043c\u0438\u0442\u0438\u0432\u043d\u044b\u0445 \u0441\u0438\u0441\u0442\u0435\u043c \u0442\u043e\u0440\u0433\u043e\u0432\u043b\u0438: <\/p>\n<p>1. \u043f\u0440\u0438\u043c\u0438\u0442\u0438\u0432\u043d\u043e\u0433\u043e \u0442\u0440\u0435\u0439\u0434\u0435\u0440\u0430-\u0447\u0435\u043b\u043e\u0432\u0435\u043a\u0430, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043d\u0430 \u0432\u0432\u043e\u0434\u043d\u043e\u043c \u043a\u0443\u0440\u0441\u0435 \u043f\u043e \u0442\u0440\u0435\u0439\u0434\u0438\u043d\u0433\u0443 \u0443\u0437\u043d\u0430\u043b \u043f\u0440\u043e \u0441\u043a\u043e\u043b\u044c\u0437\u044f\u0449\u0443\u044e \u0441\u0440\u0435\u0434\u043d\u044e\u044e,<\/p>\n<p>\u00a0\u0438<\/p>\n<p>2. \u043f\u0440\u0438\u043c\u0438\u0442\u0438\u0432\u043d\u043e\u0439 \u043c\u043e\u0434\u0435\u043b\u0438, \u043e\u0431\u0443\u0447\u0435\u043d\u043d\u043e\u0439 \u043f\u043e \u043c\u0435\u0442\u043e\u0434\u0443 \u0431\u043b\u0438\u0436\u0430\u0439\u0448\u0438\u0445 \u0441\u043e\u0441\u0435\u0434\u0435\u0439 (\u041a\u043b\u0430\u0441\u0441 KNeighborsClassifier \u0432 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0435 Python Scikit-learn).<\/p>\n<p>\u041e\u0446\u0435\u043d\u0438\u0432\u0430\u0442\u044c\u0441\u044f \u043f\u0440\u0435\u0434\u0441\u043a\u0430\u0437\u0430\u043d\u0438\u044f \u043e\u0431\u0435\u0438\u0445 \u0441\u0438\u0441\u0442\u0435\u043c \u0431\u0443\u0434\u0443\u0442 \u043f\u043e \u0434\u0432\u0443\u043c \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u0430\u043c:<\/p>\n<ol>\n<li>\n<p>\u0420\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u0442\u043e\u0440\u0433\u043e\u0432\u043b\u0438 \u0430\u043a\u0446\u0438\u0435\u0439 \u0432 \u043f\u0440\u043e\u0446\u0435\u043d\u0442\u0430\u0445.<\/p>\n<\/li>\n<li>\n<p>\u041f\u0440\u043e\u0446\u0435\u043d\u0442 \u0432\u0435\u0440\u043d\u044b\u0445 \u043f\u0440\u0435\u0434\u0441\u043a\u0430\u0437\u0430\u043d\u0438\u0439.<\/p>\n<\/li>\n<\/ol>\n<p>\u041c\u043d\u0435 \u043f\u043e\u043a\u0430\u0437\u0430\u043b\u043e\u0441\u044c, \u0447\u0442\u043e \u0431\u0443\u0434\u0443\u0442 \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u0435\u0435 \u043f\u0438\u0441\u0430\u0442\u044c \u0434\u0430\u043d\u043d\u0443\u044e \u0441\u0442\u0430\u0442\u044c\u044e \u043f\u043e\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u043e, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u043d\u0430 \u043c\u043e\u043c\u0435\u043d\u0442 \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u0438\u044f \u044d\u0442\u0438\u0445 \u0441\u043b\u043e\u0432 \u044f \u043d\u0435 \u0437\u043d\u0430\u044e \u0438\u0442\u043e\u0433\u043e\u0432\u044b\u0445 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u043e\u0432. <\/p>\n<h3>\u041a\u0440\u0430\u0442\u043a\u043e \u043e \u0441\u043a\u043e\u043b\u044c\u0437\u044f\u0449\u0435\u0439 \u0441\u0440\u0435\u0434\u043d\u0435\u0439<\/h3>\n<p>\u0421\u043a\u043e\u043b\u044c\u0437\u044f\u0449\u0430\u044f \u0441\u0440\u0435\u0434\u043d\u044f\u044f (moving average) \u0432 \u0440\u0430\u0437\u043b\u0438\u0447\u043d\u044b\u0445 \u0440\u0443\u043a\u043e\u0432\u043e\u0434\u0441\u0442\u0432\u0430\u0445 \u043f\u043e \u0442\u0440\u0435\u0439\u0434\u0438\u043d\u0433\u0443 \u0438 \u0432 \u0431\u0430\u0437\u043e\u0432\u044b\u0445 \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0430\u0445 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c \u0434\u043b\u044f \u0430\u043d\u0430\u043b\u0438\u0437\u0430 \u0438\u043c\u0435\u0435\u0442 \u043f\u0435\u0440\u0438\u043e\u0434 <em>[\u0447\u0438\u0441\u043b\u043e \u0424\u0438\u0431\u043e\u043d\u0430\u0447\u0447\u0438 >=8 + 1]<\/em>, \u0442.\u0435. 9, 14, 22 \u0438 \u0442.\u043f. \u042f \u043d\u0430 \u0442\u0435\u043a\u0443\u0449\u0435\u0439 \u0441\u0442\u0430\u0434\u0438\u0438 \u0440\u0430\u0437\u0432\u0438\u0442\u0438\u044f \u043d\u0435 \u043c\u043e\u0433\u0443 \u043e\u0431\u044a\u044f\u0441\u043d\u0438\u0442\u044c, \u043f\u043e\u0447\u0435\u043c\u0443 \u0438\u043c\u0435\u043d\u043d\u043e \u0442\u0430\u043a\u0438\u0435 \u043f\u0435\u0440\u0438\u043e\u0434\u044b, \u0447\u0435\u0441\u0442\u043d\u043e \u043f\u043e\u0442\u0440\u0430\u0442\u0438\u043b 5 \u043c\u0438\u043d\u0443\u0442, \u0447\u0442\u043e\u0431\u044b \u043d\u0430\u0439\u0442\u0438 \u043e\u0442\u0432\u0435\u0442 \u0432 \u0418\u043d\u0442\u0435\u0440\u043d\u0435\u0442\u0435, \u043d\u043e \u043d\u0435 \u0441\u043c\u043e\u0433. <\/p>\n<p>\u041f\u0435\u0440\u0438\u043e\u0434 \u2013 \u044d\u0442\u043e \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u0443\u044e\u0449\u0438\u0439 \u043d\u0430\u0441 \u0432\u0440\u0435\u043c\u0435\u043d\u043d\u043e\u0439 \u0434\u0438\u0430\u043f\u0430\u0437\u043e\u043d (\u043c\u0435\u0441\u044f\u0446, \u043d\u0435\u0434\u0435\u043b\u044f, \u0434\u0435\u043d\u044c, \u0447\u0430\u0441, 15 \u043c\u0438\u043d\u0443\u0442, 5 \u043c\u0438\u043d\u0443\u0442, 1 \u043c\u0438\u043d\u0443\u0442\u0430). \u0414\u043b\u044f \u043f\u043e\u0441\u0442\u0440\u043e\u0435\u043d\u0438\u044f \u0441\u043a\u043e\u043b\u044c\u0437\u044f\u0449\u0435\u0439 \u0441\u0440\u0435\u0434\u043d\u0435\u0439 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e\u0442 \u0440\u0430\u0437\u043b\u0438\u0447\u043d\u044b\u0435 \u0442\u0438\u043f\u044b \u0446\u0435\u043d \u0437\u0430 \u043f\u0440\u0435\u0434\u044b\u0434\u0443\u0449\u0438\u0435 \u043f\u0435\u0440\u0438\u043e\u0434\u044b: \u043f\u0440\u043e\u0441\u0442\u043e Close (\u0446\u0435\u043d\u0430  \u0430\u043a\u0446\u0438\u0438 \u0432 \u043a\u043e\u043d\u0446\u0435 \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u0443\u044e\u0449\u0435\u0433\u043e \u043d\u0430\u0441 \u043f\u0435\u0440\u0438\u043e\u0434\u0430) \u0438\u043b\u0438 \u0440\u0430\u0437\u043b\u0438\u0447\u043d\u044b\u0435 \u043a\u043e\u043c\u0431\u0438\u043d\u0430\u0446\u0438\u0438 Open (\u0446\u0435\u043d\u0430 \u0432 \u043d\u0430\u0447\u0430\u043b\u0435 \u043f\u0435\u0440\u0438\u043e\u0434\u0430), Close, Hi (\u043c\u0430\u043a\u0441\u0438\u043c\u0430\u043b\u044c\u043d\u0430\u044f \u0446\u0435\u043d\u0430), Low (\u043c\u0438\u043d\u0438\u043c\u0430\u043b\u044c\u043d\u0430\u044f \u0446\u0435\u043d\u0430) \u0442\u0438\u043f\u0430 <em>[&#171;Open + Hi + Low + 2*Close&#187; \/ 5]<\/em>. \/<\/p>\n<p>\u041f\u043e \u0432\u0438\u0434\u0430\u043c \u0441\u043a\u043e\u043b\u044c\u0437\u044f\u0449\u0438\u0435 \u0441\u0440\u0435\u0434\u043d\u0438\u0435 \u0434\u0435\u043b\u044f\u0442\u0441\u044f \u043d\u0430 \u043f\u0440\u043e\u0441\u0442\u044b\u0435 (simple moving average, \u0434\u0430\u043b\u0435\u0435 &#8212; SMA), \u0438 \u044d\u043a\u0441\u043f\u043e\u043d\u0435\u043d\u0446\u0438\u0430\u043b\u044c\u043d\u044b\u0435 (exponential moving average, \u0434\u0430\u043b\u0435\u0435 EMA). SMA \u0440\u0430\u0441\u0441\u0447\u0438\u0442\u044b\u0432\u0430\u044e\u0442\u0441\u044f \u043f\u043e \u043c\u0435\u0442\u043e\u0434\u0443 \u0441\u0440\u0435\u0434\u043d\u0435\u0433\u043e \u0430\u0440\u0438\u0444\u043c\u0435\u0442\u0438\u0447\u0435\u0441\u043a\u043e\u0433\u043e, \u0443 EMA \u0447\u0435\u043c \u043d\u043e\u0432\u0435\u0435 \u0434\u0430\u043d\u043d\u044b\u0435, \u0442\u0435\u043c \u0431\u043e\u043b\u044c\u0448\u0438\u0439 \u0432\u0435\u0441 \u0438\u043c \u043f\u0440\u0438\u0441\u0432\u0430\u0438\u0432\u0430\u0435\u0442\u0441\u044f.<\/p>\n<p>\u0415\u0441\u043b\u0438 \u0446\u0435\u043d\u0430 \u043d\u0430\u0434 \u0441\u043a\u043e\u043b\u044c\u0437\u044f\u0449\u0435\u0439 \u0441\u0440\u0435\u0434\u043d\u0435\u0439, \u0442\u043e \u0441\u0447\u0438\u0442\u0430\u0435\u0442\u0441\u044f, \u0447\u0442\u043e \u0441\u043a\u043e\u0440\u0435\u0435 \u043e\u043d\u0430 \u0431\u0443\u0434\u0435\u0442 \u0440\u0430\u0441\u0442\u0438 \u0434\u0430\u043b\u044c\u0448\u0435, \u0435\u0441\u043b\u0438 \u043f\u043e\u0434 \u0441\u043a\u043e\u043b\u044c\u0437\u044f\u0449\u0435\u0439 \u0441\u0440\u0435\u0434\u043d\u0435\u0439 &#8212; \u043f\u0440\u043e\u0434\u043e\u043b\u0436\u0430\u0442\u044c \u043f\u0430\u0434\u0430\u0442\u044c. <\/p>\n<p>\u042f \u043f\u043b\u0430\u043d\u0438\u0440\u0443\u044e \u0440\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0435\u0442\u044c \u043c\u0430\u043a\u0441\u0438\u043c\u0430\u043b\u044c\u043d\u043e \u043f\u0440\u0438\u043c\u0438\u0442\u0438\u0432\u043d\u0443\u044e \u0441\u043a\u043e\u043b\u044c\u0437\u044f\u0449\u0443\u044e \u0441\u0440\u0435\u0434\u043d\u044e\u044e, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u0442\u0440\u0435\u0439\u0434\u0435\u0440-\u0447\u0435\u043b\u043e\u0432\u0435\u043a \u0431\u0443\u0434\u0435\u0442 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043f\u0440\u043e\u0441\u0442\u0443\u044e \u0441\u043a\u043e\u043b\u044c\u0437\u044f\u0449\u0443\u044e \u0441\u0440\u0435\u0434\u043d\u044e\u044e SMA, \u043f\u043e\u0441\u0442\u0440\u043e\u0435\u043d\u043d\u0443\u044e \u043f\u043e \u0446\u0435\u043d\u0430\u043c Close \u0437\u0430 \u043f\u0435\u0440\u0438\u043e\u0434 9 \u0434\u043d\u0435\u0439.<\/p>\n<h3>\u041a\u0440\u0430\u0442\u043a\u043e \u043e \u043c\u0435\u0442\u043e\u0434\u0435 \u0431\u043b\u0438\u0436\u0430\u0439\u0448\u0438\u0445 \u0441\u043e\u0441\u0435\u0434\u0435\u0439<\/h3>\n<p>\u041c\u0435\u0442\u043e\u0434 \u0431\u043b\u0438\u0436\u0430\u0439\u0448\u0438\u0445 \u0441\u043e\u0441\u0435\u0434\u0435\u0439 &#8212; \u044d\u0442\u043e \u043e\u0434\u0438\u043d \u0438\u0437 \u0441\u0430\u043c\u044b\u0445 \u043f\u0440\u043e\u0441\u0442\u044b\u0445 \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u043e\u0432 \u043a\u043b\u0430\u0441\u0441\u0438\u0444\u0438\u043a\u0430\u0446\u0438\u0438, \u043d\u043e \u0432 \u0442\u043e \u0436\u0435 \u0432\u0440\u0435\u043c\u044f \u043e\u0434\u0438\u043d \u0438\u0437 \u0441\u0430\u043c\u044b\u0445 \u043b\u043e\u0433\u0438\u0447\u0435\u0441\u043a\u0438 \u043e\u0431\u044a\u044f\u0441\u043d\u0438\u043c\u044b\u0445 \u0438, \u0441 \u043c\u043e\u0435\u0439 \u0442\u043e\u0447\u043a\u0438 \u0437\u0440\u0435\u043d\u0438\u044f, \u0441\u0438\u043b\u044c\u043d\u044b\u0445 \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u043e\u0432. \u0412 \u043e\u0441\u043d\u043e\u0432\u043d\u043e\u043c \u043e\u043d \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u0434\u043b\u044f \u0440\u0435\u0448\u0435\u043d\u0438\u044f \u0437\u0430\u0434\u0430\u0447 \u043a\u043b\u0430\u0441\u0441\u0438\u0444\u0438\u043a\u0430\u0446\u0438\u0438. \u041c\u0435\u0442\u043e\u0434 \u043d\u0430\u0445\u043e\u0434\u0438\u0442 \u0432 \u0442\u0435\u0441\u0442\u043e\u0432\u043e\u0439 \u0432\u044b\u0431\u043e\u0440\u043a\u0435, \u0432 \u043a\u043e\u0442\u043e\u0440\u043e\u0439 \u0434\u043b\u044f \u043e\u0431\u044a\u0435\u043a\u0442\u043e\u0432 \u0443\u0436\u0435 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u044b \u043a\u043b\u0430\u0441\u0441\u044b, \u043e\u0431\u044a\u0435\u043a\u0442\u044b, \u0440\u0430\u0441\u0441\u0442\u043e\u044f\u043d\u0438\u0435 \u0434\u043e \u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u043c\u0438\u043d\u0438\u043c\u0430\u043b\u044c\u043d\u043e (\u0442\u043e \u0435\u0441\u0442\u044c \u043d\u0430\u0445\u043e\u0434\u0438\u0442 \u043c\u0430\u043a\u0441\u0438\u043c\u0430\u043b\u044c\u043d\u043e \u043f\u043e\u0445\u043e\u0436\u0438\u0435 \u043e\u0431\u044a\u0435\u043a\u0442\u044b), \u0434\u0430\u043b\u0435\u0435 \u044d\u0442\u0438 \u043e\u0431\u044a\u0435\u043a\u0442\u044b \u043d\u0430\u0437\u044b\u0432\u0430\u044e\u0442\u0441\u044f &#171;\u0441\u043e\u0441\u0435\u0434\u0438&#187;. \u0417\u0430\u0442\u0435\u043c \u043c\u0435\u0442\u043e\u0434 \u043f\u0440\u0438\u0441\u0432\u0430\u0438\u0432\u0430\u0435\u0442 \u043a\u043b\u0430\u0441\u0441\u0438\u0444\u0438\u0446\u0438\u0440\u0443\u0435\u043c\u043e\u043c\u0443 \u043e\u0431\u044a\u0435\u043a\u0442\u0443 \u043a\u043b\u0430\u0441\u0441, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0447\u0430\u0449\u0435 \u0432\u0441\u0442\u0440\u0435\u0447\u0430\u0435\u0442\u0441\u044f \u0443 \u043e\u0442\u043e\u0431\u0440\u0430\u043d\u043d\u044b\u0445 \u0441\u043e\u0441\u0435\u0434\u0435\u0439. <\/p>\n<p>\u041c\u044b\u0448\u043b\u0435\u043d\u0438\u0435 \u0447\u0435\u043b\u043e\u0432\u0435\u043a\u0430 \u0432 \u043f\u043e\u0432\u0442\u043e\u0440\u044f\u044e\u0449\u0438\u0445\u0441\u044f \u0441\u0438\u0442\u0443\u0430\u0446\u0438\u044f\u0445 \u0430\u0431\u0441\u043e\u043b\u044e\u0442\u043d\u043e  \u0442\u0430\u043a\u043e\u0435 \u0436\u0435: \u044f \u0438\u0434\u0443 \u0431\u0435\u0437 \u0433\u043e\u043b\u043e\u0432\u043d\u043e\u0433\u043e \u0443\u0431\u043e\u0440\u0430 \u2013 \u043f\u043e\u0448\u0435\u043b \u0434\u043e\u0436\u0434\u044c \u2013 \u0432 \u043f\u0440\u043e\u0448\u043b\u043e\u043c \u0431\u044b\u043b\u043e 4 \u043e\u043f\u044b\u0442\u0430, \u043a\u043e\u0433\u0434\u0430 \u044f \u0448\u0435\u043b \u0431\u0435\u0437 \u0433\u043e\u043b\u043e\u0432\u043d\u043e\u0433\u043e \u0443\u0431\u043e\u0440\u0430 \u0438 \u043f\u043e\u0448\u0435\u043b \u0434\u043e\u0436\u0434\u044c, \u0438\u0437 \u043d\u0438\u0445 \u044f 3 \u0440\u0430\u0437\u0430 \u043f\u0440\u043e\u043c\u043e\u043a (\u043d\u0435\u0433\u0430\u0442\u0438\u0432\u043d\u044b\u0439 \u043e\u043f\u044b\u0442) \u0438 1 \u0440\u0430\u0437 \u0434\u043e\u0436\u0434\u044c \u0431\u044b\u0441\u0442\u0440\u043e \u043a\u043e\u043d\u0447\u0438\u043b\u0441\u044f. \u0412\u044b\u0432\u043e\u0434: \u0434\u043e\u0436\u0434\u044c \u0432\u0435\u0434\u0435\u0442 \u043a \u043d\u0435\u0433\u0430\u0442\u0438\u0432\u043d\u044b\u043c \u043f\u043e\u0441\u043b\u0435\u0434\u0441\u0442\u0432\u0438\u044f\u043c. <\/p>\n<h3>\u041f\u043e\u0434\u0433\u043e\u0442\u043e\u0432\u043a\u0430 \u0438\u0441\u0445\u043e\u0434\u043d\u044b\u0445 \u0434\u0430\u043d\u043d\u044b\u0445 \u0447\u0435\u043b\u043e\u0432\u0435\u043a\u0430-\u0442\u0440\u0435\u0439\u0434\u0435\u0440\u0430<\/h3>\n<p>\u041d\u0430 \u0441\u0430\u0439\u0442\u0435 \u043e\u0434\u043d\u043e\u0433\u043e \u0440\u043e\u0441\u0441\u0438\u0439\u0441\u043a\u043e\u0433\u043e \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u043e\u043d\u043d\u043e\u0433\u043e \u0430\u0433\u0435\u043d\u0442\u0441\u0442\u0432\u0430 \u043c\u043e\u0436\u043d\u043e \u0431\u044b\u0441\u0442\u0440\u043e \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u0438\u0441\u0442\u043e\u0440\u0438\u044e \u043a\u043e\u0442\u0438\u0440\u043e\u0432\u043e\u043a \u043b\u044e\u0431\u044b\u0445 \u0430\u043a\u0446\u0438\u0439 \u0432 \u0444\u043e\u0440\u043c\u0430\u0442\u0435 .csv. \u0424\u0430\u0439\u043b \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u0442 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0435 \u0441\u0442\u043e\u043b\u0431\u0446\u044b: &lt;TICKER> &#8212; \u043d\u0430\u0437\u0432\u0430\u043d\u0438\u0435 \u0430\u043a\u0446\u0438\u0438, &lt;PER> &#8212; \u043f\u0435\u0440\u0438\u043e\u0434 , &lt;DATE> &#8212; \u0434\u0430\u0442\u0430, &lt;TIME> &#8212; \u0432\u0440\u0435\u043c\u044f, &lt;OPEN> &#8212; \u0446\u0435\u043d\u0430 \u043e\u0442\u043a\u0440\u044b\u0442\u0438\u044f, &lt;HIGH> &#8212; \u043c\u0430\u043a\u0441\u0438\u043c\u0430\u043b\u044c\u043d\u0430\u044f \u0446\u0435\u043d\u0430, &lt;LOW> &#8212; \u043c\u0438\u043d\u0438\u043c\u0430\u043b\u044c\u043d\u0430\u044f \u0446\u0435\u043d\u0430, &lt;CLOSE> &#8212; \u0446\u0435\u043d\u0430 \u0437\u0430\u043a\u0440\u044b\u0442\u0438\u044f, &lt;AMOUNT> &#8212; \u0441\u0443\u043c\u043c\u0430 \u0442\u043e\u0440\u0433\u043e\u0432, &lt;VOL> &#8212; \u043e\u0431\u044a\u0435\u043c \u0442\u043e\u0440\u0433\u043e\u0432. \u0414\u043b\u044f \u043f\u0440\u0438\u043c\u0435\u0440\u0430, \u043d\u0438\u0436\u0435 \u0441\u0442\u0440\u043e\u043a\u0430 \u0444\u0430\u0439\u043b\u0430 .csv \u0434\u043b\u044f \u0434\u043d\u0435\u0432\u043d\u044b\u0445 \u043a\u043e\u0442\u0438\u0440\u043e\u0432\u043e\u043a \u0430\u043a\u0446\u0438\u0439 \u0413\u0430\u0437\u043f\u0440\u043e\u043c\u0430 \u0437\u0430 \u0434\u0430\u0442\u0443 05.01.2015\u0433.:<\/p>\n<p><em>\u00a0[\u0413\u0410\u0417\u041f\u0420\u041e\u041c \u0430\u043e,D,20150105,000000,129.5,133.95,129.15,133.95,18223370,2410730975.5]<\/em><\/p>\n<p>\u0410\u043a\u0446\u0438\u0438 \u0413\u0430\u0437\u043f\u0440\u043e\u043c\u0430 (\u0442\u0438\u043a\u0435\u0440 GAZP) \u2013 \u043d\u0430\u0438\u0431\u043e\u043b\u0435\u0435 \u043b\u0438\u043a\u0432\u0438\u0434\u043d\u044b\u0435 \u0430\u043a\u0446\u0438\u0438 \u0438\u0437 \u0442\u043e\u0440\u0433\u0443\u0435\u043c\u044b\u0445 \u043d\u0430 \u041c\u043e\u0441\u043a\u043e\u0432\u0441\u043a\u043e\u0439 \u0431\u0438\u0440\u0436\u0435. \u0414\u043e\u043b\u0433\u043e\u0435 \u0432\u0440\u0435\u043c\u044f \u044d\u0442\u0438 \u0430\u043a\u0446\u0438\u0438 \u0438\u043c\u0435\u043b\u0438 \u043d\u0430\u0438\u0431\u043e\u043b\u044c\u0448\u0438\u0439 \u0432\u0435\u0441 \u0432 \u0438\u043d\u0434\u0435\u043a\u0441\u0435 iMOEX (\u0442\u043e\u043f-40 \u0440\u043e\u0441\u0441\u0438\u0439\u0441\u043a\u0438\u0445 \u0430\u043a\u0446\u0438\u0439). \u041f\u043e\u044d\u0442\u043e\u043c\u0443 \u043e\u0431\u0435 \u0441\u0438\u0441\u0442\u0435\u043c\u044b \u0431\u0443\u0434\u0443\u0442 \u0434\u0435\u043b\u0430\u0442\u044c \u043f\u0440\u0435\u0434\u0441\u043a\u0430\u0437\u0430\u043d\u0438\u044f \u0446\u0435\u043d\u044b \u0430\u043a\u0446\u0438\u0438 \u0413\u0430\u0437\u043f\u0440\u043e\u043c\u0430 \u0432 \u043f\u0435\u0440\u0438\u043e\u0434 \u0441 03.01.2017\u0433. \u043f\u043e 30.12.2021\u0433. <\/p>\n<p>\u0414\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u0434\u0430\u0442\u0430-\u0444\u0440\u0435\u0439\u043c \u0442\u0440\u0435\u0439\u0434\u0435\u0440\u0430-\u0447\u0435\u043b\u043e\u0432\u0435\u043a\u0430 \u0431\u0443\u0434\u0435\u0442 \u0441\u043e\u0434\u0435\u0440\u0436\u0430\u0442\u044c \u043a\u043e\u0442\u0438\u0440\u043e\u0432\u043a\u0438 \u0432 \u043f\u0435\u0440\u0438\u043e\u0434 \u0441 20.12.2016\u0433., \u0447\u0442\u043e\u0431\u044b \u0438\u043c\u0435\u0442\u044c \u0434\u0430\u043d\u043d\u044b\u0435\u00a0 \u0434\u043b\u044f \u043f\u043e\u0441\u0442\u0440\u043e\u0435\u043d\u0438\u044f \u0441\u043a\u043e\u043b\u044c\u0437\u044f\u0449\u0435\u0439 \u0441\u0440\u0435\u0434\u043d\u0435\u0439 \u043d\u0430 03.01.2017\u0433. \u041c\u043e\u0434\u0435\u043b\u044c \u0436\u0435 \u0431\u0443\u0434\u0435\u0442 \u043e\u0431\u0443\u0447\u0430\u0442\u044c\u0441\u044f \u0434\u043e 30.12.2016\u0433., \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u0434\u0430\u0442\u0430-\u0444\u0440\u0435\u0439\u043c \u043c\u043e\u0434\u0435\u043b\u0438 \u0431\u0443\u0434\u0435\u0442 \u0441\u043e\u0434\u0435\u0440\u0436\u0430\u0442\u044c \u043a\u043e\u0442\u0438\u0440\u043e\u0432\u043a\u0438 \u0432 \u043f\u0435\u0440\u0438\u043e\u0434 \u0441 19.01.2015\u0433 \u043f\u043e 30.12.2021\u0433.<\/p>\n<p>\u0414\u0430\u0442\u0430-\u0444\u0440\u0435\u0439\u043c \u0442\u0440\u0435\u0439\u0434\u0435\u0440\u0430-\u0447\u0435\u043b\u043e\u0432\u0435\u043a\u0430 (human_df) \u0431\u0443\u0434\u0435\u0442 \u0441\u043e\u0434\u0435\u0440\u0436\u0430\u0442\u044c \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0435 \u0441\u0442\u043e\u043b\u0431\u0446\u044b:<\/p>\n<p>&lt;DATE> &#8212; \u0434\u0430\u0442\u0430 <\/p>\n<p>&lt;OPEN> &#8212; \u0446\u0435\u043d\u0430 \u043e\u0442\u043a\u0440\u044b\u0442\u0438\u044f<\/p>\n<p>&lt;CLOSE> &#8212; \u0446\u0435\u043d\u0430 \u0437\u0430\u043a\u0440\u044b\u0442\u0438\u044f<\/p>\n<p>&lt;SMA9> &#8212; \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u0441\u043a\u043e\u043b\u044c\u0437\u044f\u0449\u0435\u0439 \u0441\u0440\u0435\u0434\u043d\u0435\u0439 SMA9<\/p>\n<p>&lt;RESULT> &#8212; \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u0434\u043d\u044f \u043f\u043e \u0444\u043e\u0440\u043c\u0443\u043b\u0435 <em>[(&lt;CLOSE> &#8212; &lt;OPEN>) \/ &lt;OPEN>]<\/em><\/p>\n<p>\u0421\u043e\u0437\u0434\u0430\u044e \u0434\u0430\u0442\u0430-\u0444\u0440\u0435\u0439\u043c \u0442\u0440\u0435\u0439\u0434\u0435\u0440\u0430-\u0447\u0435\u043b\u043e\u0432\u0435\u043a\u0430 (human_df):<\/p>\n<pre><code class=\"python\">#\u0438\u043c\u043f\u043e\u0440\u0442\u0438\u0440\u0443\u044e \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u044b\u0435 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438 import pandas as pd import numpy as np #\u0441\u043e\u0437\u0434\u0430\u044e \u0434\u0430\u0442\u0430-\u0444\u0440\u0435\u0439\u043c \u0441 \u043a\u043e\u0442\u0438\u0440\u043e\u0432\u043a\u0430\u043c\u0438 \u0432 \u043f\u0435\u0440\u0438\u043e\u0434 \u0441 05.01.2015\u0433 \u043f\u043e 30.12.2021\u0433. #\u0438\u0437 \u043f\u0440\u0435\u0434\u0432\u0430\u0440\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u0437\u0430\u0433\u0440\u0443\u0436\u0435\u043d\u043d\u043e\u0433\u043e \u0444\u0430\u0439\u043b\u0430 .csv df = pd.read_csv('\u2026\\csv_files\\GAZP_150105_213012.csv') #\u0432\u044b\u0432\u043e\u0436\u0443 \u043d\u0430 \u044d\u043a\u0440\u0430\u043d \u043f\u0435\u0440\u0432\u0443\u044e \u0441\u0442\u0440\u043e\u043a\u0443 \u0434\u0430\u0442\u0430-\u0444\u0440\u0435\u0439\u043c\u0430 df print(df.iloc[0])<\/code><\/pre>\n<details class=\"spoiler\">\n<summary>Hidden text<\/summary>\n<div class=\"spoiler__content\">\n<figure class=\"\"><figcaption><\/figcaption><\/figure>\n<\/p>\n<\/div>\n<\/details>\n<pre><code class=\"python\">#\u0438\u0437 \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u043d\u043e\u0433\u043e \u0434\u0430\u0442\u0430-\u0444\u0440\u0435\u0439\u043c\u0430 df \u0441\u043e\u0437\u0434\u0430\u044e \u0434\u0430\u0442\u0430-\u0444\u0440\u0435\u0439\u043c date_open_close_df \u0441\u043e \u0441\u0442\u043e\u043b\u0431\u0446\u0430\u043c\u0438 &lt;DATE>, #&lt;OPEN>, &lt;CLOSE> \u0432 \u043f\u0435\u0440\u0438\u043e\u0434 \u0434\u0430\u0442 \u0441 20.12.2016\u0433. \u043f\u043e 30.12.2021\u0433 date_open_close_df = df.iloc[493:,[2,4,7]] #\u0432\u044b\u0432\u043e\u0436\u0443 \u043d\u0430 \u044d\u043a\u0440\u0430\u043d \u043f\u0435\u0440\u0432\u044b\u0435 5 \u0441\u0442\u0440\u043e\u043a \u0434\u0430\u0442\u0430-\u0444\u0440\u0435\u0439\u043c\u0430 date_open_close_df print(date_open_close_df.head()) <\/code><\/pre>\n<details class=\"spoiler\">\n<summary>Hidden text<\/summary>\n<div class=\"spoiler__content\">\n<figure class=\"\"><figcaption><\/figcaption><\/figure>\n<\/p>\n<\/div>\n<\/details>\n<pre><code class=\"python\">#\u043a\u0430\u0436\u0434\u044b\u0439 \u0441\u0442\u043e\u043b\u0431\u0435\u0446 \u0434\u0430\u0442\u0430-\u0444\u0440\u0435\u0439\u043c\u0430 date_open_close_df \u043f\u0435\u0440\u0435\u0432\u043e\u0436\u0443 \u0432 \u043c\u0430\u0441\u0441\u0438\u0432 numpy \u0434\u043b\u044f #\u043f\u043e\u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u0439 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0438 date_arr = date_open_close_df.iloc[:,0].to_numpy() open_arr = date_open_close_df.iloc[:,1].to_numpy() close_arr = date_open_close_df.iloc[:,2].to_numpy() #\u0441\u043e\u0437\u0434\u0430\u044e \u043c\u0430\u0441\u0441\u0438\u0432 \u0441 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u043e\u043c \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u0434\u043d\u044f \u043f\u043e \u0444\u043e\u0440\u043c\u0443\u043b\u0435 [(close - open) \/ open] res_arr = (close_arr - open_arr) \/ open_arr #\u0441 10-\u0439 \u0441\u0442\u0440\u043e\u043a\u0438 \u0441\u0447\u0438\u0442\u0430\u044e \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u0441\u043a\u043e\u043b\u044c\u0437\u044f\u0449\u0435\u0439 \u0441\u0440\u0435\u0434\u043d\u0435\u0439 \u0437\u0430 9 \u0434\u043d\u0435\u0439 SMA9 sma9_arr = [np.mean(close_arr[i-9:i]) for i in range(9,len(close_arr))] #\u043e\u0431\u044a\u0435\u0434\u0438\u043d\u044f\u044e \u043f\u043e \u0441\u0442\u043e\u043b\u0431\u0446\u0430\u043c \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u043d\u044b\u0435 \u043c\u0430\u0441\u0441\u0438\u0432\u044b \u0432 \u043e\u0434\u0438\u043d \u0434\u043b\u044f \u043f\u043e\u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u0433\u043e \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f \u0438\u0442\u043e\u0433\u043e\u0432\u043e\u0433\u043e #\u0434\u0430\u0442\u0430-\u0444\u0440\u0435\u0439\u043c\u0430, \u043f\u0440\u0438 \u044d\u0442\u043e\u043c \u043d\u0430\u0447\u0430\u043b\u043e \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u0441 10-\u0439 \u0441\u0442\u0440\u043e\u043a\u0438, \u0441 \u043a\u043e\u0442\u043e\u0440\u043e\u0439 \u043d\u0430\u0447\u0438\u043d\u0430\u0435\u0442\u0441\u044f #\u0440\u0430\u0441\u0447\u0435\u0442 SMA9  arr_to_df = np.column_stack([date_arr[9:], open_arr[9:], close_arr[9:], sma9_arr, res_arr[9:]])  #\u0441\u043e\u0437\u0434\u0430\u044e \u0434\u0430\u0442\u0430-\u0444\u0440\u0435\u0439\u043c \u0447\u0435\u043b\u043e\u0432\u0435\u043a\u0430-\u0442\u0440\u0435\u0439\u0434\u0435\u0440\u0430 human_df human_df = pd.DataFrame(data = arr_to_df,                         columns = ['Date', 'Open', 'Close', 'SMA9', 'Result'])  #\u0432\u044b\u0432\u043e\u0436\u0443 \u043d\u0430 \u044d\u043a\u0440\u0430\u043d \u043f\u0435\u0440\u0432\u044b\u0435 5 \u0441\u0442\u0440\u043e\u043a \u0434\u0430\u0442\u0430-\u0444\u0440\u0435\u0439\u043c\u0430 human_df print(human_df.head()) <\/code><\/pre>\n<details class=\"spoiler\">\n<summary>Hidden text<\/summary>\n<div class=\"spoiler__content\">\n<figure class=\"\"><figcaption><\/figcaption><\/figure>\n<\/p>\n<\/div>\n<\/details>\n<pre><code class=\"python\">#\u0417\u0430\u043f\u0438\u0441\u044b\u0432\u0430\u044e \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u043d\u044b\u0439 \u0434\u0430\u0442\u0430-\u0444\u0440\u0435\u0439\u043c \u0447\u0435\u043b\u043e\u0432\u0435\u043a\u0430-\u0442\u0440\u0435\u0439\u0434\u0435\u0440\u0430 \u0432 \u0444\u0430\u0439\u043b gazp_human_df.csv  human_df.to_csv(\u2026\\data-frame\\gazp_human_df.csv')<\/code><\/pre>\n<h3>\u0420\u0430\u0441\u0447\u0435\u0442 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0430 \u0442\u043e\u0440\u0433\u043e\u0432\u043b\u0438 \u0447\u0435\u043b\u043e\u0432\u0435\u043a\u0430-\u0442\u0440\u0435\u0439\u0434\u0435\u0440\u0430<\/h3>\n<p>\u0412 \u043d\u043e\u0432\u043e\u043c \u043e\u043a\u043d\u0435 \u0438\u043c\u043f\u043e\u0440\u0442\u0438\u0440\u0443\u044e \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u044b\u0435 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438 \u0438 \u0437\u0430\u0433\u0440\u0443\u0436\u0430\u044e \u0434\u0430\u0442\u0430-\u0444\u0440\u0435\u0439\u043c \u0442\u0440\u0435\u0439\u0434\u0435\u0440\u0430-\u0447\u0435\u043b\u043e\u0432\u0435\u043a\u0430<\/p>\n<pre><code class=\"python\">import pandas as pd pd.plotting.register_matplotlib_converters() import matplotlib.pyplot as plt import seaborn as sns import numpy as np human_df = pd.read_csv('...\\data-frame\\gazp_human_df.csv',                        index_col = 0)<\/code><\/pre>\n<p>\u0421\u0438\u0441\u0442\u0435\u043c\u0430 \u0442\u043e\u0440\u0433\u043e\u0432\u043b\u0438 \u0442\u0440\u0435\u0439\u0434\u0435\u0440\u0430-\u0447\u0435\u043b\u043e\u0432\u0435\u043a\u0430 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0430\u044f:<\/p>\n<p>\u041a\u0430\u0436\u0434\u044b\u0439 \u0434\u0435\u043d\u044c \u0432 \u043c\u043e\u043c\u0435\u043d\u0442 \u043e\u0442\u043a\u0440\u044b\u0442\u0438\u044f \u0442\u043e\u0440\u0433\u043e\u0432 \u0441\u0440\u0430\u0432\u043d\u0438\u0432\u0430\u044e\u0442\u0441\u044f \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f Open \u0438 SMA9. \u0415\u0441\u043b\u0438 Open > SMA9, \u0442.\u0435. \u0446\u0435\u043d\u0430 \u043d\u0430\u0445\u043e\u0434\u0438\u0442\u0441\u044f \u043d\u0430\u0434 \u0441\u043a\u043e\u043b\u044c\u0437\u044f\u0449\u0435\u0439 \u0441\u0440\u0435\u0434\u043d\u0435\u0439, \u0430\u043a\u0446\u0438\u044f \u043f\u043e\u043a\u0443\u043f\u0430\u0435\u0442\u0441\u044f, \u0435\u0441\u043b\u0438 Open &lt;= SMA9, \u0430\u043a\u0446\u0438\u044f \u043f\u0440\u043e\u0434\u0430\u0435\u0442\u0441\u044f. \u041a\u0430\u0436\u0434\u0430\u044f \u0441\u0434\u0435\u043b\u043a\u0430 \u0437\u0430\u043a\u0440\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u0432 \u043c\u043e\u043c\u0435\u043d\u0442 \u0437\u0430\u043a\u0440\u044b\u0442\u0438\u044f \u0442\u043e\u0440\u0433\u043e\u0432 \u0438 \u0444\u0438\u043a\u0441\u0438\u0440\u0443\u0435\u0442\u0441\u044f \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442. \u0422\u0430\u043a\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c, \u0413\u042d\u041f-\u044b (\u0440\u0430\u0437\u0440\u044b\u0432\u044b), \u043a\u043e\u0433\u0434\u0430 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 Open \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u0433\u043e \u0434\u043d\u044f \u043e\u0442\u043b\u0438\u0447\u0430\u0435\u0442\u0441\u044f \u043e\u0442 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u0421lose \u043f\u0440\u0435\u0434\u044b\u0434\u0443\u0449\u0435\u0433\u043e \u0434\u043d\u044f, \u043d\u0435 \u0443\u0447\u0438\u0442\u044b\u0432\u0430\u044e\u0442\u0441\u044f. \u041e\u0434\u0438\u043d \u0434\u0435\u043d\u044c \u2013 \u043e\u0434\u043d\u0430 \u0441\u0434\u0435\u043b\u043a\u0430.<\/p>\n<pre><code class=\"python\">#\u0441\u043e\u0437\u0434\u0430\u044e \u0444\u0443\u043d\u043a\u0446\u0438\u044e \u0434\u043b\u044f \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u044f \u043f\u0440\u043e\u0433\u043d\u043e\u0437\u0430 \u0447\u0435\u043b\u043e\u0432\u0435\u043a\u0430-\u0442\u0440\u0435\u0439\u0434\u0435\u0440\u0430 def create_human_predict(row):     if row.Open >= row.SMA9:         row.human_predict = 1     else:         row.human_predict = 0             return row.human_predict #\u0441\u043e\u0437\u0434\u0430\u044e \u0441\u0435\u0440\u0438\u044e \u0441 \u043f\u0440\u043e\u0433\u043d\u043e\u0437\u0430\u043c\u0438 \u0447\u0435\u043b\u043e\u0432\u0435\u043a\u0430-\u0442\u0440\u0435\u0439\u0434\u0435\u0440\u0430 human_predict = human_df.apply(create_human_predict, axis='columns') #\u0434\u043e\u0431\u0430\u0432\u043b\u044f\u044e \u0432 \u0434\u0430\u0442\u0430-\u0444\u0440\u0435\u0439\u043c human_df \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u043d\u0443\u044e \u0441\u0435\u0440\u0438\u044e human_df = pd.concat([human_df, human_predict], axis = 1) human_df.columns.values[5]='Predict' #\u0432\u044b\u0432\u043e\u0436\u0443 \u043f\u0435\u0440\u0432\u044b\u0435 5 \u0441\u0442\u0440\u043e\u043a \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u043d\u043e\u0433\u043e \u0434\u0430\u0442\u0430-\u0444\u0440\u0435\u0439\u043c\u0430 print(human_df.head())<\/code><\/pre>\n<details class=\"spoiler\">\n<summary>Hidden text<\/summary>\n<div class=\"spoiler__content\">\n<figure class=\"\"><figcaption><\/figcaption><\/figure>\n<\/p>\n<\/div>\n<\/details>\n<p>\u0412\u0441\u0435 \u043a\u043e\u0440\u0440\u0435\u043a\u0442\u043d\u043e, \u0434\u043b\u044f \u0432\u0441\u0435\u0445 5-\u0438 \u0441\u0442\u0440\u043e\u043a Open \u0431\u043e\u043b\u044c\u0448\u0435, \u0447\u0435\u043c SMA9, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u0441\u0442\u043e\u043b\u0431\u0446\u0430 Predict \u20181\u2019.<\/p>\n<pre><code class=\"python\">#\u0441\u043e\u0437\u0434\u0430\u044e \u0444\u0443\u043d\u043a\u0446\u0438\u044e \u0434\u043b\u044f \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u044f \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0430 \u043f\u0440\u043e\u0433\u043d\u043e\u0437\u0430 \u0447\u0435\u043b\u043e\u0432\u0435\u043a\u0430-\u0442\u0440\u0435\u0439\u0434\u0435\u0440\u0430 \u0432 \u043f\u0440\u043e\u0446\u0435\u043d\u0442\u0430\u0445 def create_human_result_perc(row):     return row.Result * 100 if row.Predict == 1 else - row.Result * 100 #\u0441\u043e\u0437\u0434\u0430\u044e \u0441\u0435\u0440\u0438\u044e \u0441 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0430\u043c\u0438 \u043f\u0440\u043e\u0433\u043d\u043e\u0437\u043e\u0432 \u0447\u0435\u043b\u043e\u0432\u0435\u043a\u0430-\u0442\u0440\u0435\u0439\u0434\u0435\u0440\u0430 \u0432 \u043f\u0440\u043e\u0446\u0435\u043d\u0442\u0430\u0445 human_result_perc = human_df.apply(create_human_result_perc, axis='columns') #\u0441\u043e\u0437\u0434\u0430\u044e \u0444\u0443\u043d\u043a\u0446\u0438\u044e \u0434\u043b\u044f \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u044f \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0430 \u043f\u0440\u043e\u0433\u043d\u043e\u0437\u0430 \u0447\u0435\u043b\u043e\u0432\u0435\u043a\u0430-\u0442\u0440\u0435\u0439\u0434\u0435\u0440\u0430 \u0432 \u0431\u0443\u043b\u0435\u0432\u043e\u043c #\u043c\u043d\u043e\u0436\u0435\u0441\u0442\u0432\u0435, \u0433\u0434\u0435 0 - \u043f\u0440\u043e\u0433\u043d\u043e\u0437 \u043d\u0435\u0432\u0435\u0440\u0435\u043d, 1 - \u043f\u0440\u043e\u0433\u043d\u043e\u0437 \u0432\u0435\u0440\u0435\u043d def create_human_result_bool(row):     return 1 if row.Result >= 0 and row.Predict == 1 or row.Result &lt; 0 and row.Predict == 0 else 0 #\u0441\u043e\u0437\u0434\u0430\u044e \u0441\u0435\u0440\u0438\u044e \u0441 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0430\u043c\u0438 \u043f\u0440\u043e\u0433\u043d\u043e\u0437\u043e\u0432 \u0447\u0435\u043b\u043e\u0432\u0435\u043a\u0430-\u0442\u0440\u0435\u0439\u0434\u0435\u0440\u0430 \u0432 \u0431\u0443\u043b\u0435\u0432\u043e\u043c \u043c\u043d\u043e\u0436\u0435\u0441\u0442\u0432\u0435 human_result_bool = human_df.apply(create_human_result_bool, axis='columns') #\u0441\u043e\u0437\u0434\u0430\u044e \u043d\u043e\u0432\u044b\u0439 \u0434\u0430\u0442\u0430-\u0444\u0440\u0435\u0439\u043c human_result_frame \u0441 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0430\u043c\u0438 \u043f\u0440\u043e\u0433\u043d\u043e\u0437\u043e\u0432 \u0447\u0435\u043b\u043e\u0432\u0435\u043a\u0430-\u0442\u0440\u0435\u0439\u0434\u0435\u0440\u0430 human_result_frame = pd.DataFrame({'Human_result_perc' : human_result_perc, 'Human_result_bool' : human_result_bool}) print(human_result_frame.head())<\/code><\/pre>\n<details class=\"spoiler\">\n<summary>Hidden text<\/summary>\n<div class=\"spoiler__content\">\n<figure class=\"\"><figcaption><\/figcaption><\/figure>\n<\/p>\n<\/div>\n<\/details>\n<pre><code class=\"python\">#\u0432\u044b\u0432\u043e\u0436\u0443 \u043f\u0440\u043e\u0446\u0435\u043d\u0442 \u0432\u0435\u0440\u043d\u044b\u0445 \u043f\u0440\u043e\u0433\u043d\u043e\u0437\u043e\u0432 \u0447\u0435\u043b\u043e\u0432\u0435\u043a\u0430-\u0442\u0440\u0435\u0439\u0434\u0435\u0440\u0430 print(human_result_frame.Human_result_bool.value_counts('1'))<\/code><\/pre>\n<details class=\"spoiler\">\n<summary>Hidden text<\/summary>\n<div class=\"spoiler__content\">\n<figure class=\"\"><figcaption><\/figcaption><\/figure>\n<\/p>\n<\/div>\n<\/details>\n<pre><code class=\"python\">#\u0441\u043e\u0437\u0434\u0430\u044e \u0441\u0435\u0440\u0438\u044e \u0441 \u043a\u0443\u043c\u0443\u043b\u044f\u0442\u0438\u0432\u043d\u043e\u0439 \u0441\u0443\u043c\u043c\u043e\u0439 human_result_perc human_result_cumsum = human_result_frame.Human_result_perc.cumsum() print(human_result_cumsum)<\/code><\/pre>\n<details class=\"spoiler\">\n<summary>Hidden text<\/summary>\n<div class=\"spoiler__content\">\n<figure class=\"\"><figcaption><\/figcaption><\/figure>\n<\/p>\n<\/div>\n<\/details>\n<pre><code class=\"python\">#\u0434\u043e\u0431\u0430\u0432\u043b\u044f\u044e \u0432 \u0434\u0430\u0442\u0430-\u0444\u0440\u0435\u0439\u043c human_df \u043d\u043e\u0432\u044b\u0439 \u0434\u0430\u0442\u0430-\u0444\u0440\u0435\u0439\u043c human_result_frame human_df = pd.concat([human_df, human_result_frame], axis = 1) #\u0434\u043e\u0431\u0430\u0432\u043b\u044f\u044e \u0432 \u0434\u0430\u0442\u0430-\u0444\u0440\u0435\u0439\u043c human_df \u0441\u0435\u0440\u0438\u044e \u0441 \u043a\u0443\u043c\u0443\u043b\u044f\u0442\u0438\u0432\u043d\u043e\u0439 \u0441\u0443\u043c\u043c\u043e\u0439 human_result_perc human_df = pd.concat([human_df, human_result_cumsum], axis = 1) human_df.columns.values[8]='CumSum' #\u0432\u044b\u0432\u043e\u0436\u0443 \u043f\u0435\u0440\u0432\u044b\u0435 5 \u0441\u0442\u0440\u043e\u043a \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u043d\u043e\u0433\u043e \u0434\u0430\u0442\u0430-\u0444\u0440\u0435\u0439\u043c\u0430 print(human_df.head())<\/code><\/pre>\n<details class=\"spoiler\">\n<summary>Hidden text<\/summary>\n<div class=\"spoiler__content\">\n<figure class=\"full-width\"><figcaption><\/figcaption><\/figure>\n<\/p>\n<\/div>\n<\/details>\n<pre><code class=\"python\">#\u0414\u043b\u044f \u0432\u0438\u0437\u0443\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u0441\u0442\u0440\u043e\u044e \u0433\u0440\u0430\u0444\u0438\u043a \u0442\u043e\u0440\u0433\u043e\u0432\u043b\u0438 \u0442\u0440\u0435\u0439\u0434\u0435\u0440\u0430-\u0447\u0435\u043b\u043e\u0432\u0435\u043a\u0430: #\u0443\u0441\u0442\u0430\u043d\u0430\u0432\u043b\u0438\u0432\u0430\u044e \u0448\u0438\u0440\u0438\u043d\u0443 \u0438 \u0432\u044b\u0441\u043e\u0442\u0443 \u0433\u0440\u0430\u0444\u0438\u043a\u0430 plt.figure(figsize=(10,6)) # \u0417\u0430\u0433\u043e\u043b\u043e\u0432\u043e\u043a plt.title(\"\u0420\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u0442\u043e\u0440\u0433\u043e\u0432\u043b\u0438 \u0442\u0440\u0435\u0439\u0434\u0435\u0440\u0430-\u0447\u0435\u043b\u043e\u0432\u0435\u043a\u0430\") # \u0441\u0442\u0440\u043e\u044e \u043b\u0438\u043d\u0435\u0439\u043d\u044b\u0439 \u0433\u0440\u0430\u0444\u0438\u043a sns.lineplot(data=human_df['CumSum']) plt.show()<\/code><\/pre>\n<figure class=\"full-width\"><figcaption><\/figcaption><\/figure>\n<p>\u041d\u0438\u0436\u0435 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u0442\u043e\u0440\u0433\u043e\u0432\u043b\u0438 \u0447\u0435\u043b\u043e\u0432\u0435\u043a\u0430 \u2013 \u0442\u0440\u0435\u0439\u0434\u0435\u0440\u0430:<\/p>\n<p><strong>\u041f\u0440\u043e\u0446\u0435\u043d\u0442 \u0443\u0441\u043f\u0435\u0448\u043d\u044b\u0445 \u043f\u0440\u043e\u0433\u043d\u043e\u0437\u043e\u0432 \u0432 %: 50,9%<\/strong><\/p>\n<p><strong>\u0420\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u0442\u043e\u0440\u0433\u043e\u0432\u043b\u0438: +74,51%<\/strong><\/p>\n<p>\u0422.\u0435. \u0437\u0430 5 \u043b\u0435\u0442 \u0441 2017 \u043f\u043e 2021 \u0433\u043e\u0434 \u0442\u0430\u043a\u0430\u044f \u0441\u0438\u0441\u0442\u0435\u043c\u0430 \u0442\u043e\u0440\u0433\u043e\u0432\u043b\u0438 \u043f\u0440\u0438\u043d\u0435\u0441\u043b\u0430 \u043f\u043e\u0447\u0442\u0438 75%.<\/p>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\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-335710","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/335710","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=335710"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/335710\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=335710"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=335710"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=335710"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}