{"id":352218,"date":"2024-05-20T22:04:24","date_gmt":"2024-05-20T22:04:24","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=352218"},"modified":"-0001-11-30T00:00:00","modified_gmt":"2024-05-20T22:04:24","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=352218","title":{"rendered":"<span>\u0420\u0435\u043a\u043e\u043c\u0435\u043d\u0434\u0430\u0442\u0435\u043b\u044c\u043d\u0430\u044f \u0441\u0438\u0441\u0442\u0435\u043c\u0430 SVD: Funk MF (Matrix Factorization)<\/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<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/781\/357\/536\/78135753697e5ccee17eec040a97e404.png\" width=\"823\" height=\"200\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/781\/357\/536\/78135753697e5ccee17eec040a97e404.png\"\/><\/figure>\n<p>\u0414\u0430\u043d\u043d\u0430\u044f \u0441\u0442\u0430\u0442\u044c\u044f \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043f\u0440\u043e\u0434\u043e\u043b\u0436\u0435\u043d\u0438\u0435\u043c &#171;<a href=\"https:\/\/habr.com\/ru\/articles\/751470\/\" rel=\"noopener noreferrer nofollow\">\u0420\u0435\u043a\u043e\u043c\u0435\u043d\u0434\u0430\u0442\u0435\u043b\u044c\u043d\u0430\u044f \u0441\u0438\u0441\u0442\u0435\u043c\u0430 SVD<\/a>&#171;. \u0415\u0441\u043b\u0438 \u0432\u0430\u043c \u043d\u0435 \u0437\u043d\u0430\u043a\u043e\u043c\u0430 \u0442\u0435\u0440\u043c\u0438\u043d\u043e\u043b\u043e\u0433\u0438\u044f (user-item matrix, SVD-\u0440\u0430\u0437\u043b\u043e\u0436\u0435\u043d\u0438\u0435, PCA, \u043c\u0435\u0442\u043e\u0434 \u0433\u043b\u0430\u0432\u043d\u044b\u0445 \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442 \u0438 \u043f\u0440.), \u0442\u043e \u0440\u0435\u043a\u043e\u043c\u0435\u043d\u0434\u0443\u044e \u043f\u0440\u0435\u0436\u0434\u0435 \u043f\u0440\u043e\u0447\u0438\u0442\u0430\u0442\u044c \u043f\u0435\u0440\u0432\u0443\u044e \u0447\u0430\u0441\u0442\u044c. <\/p>\n<p><a href=\"https:\/\/ru.wikipedia.org\/wiki\/Netflix_Prize\" rel=\"noopener noreferrer nofollow\"><u>Netflix Prize<\/u><\/a>\u00a0&#8212; \u043e\u0434\u043d\u043e \u0438\u0437 \u0441\u0430\u043c\u044b\u0445 \u0438\u0437\u0432\u0435\u0441\u0442\u043d\u044b\u0445 \u0441\u043e\u0440\u0435\u0432\u043d\u043e\u0432\u0430\u043d\u0438\u0439 \u0432 \u043e\u0431\u043b\u0430\u0441\u0442\u0438 \u043c\u0430\u0448\u0438\u043d\u043d\u043e\u0433\u043e \u043e\u0431\u0443\u0447\u0435\u043d\u0438\u044f. \u0426\u0435\u043b\u044c\u044e \u0431\u044b\u043b\u043e \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u0435 \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u0430, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0443\u043b\u0443\u0447\u0448\u0430\u043b \u0431\u044b \u0440\u0435\u043a\u043e\u043c\u0435\u043d\u0434\u0430\u0446\u0438\u0438 \u0444\u0438\u043b\u044c\u043c\u043e\u0432 \u0438 \u0442\u0435\u043b\u0435\u0448\u043e\u0443 \u043d\u0430 10%.<\/p>\n<p>\u041e\u0434\u0438\u043d \u0438\u0437 \u043d\u0430\u0438\u0431\u043e\u043b\u0435\u0435 \u0443\u0441\u043f\u0435\u0448\u043d\u044b\u0445 \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u043e\u0432 \u0431\u044b\u043b \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c<a href=\"https:\/\/en.wikipedia.org\/wiki\/Matrix_factorization_(recommender_systems)\" rel=\"noopener noreferrer nofollow\"> \u0421\u0430\u0439\u043c\u043e\u043d\u0430 \u0424\u0430\u043d\u043a\u0430<\/a>, \u043e\u0441\u043d\u043e\u0432\u043d\u043e\u0439 \u0438\u0434\u0435\u0435\u0439 \u043a\u043e\u0442\u043e\u0440\u043e\u0433\u043e \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043c\u0430\u0442\u0440\u0438\u0447\u043d\u0430\u044f \u0444\u0430\u043a\u0442\u043e\u0440\u0438\u0437\u0430\u0446\u0438\u044f. <\/p>\n<p>\u041c\u0430\u0442\u0440\u0438\u0447\u043d\u0430\u044f \u0444\u0430\u043a\u0442\u043e\u0440\u0438\u0437\u0430\u0446\u0438\u044f &#8212; \u0440\u0430\u0437\u043b\u043e\u0436\u0435\u043d\u0438\u0435 \u043c\u0430\u0442\u0440\u0438\u0446\u044b \u043d\u0430 \u043f\u0440\u043e\u0438\u0437\u0432\u0435\u0434\u0435\u043d\u0438\u0435 \u0434\u0432\u0443\u0445 \u0438\u043b\u0438 \u0431\u043e\u043b\u0435\u0435 \u043c\u0430\u0442\u0440\u0438\u0446. \u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, SVD-\u0440\u0430\u0437\u043b\u043e\u0436\u0435\u043d\u0438\u0435.<\/p>\n<p>\u041f\u0443\u0441\u0442\u044c \u0443 \u043d\u0430\u0441 \u0438\u043c\u0435\u0435\u0442\u0441\u044f \u043c\u0430\u0442\u0440\u0438\u0446\u0430 \u0440\u0435\u0439\u0442\u0438\u043d\u0433\u043e\u0432 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0435\u0439 <img loading=\"lazy\" decoding=\"async\" class=\"formula inline\" source=\"R\" alt=\"R\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/ea0\/9d5\/e79\/ea09d5e795166a3ea8ef6927498e68e5.svg\" width=\"15\" height=\"17\"\/> (\u0440\u0430\u0437\u0440\u044f\u0436\u0435\u043d\u043d\u0430\u044f <a href=\"https:\/\/habr.com\/ru\/articles\/751470\/#:~:text=User%2Ditem%20matrix,%D0%B8%20%D1%80%D0%B0%D0%B7%D1%80%D1%8F%D0%B6%D0%B5%D0%BD%D0%BD%D0%B0%D1%8F%20%D0%BC%D0%B0%D1%82%D1%80%D0%B8%D1%86%D0%B0.\" rel=\"noopener noreferrer nofollow\">user-item matrix<\/a>). <img loading=\"lazy\" decoding=\"async\" class=\"formula inline\" source=\"r_{ui}\" alt=\"r_{ui}\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/2dd\/d40\/fc7\/2ddd40fc73feb8330c2f4714bf23683a.svg\" width=\"23\" height=\"15\"\/>&#8212; \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u044b <img loading=\"lazy\" decoding=\"async\" class=\"formula inline\" source=\"R\" alt=\"R\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/b6f\/252\/c97\/b6f252c97de67fd93ce3db22188cac39.svg\" width=\"15\" height=\"17\"\/>. \u041e\u0431\u043e\u0437\u043d\u0430\u0447\u0438\u043c \u0447\u0435\u0440\u0435\u0437 <img loading=\"lazy\" decoding=\"async\" class=\"formula inline\" source=\"\\hat R\" alt=\"\\hat R\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/552\/322\/d9e\/552322d9eddc443bc23fe379b68cdea4.svg\" width=\"15\" height=\"21\"\/>&#8212; \u043f\u0440\u043e\u0433\u043d\u043e\u0437\u0438\u0440\u0443\u0435\u043c\u044b\u0435 \u0440\u0435\u0439\u0442\u0438\u043d\u0433\u0438 \u0438 <img loading=\"lazy\" decoding=\"async\" class=\"formula inline\" source=\"\\hat r_{ui}\" alt=\"\\hat r_{ui}\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/584\/a8b\/bf0\/584a8bbf03e647e8cf529ee1cc45eff9.svg\" width=\"25\" height=\"20\"\/>&#8212; \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u044b <img loading=\"lazy\" decoding=\"async\" class=\"formula inline\" source=\"\\hat R\" alt=\"\\hat R\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/e8f\/d5a\/190\/e8fd5a19011b7f33f45255eaa6d44683.svg\" width=\"15\" height=\"21\"\/>. \u041f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u0438\u043c <img loading=\"lazy\" decoding=\"async\" class=\"formula inline\" source=\"R\" alt=\"R\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/8d0\/a77\/494\/8d0a77494e3b3d11b7ae27aefc3ec133.svg\" width=\"15\" height=\"17\"\/> \u043a\u0430\u043a \u043f\u0440\u043e\u0438\u0437\u0432\u0435\u0434\u0435\u043d\u0438\u0435 \u043c\u0430\u0442\u0440\u0438\u0446 <img loading=\"lazy\" decoding=\"async\" class=\"formula inline\" source=\"P\" alt=\"P\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/ac8\/820\/434\/ac882043495a8789991c5b42ac763fd1.svg\" width=\"14\" height=\"17\"\/>\u043d\u0430 <img loading=\"lazy\" decoding=\"async\" class=\"formula inline\" source=\"Q\" alt=\"Q\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/5b6\/05c\/0b5\/5b605c0b5c86e2667686206b46a80c49.svg\" width=\"15\" height=\"20\"\/>. \u041f\u043e\u0434\u0440\u0430\u0437\u0443\u043c\u0435\u0432\u0430\u0435\u0442\u0441\u044f, \u0447\u0442\u043e <img loading=\"lazy\" decoding=\"async\" class=\"formula inline\" source=\"P\" alt=\"P\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/0d5\/9b1\/875\/0d59b1875d001b40561086b58bacda92.svg\" width=\"14\" height=\"17\"\/>&#8212; <strong>\u0441\u043a\u0440\u044b\u0442\u044b\u0435<\/strong> \u0444\u0430\u043a\u0442\u043e\u0440\u044b \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f (<strong>user<\/strong>), <img loading=\"lazy\" decoding=\"async\" class=\"formula inline\" source=\"p_u\" alt=\"p_u\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/fff\/a1d\/371\/fffa1d371d0c80519391120953cca882.svg\" width=\"20\" height=\"15\"\/>&#8212; <img loading=\"lazy\" decoding=\"async\" class=\"formula inline\" source=\"u\" alt=\"u\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/535\/15d\/a87\/53515da87330162f93d0c51add88740f.svg\" width=\"11\" height=\"12\"\/>-\u0430\u044f \u0441\u0442\u0440\u043e\u043a\u0430. <img loading=\"lazy\" decoding=\"async\" class=\"formula inline\" source=\"Q\" alt=\"Q\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/cc3\/99f\/802\/cc399f802dc888e34675521113fb03c0.svg\" width=\"15\" height=\"20\"\/>&#8212; <strong>\u0441\u043a\u0440\u044b\u0442\u044b\u0435<\/strong> \u0444\u0430\u043a\u0442\u043e\u0440\u044b \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u0430 (<strong>item<\/strong>), <img loading=\"lazy\" decoding=\"async\" class=\"formula inline\" source=\"q_i\" alt=\"q_i\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/e5e\/a9e\/70f\/e5ea9e70fe7da637cc1c1a06ec31efd3.svg\" width=\"15\" height=\"15\"\/>&#8212; <img loading=\"lazy\" decoding=\"async\" class=\"formula inline\" source=\"i\" alt=\"i\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/610\/c72\/4c9\/610c724c985ce8291bb96456ddfc2866.svg\" width=\"7\" height=\"16\"\/>-\u044b\u0439 \u0441\u0442\u043e\u043b\u0431\u0435\u0446 (\u0442\u0430\u043a\u0438\u0435 \u043c\u0435\u0442\u043e\u0434\u044b \u043d\u0430\u0437\u044b\u0432\u0430\u044e\u0442 <strong><em>Latent Models for Collaborative Filtering<\/em><\/strong>). \u0422\u043e\u0433\u0434\u0430 \u043f\u0440\u043e\u0433\u043d\u043e\u0437\u0438\u0440\u0443\u0435\u043c\u044b\u0439 \u0440\u0435\u0439\u0442\u0438\u043d\u0433 \u0434\u043b\u044f <img loading=\"lazy\" decoding=\"async\" class=\"formula inline\" source=\"u\" alt=\"u\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/582\/3be\/355\/5823be355aaf81a5656da131cfddb95a.svg\" width=\"11\" height=\"12\"\/>-\u0433\u043e \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f \u0438 <img loading=\"lazy\" decoding=\"async\" class=\"formula inline\" source=\"i\" alt=\"i\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/a1f\/b82\/1cf\/a1fb821cfba29d94a4a296d90ea885f1.svg\" width=\"7\" height=\"16\"\/>-\u0433\u043e \u0442\u043e\u0432\u0430\u0440\u0430 \u0432\u044b\u0447\u0438\u0441\u043b\u044f\u0435\u0442\u0441\u044f \u043a\u0430\u043a \u0441\u043a\u0430\u043b\u044f\u0440\u043d\u043e\u0435 \u043f\u0440\u043e\u0438\u0437\u0432\u0435\u0434\u0435\u043d\u0438\u0435: <img loading=\"lazy\" decoding=\"async\" class=\"formula inline\" source=\"\\hat r_{ui} = q^T_i p_u\" alt=\"\\hat r_{ui} = q^T_i p_u\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/cd7\/e9b\/c04\/cd7e9bc04d4d9c36d364e6b90e84c6e3.svg\" width=\"91\" height=\"25\"\/>.<\/p>\n<p>\u041e\u0431\u0443\u0447\u0435\u043d\u0438\u0435 \u0441\u043e\u0441\u0442\u043e\u0438\u0442 \u0432 \u043c\u0438\u043d\u0438\u043c\u0438\u0437\u0430\u0446\u0438\u0438 \u043a\u0432\u0430\u0434\u0440\u0430\u0442\u0438\u0447\u043d\u043e\u0439\u00a0\u043e\u0448\u0438\u0431\u043a\u0438:<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"formula\" source=\"\\sum_{r_{ui} \\in R_{train}} \\left(r_{ui} - \\hat{r}_{ui} \\right)^2 +\\lambda \\left(||q_i||^2 + ||p_u||^2\\right)\" alt=\"\\sum_{r_{ui} \\in R_{train}} \\left(r_{ui} - \\hat{r}_{ui} \\right)^2 +\\lambda \\left(||q_i||^2 + ||p_u||^2\\right)\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/532\/294\/100\/5322941004f6ab1eee459980e0e1ce1f.svg\" width=\"338\" height=\"51\"\/><\/p>\n<p>\u0433\u0434\u0435 <img loading=\"lazy\" decoding=\"async\" class=\"formula inline\" source=\"\\lambda \" alt=\"\\lambda \" src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/09e\/41b\/af5\/09e41baf57d881d3742d7eb9cce03d95.svg\" width=\"11\" height=\"17\"\/>&#8212; \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043a\u043e\u044d\u0444\u0444\u0438\u0446\u0438\u0435\u043d\u0442 (\u0433\u0438\u043f\u0435\u0440\u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440).<\/p>\n<p>\u041e\u0434\u043d\u0430\u043a\u043e, \u043f\u0440\u0438 \u043f\u0440\u043e\u0433\u043d\u043e\u0437\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0438 \u043e\u0446\u0435\u043d\u043e\u043a \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0443\u0447\u0438\u0442\u044b\u0432\u0430\u0442\u044c\u00a0<strong>\u043f\u0440\u0435\u0434\u0443\u0431\u0435\u0436\u0434\u0435\u043d\u0438\u044f<\/strong>\u00a0\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0435\u0439.<\/p>\n<p>\u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c, \u0432\u0435\u0440\u043e\u044f\u0442\u043d\u043e, \u043f\u043e\u0441\u0442\u0430\u0432\u0438\u0442 \u0431\u043e\u043b\u0435\u0435 \u0437\u0430\u0432\u044b\u0448\u0435\u043d\u043d\u0443\u044e \u043e\u0446\u0435\u043d\u043a\u0443 \u0444\u0438\u043b\u044c\u043c\u0443, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043f\u0440\u0438\u0437\u043d\u0430\u043d \u043a\u0430\u043a\u0438\u043c-\u0442\u043e \u0441\u043e\u043e\u0431\u0449\u0435\u0441\u0442\u0432\u043e\u043c. \u0412 \u0442\u043e \u0432\u0440\u0435\u043c\u044f \u043a\u0430\u043a \u043c\u0435\u043d\u0435\u0435 \u043f\u043e\u043f\u0443\u043b\u044f\u0440\u043d\u044b\u0439 \u0444\u0438\u043b\u044c\u043c \u043f\u043e\u043b\u0443\u0447\u0438\u0442 \u0431\u043e\u043b\u0435\u0435 \u0443\u043c\u0435\u0440\u0435\u043d\u043d\u0443\u044e \u043e\u0446\u0435\u043d\u043a\u0443.<\/p>\n<p>\u0418\u043b\u0438, \u043c\u043e\u0436\u043d\u043e \u0440\u0430\u0437\u0434\u0435\u043b\u0438\u0442\u044c \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0435\u0439 \u043d\u0430 \u0431\u043e\u043b\u0435\u0435 \u0438 \u043c\u0435\u043d\u0435\u0435 \u043a\u0440\u0438\u0442\u0438\u0447\u043d\u044b\u0445. \u041a\u0442\u043e-\u0442\u043e \u043b\u0435\u0433\u043a\u043e \u0441\u0442\u0430\u0432\u0438\u0442 \u0432\u044b\u0441\u043e\u043a\u0438\u0435 \u0440\u0435\u0439\u0442\u0438\u043d\u0433\u0438, \u043a\u0442\u043e-\u0442\u043e &#8212; \u043d\u0430\u043e\u0431\u043e\u0440\u043e\u0442.<\/p>\n<p>\u042d\u0442\u0438 \u0441\u043c\u0435\u0449\u0435\u043d\u0438\u044f (\u043f\u0440\u0435\u0434\u0443\u0431\u0435\u0436\u0434\u0435\u043d\u0438\u044f) \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0443\u0447\u0438\u0442\u044b\u0432\u0430\u0442\u044c \u043f\u0440\u0438 \u043f\u0440\u043e\u0433\u043d\u043e\u0437\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0438.<\/p>\n<p>\u0412\u0432\u0435\u0434\u0435\u043c \u043d\u043e\u0432\u044b\u0435 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0435:<\/p>\n<ul>\n<li>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"formula inline\" source=\" \\mu\" alt=\" \\mu\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/e08\/554\/4e1\/e085544e15f12a58dfa8c5c31cc676fe.svg\" width=\"12\" height=\"16\"\/>&#8212; \u0441\u0440\u0435\u0434\u043d\u0435\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u0431\u0430\u043b\u043b\u043e\u0432, \u0432\u044b\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u043d\u044b\u0445 \u043f\u043e \u0432\u0441\u0435\u043c items \u0432\u0441\u0435\u043c\u0438 users;<\/p>\n<\/li>\n<li>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"formula inline\" source=\"b_i \" alt=\"b_i \" src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/77c\/83c\/976\/77c83c976d274442eccec3803be8c87b.svg\" width=\"15\" height=\"20\"\/>&#8212; \u0441\u043c\u0435\u0449\u0435\u043d\u0438\u0435, \u0432\u043d\u043e\u0441\u0438\u043c\u043e\u0435 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u043e\u043c;<\/p>\n<\/li>\n<li>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"formula inline\" source=\"b_u\" alt=\"b_u\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/7ee\/0fe\/c5f\/7ee0fec5fb4f12781c0797d411df8f23.svg\" width=\"18\" height=\"20\"\/>&#8212; \u043f\u0440\u0435\u0434\u0432\u0437\u044f\u0442\u043e\u0441\u0442\u044c, \u0432\u043d\u0435\u0441\u0435\u043d\u043d\u0430\u044f \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0435\u043c;<\/p>\n<\/li>\n<\/ul>\n<p>\u0422\u043e\u0433\u0434\u0430, \u0441\u043a\u043e\u0440\u0440\u0435\u043a\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0439 \u043f\u0440\u043e\u0433\u043d\u043e\u0437 (\u0441 \u0443\u0447\u0435\u0442\u043e\u043c \u0441\u043c\u0435\u0449\u0435\u043d\u0438\u044f) :<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"formula\" source=\"\\hat{r}_{ui} = \\mu + b_i + b_u + q^T_i p_u\" alt=\"\\hat{r}_{ui} = \\mu + b_i + b_u + q^T_i p_u\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/335\/cd4\/5f2\/335cd45f203dcdab0e9d9ceac4db718c.svg\" width=\"206\" height=\"25\"\/><\/p>\n<p>\u0412 \u0442\u0430\u043a\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u043c\u0438\u043d\u0438\u043c\u0438\u0437\u0438\u0440\u0443\u0435\u043c \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0439 \u0444\u0443\u043d\u043a\u0446\u0438\u043e\u043d\u0430\u043b:<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"formula\" source=\"\\sum_{r_{ui} \\in R_{train}} \\left(r_{ui} - \\mu + b_i + b_u + q^T_i p_u  \\right)^2 + \\lambda\\left(b_i^2 + b_u^2 + ||q_i||^2 + ||p_u||^2\\right) =\" alt=\"\\sum_{r_{ui} \\in R_{train}} \\left(r_{ui} - \\mu + b_i + b_u + q^T_i p_u  \\right)^2 + \\lambda\\left(b_i^2 + b_u^2 + ||q_i||^2 + ||p_u||^2\\right) =\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/ba9\/a3a\/a52\/ba9a3aa5220c34e1b56c5444caea1758.svg\" width=\"573\" height=\"51\"\/><img loading=\"lazy\" decoding=\"async\" class=\"formula\" source=\"\\sum_{r_{ui} \\in R_{train}} \\left(r_{ui} - \\hat{r}_{ui} \\right)^2 + \\lambda\\left(b_i^2 + b_u^2 + ||q_i||^2 + ||p_u||^2\\right) \" alt=\"\\sum_{r_{ui} \\in R_{train}} \\left(r_{ui} - \\hat{r}_{ui} \\right)^2 + \\lambda\\left(b_i^2 + b_u^2 + ||q_i||^2 + ||p_u||^2\\right) \" src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/142\/2ba\/59b\/1422ba59b59778ef56bf0c8392abed6d.svg\" width=\"420\" height=\"51\"\/><\/p>\n<p>\u041e\u043f\u0442\u0438\u043c\u0430\u043b\u044c\u043d\u043e\u0435 \u0440\u0435\u0448\u0435\u043d\u0438\u0435 \u0431\u0443\u0434\u0435\u043c \u0438\u0441\u043a\u0430\u0442\u044c \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u0433\u0440\u0430\u0434\u0438\u0435\u043d\u0442\u043d\u043e\u0433\u043e \u0441\u043f\u0443\u0441\u043a\u0430.<\/p>\n<p>\u041e\u0448\u0438\u0431\u043a\u0443 \u043e\u0431\u043e\u0437\u043d\u0430\u0447\u0438\u043c \u043a\u0430\u043a <img loading=\"lazy\" decoding=\"async\" class=\"formula inline\" source=\"e_{ui} = r_{ui} - \\hat{r}_{ui}\" alt=\"e_{ui} = r_{ui} - \\hat{r}_{ui}\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/bc4\/e21\/555\/bc4e2155573ab836bdc1729ec15f6e4d.svg\" width=\"121\" height=\"20\"\/><\/p>\n<p>\u0413\u0440\u0430\u0434\u0438\u0435\u043d\u0442\u044b \u043f\u043e <img loading=\"lazy\" decoding=\"async\" class=\"formula inline\" source=\"b_u\" alt=\"b_u\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/95c\/794\/eb8\/95c794eb8f7186c92de761da182d2c51.svg\" width=\"18\" height=\"20\"\/>, <img loading=\"lazy\" decoding=\"async\" class=\"formula inline\" source=\"b_i\" alt=\"b_i\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/b18\/5f9\/a08\/b185f9a08b81c8073095abfee31dd4ad.svg\" width=\"15\" height=\"20\"\/>, <img loading=\"lazy\" decoding=\"async\" class=\"formula inline\" source=\"p_u\" alt=\"p_u\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/282\/287\/ed5\/282287ed58228cadc763ea75d020ac3a.svg\" width=\"20\" height=\"15\"\/>, <img loading=\"lazy\" decoding=\"async\" class=\"formula inline\" source=\"q_i\" alt=\"q_i\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/a27\/f57\/a39\/a27f57a39969116f6e3b309f79b5178a.svg\" width=\"15\" height=\"15\"\/>:<\/p>\n<p> <img loading=\"lazy\" decoding=\"async\" class=\"formula inline\" source=\"\\nabla b_u = \\left(r_{ui} - \\mu + b_i + b_u + q^T_i p_u  \\right) - \\lambda b_u  = e_{ui} - \\lambda b_u \" alt=\"\\nabla b_u = \\left(r_{ui} - \\mu + b_i + b_u + q^T_i p_u  \\right) - \\lambda b_u  = e_{ui} - \\lambda b_u \" src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/0fc\/029\/ddb\/0fc029ddbf0de23521654b9e73d54366.svg\" width=\"434\" height=\"26\"\/><\/p>\n<p> <img loading=\"lazy\" decoding=\"async\" class=\"formula inline\" source=\"\\nabla b_i = e_{ui} - \\lambda b_i\" alt=\"\\nabla b_i = e_{ui} - \\lambda b_i\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/e68\/632\/ad6\/e68632ad68955150429742b63a05b3e9.svg\" width=\"130\" height=\"20\"\/><\/p>\n<p> <img loading=\"lazy\" decoding=\"async\" class=\"formula inline\" source=\"\\nabla p_u = e_{ui} \\cdot q_i - \\lambda p_u\" alt=\"\\nabla p_u = e_{ui} \\cdot q_i - \\lambda p_u\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/534\/e3b\/3d7\/534e3b3d711a836cea6fd3afc2dae840.svg\" width=\"168\" height=\"20\"\/><\/p>\n<p> <img loading=\"lazy\" decoding=\"async\" class=\"formula inline\" source=\"\\nabla q_i = e_{ui} \\cdot p_u - \\lambda q_i\" alt=\"\\nabla q_i = e_{ui} \\cdot p_u - \\lambda q_i\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/212\/3c5\/13e\/2123c513efe6ba6016182549fa614c5e.svg\" width=\"164\" height=\"20\"\/><\/p>\n<p>\u0422\u043e\u0433\u0434\u0430 \u0433\u0440\u0430\u0434\u0438\u0435\u043d\u0442\u043d\u044b\u0439 \u0448\u0430\u0433 \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0435\u0442\u0441\u044f \u043f\u043e \u0444\u043e\u0440\u043c\u0443\u043b\u0430\u043c:<\/p>\n<p> <img loading=\"lazy\" decoding=\"async\" class=\"formula inline\" source=\"b_u \\leftarrow b_u + \\gamma (e_{ui} - \\lambda b_u)\" alt=\"b_u \\leftarrow b_u + \\gamma (e_{ui} - \\lambda b_u)\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/896\/511\/8f8\/8965118f8f05e756fb8231d0f8f01866.svg\" width=\"191\" height=\"22\"\/><\/p>\n<p> <img loading=\"lazy\" decoding=\"async\" class=\"formula inline\" source=\"b_i \\leftarrow b_i + \\gamma (e_{ui} - \\lambda b_i)\" alt=\"b_i \\leftarrow b_i + \\gamma (e_{ui} - \\lambda b_i)\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/4bc\/df4\/637\/4bcdf46377ac5faa845f9fba55aa4334.svg\" width=\"182\" height=\"22\"\/><\/p>\n<p> <img loading=\"lazy\" decoding=\"async\" class=\"formula inline\" source=\"p_u \\leftarrow p_u + \\gamma (e_{ui} \\cdot q_i - \\lambda p_u)\" alt=\"p_u \\leftarrow p_u + \\gamma (e_{ui} \\cdot q_i - \\lambda p_u)\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/430\/53c\/ead\/43053cead3d09db536dea2f5a4c0c68a.svg\" width=\"225\" height=\"22\"\/><\/p>\n<p> <img loading=\"lazy\" decoding=\"async\" class=\"formula inline\" source=\"q_i \\leftarrow q_i + \\gamma (e_{ui} \\cdot p_u - \\lambda q_i)\" alt=\"q_i \\leftarrow q_i + \\gamma (e_{ui} \\cdot p_u - \\lambda q_i)\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/808\/6ee\/2ae\/8086ee2ae3aa71b0d494b37d32c85341.svg\" width=\"216\" height=\"22\"\/><\/p>\n<p>\u0433\u0434\u0435 <img loading=\"lazy\" decoding=\"async\" class=\"formula inline\" source=\"\\gamma\" alt=\"\\gamma\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/c9d\/ca6\/322\/c9dca6322ea17c75309293506d0878f3.svg\" width=\"10\" height=\"16\"\/> &#8212; \u043a\u043e\u044d\u0444\u0444\u0438\u0446\u0438\u0435\u043d\u0442 \u0441\u043a\u043e\u0440\u043e\u0441\u0442\u0438 \u043e\u0431\u0443\u0447\u0435\u043d\u0438\u044f <strong><em>learning rate<\/em><\/strong> (\u0433\u0438\u043f\u0435\u0440\u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440).<\/p>\n<p>\u0420\u0435\u0430\u043b\u0438\u0437\u0443\u0435\u043c \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c. <\/p>\n<p>\u0414\u0430\u043d\u043d\u044b\u0435 \u0432\u043e\u0437\u044c\u043c\u0435\u043c \u0438\u0437 <a href=\"https:\/\/habr.com\/ru\/articles\/751470\/#:~:text=%D0%97%D0%B0%D0%B4%D0%B0%D0%B4%D0%B8%D0%BC%20%D0%BF%D0%BE%D0%BB%D1%8C%D0%B7%D0%BE%D0%B2%D0%B0%D1%82%D0%B5%D0%BB%D0%B5%D0%B9%20%D0%B8%20%D1%84%D0%B8%D0%BB%D1%8C%D0%BC%D1%8B%3A\" rel=\"noopener noreferrer nofollow\">\u043f\u0435\u0440\u0432\u043e\u0439 \u0447\u0430\u0441\u0442\u0438 \u0441\u0442\u0430\u0442\u044c\u0438.<\/a> <\/p>\n<pre><code class=\"python\">import numpy as np import pandas as pd<\/code><\/pre>\n<pre><code class=\"python\">k = 10 # \u043c\u0430\u043a\u0441\u0438\u043c\u0430\u043b\u044c\u043d\u0430\u044f \u043e\u0446\u0435\u043d\u043a\u0430  movies = ['\u0424\u0430\u043d\u0442\u0430\u0437\u0438\u044f', '\u0412\u0410\u041b\u041b-\u0418', '\u041f\u0438\u043d\u043e\u043a\u043a\u0438\u043e', '\u0411\u0435\u043c\u0431\u0438' , '\u0428\u0440\u044d\u043a', '\u0414\u0430\u043c\u0431\u043e', '\u0421\u043f\u0430\u0441\u0430\u0442\u0435\u043b\u0438', '\u0413\u0435\u0440\u043a\u0443\u043b\u0435\u0441', '\u041a\u0443\u043d\u0433-\u0444\u0443 \u041f\u0430\u043d\u0434\u0430'] m_movies = len(movies)  users = ['\u0410\u043d\u0434\u0440\u0435\u0439', '\u0410\u043d\u044f', '\u0410\u043b\u0438\u0441\u0430', '\u0412\u0430\u043d\u044f', '\u041b\u0435\u0448\u0430', '\u041e\u043a\u0441\u0430\u043d\u0430', '\u0421\u0430\u0448\u0430', '\u041f\u0430\u0448\u0430', '\u0421\u0435\u043d\u044f', '\u0413\u0440\u0438\u0448\u0430']         n_users = len(users)<\/code><\/pre>\n<p>\u0421\u043e\u0437\u0434\u0430\u043d\u0438\u043c \u0440\u0435\u0439\u0442\u0438\u043d\u0433\u0438 R_train \u0441\u043b\u0443\u0447\u0430\u0439\u043d\u044b\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c<\/p>\n<pre><code class=\"python\">np.random.seed(42)  N = np.random.randint(50, 60) # \u0441\u043a\u043e\u043b\u044c\u043a\u043e \u043e\u0446\u0435\u043d\u043e\u043a \u0431\u0443\u0434\u0435\u0442 \u043f\u043e\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u043e  ind_users, ind_movies, rating = [], [], [] user_movie = [] # \u0447\u0442\u043e\u0431\u044b \u043f\u0430\u0440\u0430 user-movie \u043d\u0435 \u043f\u043e\u0432\u0442\u043e\u0440\u044f\u043b\u0438\u0441\u044c  for _ in range(N):     user = np.random.randint(0, n_users)     movie = np.random.randint(0, m_movies)     if not [user, movie] in user_movie:         ind_users.append(user)         ind_movies.append(movie)         rating.append(np.random.randint(1, k)) # \u0441\u043b\u0443\u0447\u0430\u0439\u043d\u0430\u044f \u043e\u0446\u0435\u043d\u043a\u0430 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f \u0444\u0438\u043b\u044c\u043c\u0443         user_movie.append([user, movie])         N = len(user_movie)  data = {'userId': ind_users, 'movieId': ind_movies, 'rating': rating} R_train = pd.DataFrame(data = data) R_train.head(3)<\/code><\/pre>\n<figure class=\"\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/4ff\/fbb\/eba\/4fffbbeba4e3511dc9a3ae3116e9c334.png\" width=\"239\" height=\"160\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/4ff\/fbb\/eba\/4fffbbeba4e3511dc9a3ae3116e9c334.png\"\/><\/figure>\n<p>\u041f\u043e\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u043a\u0430\u043a \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 User-item matrix<\/p>\n<pre><code class=\"python\">User_item_matrix = R_train.pivot(columns = 'movieId', index = 'userId', values = 'rating') User_item_matrix.rename(columns = dict(zip(User_item_matrix.columns, movies)), inplace = True) User_item_matrix.set_index(pd.Index(users), inplace=True) User_item_matrix<\/code><\/pre>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/792\/654\/fb7\/792654fb71cd1393e559c9161f12d5c8.png\" width=\"887\" height=\"403\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/792\/654\/fb7\/792654fb71cd1393e559c9161f12d5c8.png\"\/><\/figure>\n<p>\u041d\u0430\u0439\u0434\u0435\u043c \u0441\u0440\u0435\u0434\u043d\u0435\u0435 \u043f\u043e \u0432\u0441\u0435\u043c \u0440\u0435\u0439\u0442\u0438\u043d\u0433\u0430\u043c:<\/p>\n<pre><code class=\"python\">mu = R_train['rating'].mean() mu  5.441860465116279<\/code><\/pre>\n<p>\u0418\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0438\u0440\u0443\u0435\u043c \u0441\u043c\u0435\u0449\u0435\u043d\u0438\u0435, \u0432\u043d\u043e\u0441\u0438\u043c\u043e\u0435 \u0444\u0438\u043b\u044c\u043c\u0430\u043c\u0438 \u0438 &#171;\u043f\u0440\u0435\u0434\u0432\u0437\u044f\u0442\u043e\u0441\u0442\u044c&#187; \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0435\u0439<\/p>\n<pre><code class=\"python\">bu = np.zeros(n_users) bm = np.zeros(m_movies) print(bu.shape, bm.shape)  (10,) (9,)<\/code><\/pre>\n<p>\u0418\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0438\u0440\u0443\u0435\u043c \u0441\u043a\u0440\u044b\u0442\u044b\u0435 \u0444\u0430\u043a\u0442\u043e\u0440\u044b \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0435\u0439 \u0438 \u0441\u043a\u0440\u044b\u0442\u044b\u0435 \u0444\u0430\u043a\u0442\u043e\u0440\u044b \u0444\u0438\u043b\u044c\u043c\u043e\u0432<\/p>\n<pre><code class=\"python\">d = 5  # \u0433\u043b\u0430\u0432\u043d\u044b\u0445 \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442 pu = np.random.normal(0, 0.1, (n_users, d)) qm = np.random.normal(0, 0.1, (m_movies, d)) print(pu.shape, qm.shape)  (10, 9) (9, 9)<\/code><\/pre>\n<p>\u0413\u0440\u0430\u0434\u0438\u0435\u043d\u0442\u043d\u044b\u0439 \u0441\u043f\u0443\u0441\u043a<\/p>\n<pre><code class=\"python\">epoch = 5 gamma = 0.02 lmbda = 0.03  for _ in range(epoch):          for index in range(R_train.shape[0]):          user_id = R_train['userId'][index]          movie_id = R_train['movieId'][index]          rating = R_train['rating'][index]          err = rating - (mu + bu[user_id] + bm[movie_id] + qm[movie_id] @ pu[user_id])          bu[user_id] += gamma * (err - lmbda * bu[user_id])          bm[movie_id] += gamma * (err - lmbda * bm[movie_id])          pu[user_id] += gamma * (err * qm[movie_id] - lmbda * pu[user_id])         qm[movie_id] += gamma * (err * pu[user_id] - lmbda * qm[movie_id])<\/code><\/pre>\n<p>\u041f\u043e\u0441\u0447\u0438\u0442\u0430\u0435\u043c \u043f\u0440\u0435\u0434\u0441\u043a\u0430\u0437\u0430\u043d\u0438\u044f \u0434\u043b\u044f \u0432\u0441\u0435\u0445 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0435\u0439 \u0438 \u0444\u0438\u043b\u044c\u043c\u043e\u0432:<\/p>\n<pre><code class=\"python\">R_pred = np.zeros((n_users, m_movies))  for user in range(n_users):     for movie in range(m_movies):         R_pred[user][movie] = round(mu + bu[user] + bm[movie] + qm[movie] @ pu[user], 2)  pd.DataFrame(R_pred, users, movies)<\/code><\/pre>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/27b\/900\/763\/27b900763ff119d8260a2d0235a7a35a.png\" width=\"903\" height=\"415\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/27b\/900\/763\/27b900763ff119d8260a2d0235a7a35a.png\"\/><\/figure>\n<p>\u041c\u043e\u0436\u043d\u043e \u0432\u043e\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c\u0441\u044f \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u043e\u0439 <a href=\"https:\/\/surprise.readthedocs.io\/en\/stable\/matrix_factorization.html#surprise.prediction_algorithms.matrix_factorization.SVD\" rel=\"noopener noreferrer nofollow\">scikit-surprise<\/a>.<\/p>\n<pre><code class=\"python\">from surprise import Reader, Dataset, SVD from surprise.model_selection import train_test_split from surprise import accuracy  # \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u0435 \u043e\u0431\u044a\u0435\u043a\u0442\u0430 \u043a\u043b\u0430\u0441\u0441\u0430 Reader reader = Reader(rating_scale=(1, 10))  # \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u0435 \u043e\u0431\u044a\u0435\u043a\u0442\u0430 \u043a\u043b\u0430\u0441\u0441\u0430 Dataset dataset = Dataset.load_from_df(R_train[['userId', 'movieId', 'rating']], reader)  # \u0440\u0430\u0437\u0431\u0438\u0435\u043d\u0438\u0435 \u0434\u0430\u043d\u043d\u044b\u0445 \u043d\u0430 \u043e\u0431\u0443\u0447\u0430\u044e\u0449\u0443\u044e \u0438 \u0442\u0435\u0441\u0442\u043e\u0432\u0443\u044e \u0432\u044b\u0431\u043e\u0440\u043a\u0438 trainset, testset = train_test_split(dataset, test_size = 0.1)  # \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u0435 \u044d\u043a\u0437\u0435\u043c\u043f\u043b\u044f\u0440\u0430 \u043a\u043b\u0430\u0441\u0441\u0430 SVD model = SVD()  # \u043e\u0431\u0443\u0447\u0435\u043d\u0438\u0435 \u043c\u043e\u0434\u0435\u043b\u0438 \u043d\u0430 \u043e\u0431\u0443\u0447\u0430\u044e\u0449\u0435\u0439 \u0432\u044b\u0431\u043e\u0440\u043a\u0435 model.fit(trainset)  # \u043f\u0440\u0435\u0434\u0441\u043a\u0430\u0437\u0430\u043d\u0438\u0435 \u0440\u0435\u0439\u0442\u0438\u043d\u0433\u043e\u0432 \u043d\u0430 \u0442\u0435\u0441\u0442\u043e\u0432\u043e\u0439 \u0432\u044b\u0431\u043e\u0440\u043a\u0435 predictions = model.test(testset)  # \u043e\u0446\u0435\u043d\u043a\u0430 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0430 \u043c\u043e\u0434\u0435\u043b\u0438 print('RMSE:', accuracy.rmse(predictions)) print('MAE:', accuracy.mae(predictions))  R_pred_surprise = np.zeros((n_users, m_movies)) for u in range(n_users):     for m in range(m_movies):         R_pred_surprise[u][m] = model.predict(u, m).est          pd.DataFrame(np.round(R_pred_surprise, 2), users, movies)<\/code><\/pre>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/6a8\/abc\/af8\/6a8abcaf84f18741450858965c50dc3b.png\" width=\"929\" height=\"413\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/6a8\/abc\/af8\/6a8abcaf84f18741450858965c50dc3b.png\"\/><\/figure>\n<p>\u0411\u044b\u0432\u0430\u0435\u0442 \u043f\u043e\u043b\u0435\u0437\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0438 \u0434\u0440\u0443\u0433\u0438\u0435 \u043c\u043e\u0434\u0438\u0444\u0438\u043a\u0430\u0446\u0438\u0438 \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u0430: <\/p>\n<h2>SVD++:<\/h2>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"formula\" source=\"r_{ij} = \\left( x_i + \\frac{1}{ \\sqrt{|{s|p_{is} \\neq 0} |} \\sum_{\\forall s|p_{is} \\neq 0} }{\\hat y_s} \\right) y_j + b_i + b_j + \\mu \" alt=\"r_{ij} = \\left( x_i + \\frac{1}{ \\sqrt{|{s|p_{is} \\neq 0} |} \\sum_{\\forall s|p_{is} \\neq 0} }{\\hat y_s} \\right) y_j + b_i + b_j + \\mu \" src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/7ec\/83d\/49a\/7ec83d49acf031daa88baef57df1b335.svg\" width=\"457\" height=\"63\"\/><\/p>\n<p>\u0433\u0434\u0435 <img loading=\"lazy\" decoding=\"async\" class=\"formula inline\" source=\"\\hat y_s\" alt=\"\\hat y_s\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/465\/592\/805\/4655928054988f29307d229a77eac136.svg\" width=\"19\" height=\"21\"\/> &#8212; \u0434\u0440\u0443\u0433\u043e\u0439 \u043d\u0430\u0431\u043e\u0440 \u0432\u0435\u043a\u0442\u043e\u0440\u043e\u0432, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0433\u043e\u0432\u043e\u0440\u0438\u0442, \u0447\u0442\u043e \u043d\u0430\u0434\u043e \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u043a \u0432\u0435\u043a\u0442\u043e\u0440\u0443 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0442\u0435\u043b\u044f, \u0435\u0441\u043b\u0438 \u0443 \u043d\u0435\u0433\u043e \u0432 \u0438\u0441\u0442\u043e\u0440\u0438\u0438 \u0431\u044b\u043b \u044d\u0442\u043e\u0442 \u0430\u0439\u0442\u043e\u043c.<\/p>\n<h2>timeSVD++:<\/h2>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"formula\" source=\"r_{ij}(t) = \\left( x_i(t) + \\frac{1}{ \\sqrt{|{s|p_{is} \\neq 0} |} \\sum_{\\forall s|p_{is} \\neq 0} }{\\hat y_s} \\right) y_j + b_i(t) + b_j(t) + \\mu\" alt=\"r_{ij}(t) = \\left( x_i(t) + \\frac{1}{ \\sqrt{|{s|p_{is} \\neq 0} |} \\sum_{\\forall s|p_{is} \\neq 0} }{\\hat y_s} \\right) y_j + b_i(t) + b_j(t) + \\mu\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/a65\/455\/15d\/a6545515de34726c1115d5f49f81c401.svg\" width=\"545\" height=\"63\"\/><\/p>\n<p>\u0414\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438 \u043e\u0442 \u0432\u0440\u0435\u043c\u0435\u043d\u0438 \u0431\u044b\u0432\u0430\u0435\u0442 \u043f\u043e\u043b\u0435\u0437\u043d\u043e, \u0435\u0441\u043b\u0438 \u0434\u0430\u043d\u043d\u044b\u0435 \u0440\u0430\u0441\u0442\u044f\u043d\u0443\u0442\u044b \u043d\u0430 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u043b\u0435\u0442 \u0438 \u0431\u043e\u043b\u0435\u0435, \u043a\u043e\u0433\u0434\u0430 \u0432\u043a\u0443\u0441\u044b \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f \u043c\u043e\u0433\u0443\u0442 \u043f\u043e\u043c\u0435\u043d\u044f\u0442\u044c\u0441\u044f (\u0438\u043d\u0430\u0447\u0435 \u043c\u043e\u0434\u0435\u043b\u044c\u043a\u0430 \u0431\u0443\u0434\u0435\u0442 \u0432\u044b\u0434\u0430\u0432\u0430\u0442\u044c \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u043e\u0435 &#171;\u0441\u0440\u0435\u0434\u043d\u0435\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u043f\u043e \u0432\u043a\u0443\u0441\u0443&#187;). <\/p>\n<p>\u0412\u0435\u043a\u0442\u043e\u0440 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f <img loading=\"lazy\" decoding=\"async\" class=\"formula inline\" source=\"x_i(t)\" alt=\"x_i(t)\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/75e\/5be\/951\/75e5be95148a44b91a74c65b3bb4e9a9.svg\" width=\"40\" height=\"22\"\/>\u043c\u043e\u0436\u043d\u043e \u043f\u043e\u0431\u0438\u0442\u044c \u043d\u0430 \u0431\u0438\u043d\u044b. \u0422\u043e\u0433\u0434\u0430 \u0432 \u0440\u0430\u0437\u043d\u044b\u0435 \u043c\u043e\u043c\u0435\u043d\u0442\u044b \u0432\u0440\u0435\u043c\u0435\u043d\u0438 \u043f\u043e\u043b\u0443\u0447\u0430\u044e\u0442\u0441\u044f \u0440\u0430\u0437\u043d\u044b\u0435 \u0432\u0435\u043a\u0442\u043e\u0440\u0430 (\u043e\u0434\u043d\u0430\u043a\u043e, \u0435\u0441\u043b\u0438 \u0432\u044b\u0431\u0440\u0430\u0442\u044c \u0431\u043e\u043b\u044c\u0448\u043e\u0435 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0431\u0438\u043d\u043e\u0432, \u043c\u043e\u0436\u043d\u043e \u043b\u0435\u0433\u043a\u043e \u043f\u0435\u0440\u0435\u043e\u0431\u0443\u0447\u0438\u0442\u044c\u0441\u044f). \u0422\u0430\u043a\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c, \u043c\u044b \u043d\u0435 \u0432\u044b\u0431\u0440\u0430\u0441\u044b\u0432\u0430\u0435\u043c \u0441\u0442\u0430\u0440\u044b\u0435 \u0432\u0437\u0430\u0438\u043c\u043e\u0434\u0435\u0439\u0441\u0442\u0432\u0438\u044f, \u0430 \u0443\u043b\u0443\u0447\u0448\u0430\u0435\u043c \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u0438\u044f \u043e\u0431 \u0430\u0439\u0442\u0435\u043c\u0430\u0445 (\u043f\u0440\u0438 \u0443\u0441\u043b\u043e\u0432\u0438\u0438 \u0447\u0442\u043e \u043e\u043d \u043d\u0435 \u043c\u0435\u043d\u044f\u043b\u0441\u044f), \u043d\u0435 \u0443\u0445\u0443\u0434\u0448\u0430\u044f \u0442\u0435\u043a\u0443\u0449\u0435\u0433\u043e \u043f\u043e\u043d\u0438\u043c\u0430\u043d\u0438\u044f \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f. <\/p>\n<hr\/>\n<p>\u0412 \u043a\u043e\u043d\u0446\u0435 \u0441\u043e\u0440\u0435\u0432\u043d\u043e\u0432\u0430\u043d\u0438\u044f Netflix \u0432\u044b\u043f\u043b\u0430\u0442\u0438\u043b \u043c\u0438\u043b\u043b\u0438\u043e\u043d \u0434\u043e\u043b\u043b\u0430\u0440\u043e\u0432 \u043f\u043e\u0431\u0435\u0434\u0438\u0442\u0435\u043b\u044f\u043c. \u041f\u043e\u0437\u0436\u0435, \u043e\u0440\u0433\u0430\u043d\u0438\u0437\u0430\u0442\u043e\u0440\u044b \u043a\u043e\u043d\u043a\u0443\u0440\u0441\u0430 \u043f\u0440\u0438\u0437\u043d\u0430\u043b\u0438\u0441\u044c, \u0447\u0442\u043e \u0437\u0430 \u0442\u0430\u043a\u0443\u044e \u043d\u0438\u0447\u0442\u043e\u0436\u043d\u0443\u044e \u0441\u0443\u043c\u043c\u0443 \u043e\u043d\u0438 \u043d\u0435 \u0441\u043c\u043e\u0433\u043b\u0438 \u0431\u044b \u0437\u0430\u0441\u0442\u0430\u0432\u0438\u0442\u044c \u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c \u0441\u0442\u043e\u043b\u044c\u043a\u043e \u0443\u0447\u0435\u043d\u044b\u0445 \u043f\u043e \u0432\u0441\u0435\u043c\u0443 \u043c\u0438\u0440\u0443 \u0446\u0435\u043b\u044b\u0445 \u0442\u0440\u0438 \u0433\u043e\u0434\u0430.<\/p>\n<p>\u041e\u0434\u043d\u0430\u043a\u043e, \u0431\u043b\u0430\u0433\u043e\u0434\u0430\u0440\u044f \u043a\u043e\u043d\u043a\u0443\u0440\u0441\u0443, \u043c\u044b \u0442\u0435\u043f\u0435\u0440\u044c \u0437\u043d\u0430\u0435\u043c \u0432\u0441\u0435 \u043e \u0440\u0430\u0437\u043b\u043e\u0436\u0435\u043d\u0438\u0438 user-item. \u0422\u0430\u043a\u0438\u0435 \u0437\u0430\u0434\u0430\u0447\u0438 \u043f\u0440\u0438\u043d\u044f\u0442\u043e \u043d\u0430\u0437\u044b\u0432\u0430\u0442\u044c 2D-\u0437\u0430\u0434\u0430\u0447\u0438, \u043f\u043e\u0442\u043e\u043c\u0443 \u0447\u0442\u043e  \u0438\u043c\u0435\u0435\u043c \u0434\u0430\u043d\u043d\u044b\u0435 \u043e \u0432\u0437\u0430\u0438\u043c\u043e\u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0438 \u0434\u0432\u0443\u0445 \u0440\u0430\u0437\u043d\u044b\u0445 \u043c\u043d\u043e\u0436\u0435\u0441\u0442\u0432.<\/p>\n<p>\u041d\u043e \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u0443\u0447\u0438\u0442\u044b\u0432\u0430\u0442\u044c, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0441\u0438\u0442\u0443\u0430\u0442\u0438\u0432\u043d\u044b\u0439 \u043a\u043e\u043d\u0442\u0435\u043a\u0441\u0442 (\u0435\u0441\u043b\u0438 \u043f\u043b\u0430\u043d\u0438\u0440\u0443\u0435\u0442\u0441\u044f \u0441\u0435\u043c\u0435\u0439\u043d\u044b\u0439 \u043f\u0440\u043e\u0441\u043c\u043e\u0442\u0440 \u0444\u0438\u043b\u044c\u043c\u0430 &#8212; \u044d\u0442\u043e \u043e\u0434\u0438\u043d \u0432\u0438\u0434 \u0440\u0435\u043a\u043e\u043c\u0435\u043d\u0434\u0430\u0446\u0438\u0439, \u0435\u0441\u043b\u0438 \u0441 \u0434\u0440\u0443\u0437\u044c\u044f\u043c\u0438 &#8212; \u0434\u0440\u0443\u0433\u043e\u0439, \u0435\u0441\u043b\u0438 \u043d\u0430\u0435\u0434\u0438\u043d\u0435 &#8212; \u0442\u0440\u0435\u0442\u0438\u0439 \u0438 \u0442\u0434), \u0442\u043e\u0433\u0434\u0430 \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u0433\u043e\u0432\u043e\u0440\u0438\u0442\u044c \u043e \u0431\u043e\u043b\u044c\u0448\u0438\u0445 \u0440\u0430\u0437\u043c\u0435\u0440\u043d\u043e\u0441\u0442\u044f\u0445 \u0434\u043b\u044f \u0434\u0430\u043d\u043d\u043e\u0439 \u0437\u0430\u0434\u0430\u0447\u0438. \u0421\u043e\u0432\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0435 \u0440\u0435\u043a\u043e\u043c\u0435\u043d\u0434\u0430\u0442\u0435\u043b\u044c\u043d\u044b\u0435 \u0441\u0438\u0441\u0442\u0435\u043c\u044b \u0443\u0445\u043e\u0434\u044f\u0442 \u0438\u043c\u0435\u043d\u043d\u043e \u0442\u0443\u0434\u0430: \u043a\u0430\u043a \u0440\u0435\u043a\u043e\u043c\u0435\u043d\u0434\u043e\u0432\u0430\u0442\u044c \u0432 \u0443\u0441\u043b\u043e\u0432\u0438\u044f\u0445 \u043a\u043e\u0433\u0434\u0430 \u0443 \u043d\u0430\u0441 \u043c\u043d\u043e\u0433\u043e \u0440\u0430\u0437\u043d\u043e\u043e\u0431\u0440\u0430\u0437\u043d\u043e\u0439 \u0440\u0430\u0437\u043d\u043e\u0440\u043e\u0434\u043d\u043e\u0439 \u0434\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0439 \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u0438.<\/p>\n<\/p>\n<\/div>\n<\/div>\n<\/div>\n<p><!----><!----><\/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\/articles\/754744\/\"> https:\/\/habr.com\/ru\/articles\/754744\/<\/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<figure class=\"full-width\"><\/figure>\n<p>\u0414\u0430\u043d\u043d\u0430\u044f \u0441\u0442\u0430\u0442\u044c\u044f \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043f\u0440\u043e\u0434\u043e\u043b\u0436\u0435\u043d\u0438\u0435\u043c &#171;<a href=\"https:\/\/habr.com\/ru\/articles\/751470\/\" rel=\"noopener noreferrer nofollow\">\u0420\u0435\u043a\u043e\u043c\u0435\u043d\u0434\u0430\u0442\u0435\u043b\u044c\u043d\u0430\u044f \u0441\u0438\u0441\u0442\u0435\u043c\u0430 SVD<\/a>&#171;. \u0415\u0441\u043b\u0438 \u0432\u0430\u043c \u043d\u0435 \u0437\u043d\u0430\u043a\u043e\u043c\u0430 \u0442\u0435\u0440\u043c\u0438\u043d\u043e\u043b\u043e\u0433\u0438\u044f (user-item matrix, SVD-\u0440\u0430\u0437\u043b\u043e\u0436\u0435\u043d\u0438\u0435, PCA, \u043c\u0435\u0442\u043e\u0434 \u0433\u043b\u0430\u0432\u043d\u044b\u0445 \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442 \u0438 \u043f\u0440.), \u0442\u043e \u0440\u0435\u043a\u043e\u043c\u0435\u043d\u0434\u0443\u044e \u043f\u0440\u0435\u0436\u0434\u0435 \u043f\u0440\u043e\u0447\u0438\u0442\u0430\u0442\u044c \u043f\u0435\u0440\u0432\u0443\u044e \u0447\u0430\u0441\u0442\u044c. <\/p>\n<p><a href=\"https:\/\/ru.wikipedia.org\/wiki\/Netflix_Prize\" rel=\"noopener noreferrer nofollow\"><u>Netflix Prize<\/u><\/a>\u00a0&#8212; \u043e\u0434\u043d\u043e \u0438\u0437 \u0441\u0430\u043c\u044b\u0445 \u0438\u0437\u0432\u0435\u0441\u0442\u043d\u044b\u0445 \u0441\u043e\u0440\u0435\u0432\u043d\u043e\u0432\u0430\u043d\u0438\u0439 \u0432 \u043e\u0431\u043b\u0430\u0441\u0442\u0438 \u043c\u0430\u0448\u0438\u043d\u043d\u043e\u0433\u043e \u043e\u0431\u0443\u0447\u0435\u043d\u0438\u044f. \u0426\u0435\u043b\u044c\u044e \u0431\u044b\u043b\u043e \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u0435 \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u0430, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0443\u043b\u0443\u0447\u0448\u0430\u043b \u0431\u044b \u0440\u0435\u043a\u043e\u043c\u0435\u043d\u0434\u0430\u0446\u0438\u0438 \u0444\u0438\u043b\u044c\u043c\u043e\u0432 \u0438 \u0442\u0435\u043b\u0435\u0448\u043e\u0443 \u043d\u0430 10%.<\/p>\n<p>\u041e\u0434\u0438\u043d \u0438\u0437 \u043d\u0430\u0438\u0431\u043e\u043b\u0435\u0435 \u0443\u0441\u043f\u0435\u0448\u043d\u044b\u0445 \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u043e\u0432 \u0431\u044b\u043b \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c<a href=\"https:\/\/en.wikipedia.org\/wiki\/Matrix_factorization_(recommender_systems)\" rel=\"noopener noreferrer nofollow\"> \u0421\u0430\u0439\u043c\u043e\u043d\u0430 \u0424\u0430\u043d\u043a\u0430<\/a>, \u043e\u0441\u043d\u043e\u0432\u043d\u043e\u0439 \u0438\u0434\u0435\u0435\u0439 \u043a\u043e\u0442\u043e\u0440\u043e\u0433\u043e \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043c\u0430\u0442\u0440\u0438\u0447\u043d\u0430\u044f \u0444\u0430\u043a\u0442\u043e\u0440\u0438\u0437\u0430\u0446\u0438\u044f. <\/p>\n<p>\u041c\u0430\u0442\u0440\u0438\u0447\u043d\u0430\u044f \u0444\u0430\u043a\u0442\u043e\u0440\u0438\u0437\u0430\u0446\u0438\u044f &#8212; \u0440\u0430\u0437\u043b\u043e\u0436\u0435\u043d\u0438\u0435 \u043c\u0430\u0442\u0440\u0438\u0446\u044b \u043d\u0430 \u043f\u0440\u043e\u0438\u0437\u0432\u0435\u0434\u0435\u043d\u0438\u0435 \u0434\u0432\u0443\u0445 \u0438\u043b\u0438 \u0431\u043e\u043b\u0435\u0435 \u043c\u0430\u0442\u0440\u0438\u0446. \u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, SVD-\u0440\u0430\u0437\u043b\u043e\u0436\u0435\u043d\u0438\u0435.<\/p>\n<p>\u041f\u0443\u0441\u0442\u044c \u0443 \u043d\u0430\u0441 \u0438\u043c\u0435\u0435\u0442\u0441\u044f \u043c\u0430\u0442\u0440\u0438\u0446\u0430 \u0440\u0435\u0439\u0442\u0438\u043d\u0433\u043e\u0432 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0435\u0439  (\u0440\u0430\u0437\u0440\u044f\u0436\u0435\u043d\u043d\u0430\u044f <a href=\"https:\/\/habr.com\/ru\/articles\/751470\/#:~:text=User%2Ditem%20matrix,%D0%B8%20%D1%80%D0%B0%D0%B7%D1%80%D1%8F%D0%B6%D0%B5%D0%BD%D0%BD%D0%B0%D1%8F%20%D0%BC%D0%B0%D1%82%D1%80%D0%B8%D1%86%D0%B0.\" rel=\"noopener noreferrer nofollow\">user-item matrix<\/a>). &#8212; \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u044b . \u041e\u0431\u043e\u0437\u043d\u0430\u0447\u0438\u043c \u0447\u0435\u0440\u0435\u0437 &#8212; \u043f\u0440\u043e\u0433\u043d\u043e\u0437\u0438\u0440\u0443\u0435\u043c\u044b\u0435 \u0440\u0435\u0439\u0442\u0438\u043d\u0433\u0438 \u0438 &#8212; \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u044b . \u041f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u0438\u043c  \u043a\u0430\u043a \u043f\u0440\u043e\u0438\u0437\u0432\u0435\u0434\u0435\u043d\u0438\u0435 \u043c\u0430\u0442\u0440\u0438\u0446 \u043d\u0430 . \u041f\u043e\u0434\u0440\u0430\u0437\u0443\u043c\u0435\u0432\u0430\u0435\u0442\u0441\u044f, \u0447\u0442\u043e &#8212; <strong>\u0441\u043a\u0440\u044b\u0442\u044b\u0435<\/strong> \u0444\u0430\u043a\u0442\u043e\u0440\u044b \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f (<strong>user<\/strong>), &#8212; -\u0430\u044f \u0441\u0442\u0440\u043e\u043a\u0430. &#8212; <strong>\u0441\u043a\u0440\u044b\u0442\u044b\u0435<\/strong> \u0444\u0430\u043a\u0442\u043e\u0440\u044b \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u0430 (<strong>item<\/strong>), &#8212; -\u044b\u0439 \u0441\u0442\u043e\u043b\u0431\u0435\u0446 (\u0442\u0430\u043a\u0438\u0435 \u043c\u0435\u0442\u043e\u0434\u044b \u043d\u0430\u0437\u044b\u0432\u0430\u044e\u0442 <strong><em>Latent Models for Collaborative Filtering<\/em><\/strong>). \u0422\u043e\u0433\u0434\u0430 \u043f\u0440\u043e\u0433\u043d\u043e\u0437\u0438\u0440\u0443\u0435\u043c\u044b\u0439 \u0440\u0435\u0439\u0442\u0438\u043d\u0433 \u0434\u043b\u044f -\u0433\u043e \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f \u0438 -\u0433\u043e \u0442\u043e\u0432\u0430\u0440\u0430 \u0432\u044b\u0447\u0438\u0441\u043b\u044f\u0435\u0442\u0441\u044f \u043a\u0430\u043a \u0441\u043a\u0430\u043b\u044f\u0440\u043d\u043e\u0435 \u043f\u0440\u043e\u0438\u0437\u0432\u0435\u0434\u0435\u043d\u0438\u0435: .<\/p>\n<p>\u041e\u0431\u0443\u0447\u0435\u043d\u0438\u0435 \u0441\u043e\u0441\u0442\u043e\u0438\u0442 \u0432 \u043c\u0438\u043d\u0438\u043c\u0438\u0437\u0430\u0446\u0438\u0438 \u043a\u0432\u0430\u0434\u0440\u0430\u0442\u0438\u0447\u043d\u043e\u0439\u00a0\u043e\u0448\u0438\u0431\u043a\u0438:<\/p>\n<p>\u0433\u0434\u0435 &#8212; \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043a\u043e\u044d\u0444\u0444\u0438\u0446\u0438\u0435\u043d\u0442 (\u0433\u0438\u043f\u0435\u0440\u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440).<\/p>\n<p>\u041e\u0434\u043d\u0430\u043a\u043e, \u043f\u0440\u0438 \u043f\u0440\u043e\u0433\u043d\u043e\u0437\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0438 \u043e\u0446\u0435\u043d\u043e\u043a \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0443\u0447\u0438\u0442\u044b\u0432\u0430\u0442\u044c\u00a0<strong>\u043f\u0440\u0435\u0434\u0443\u0431\u0435\u0436\u0434\u0435\u043d\u0438\u044f<\/strong>\u00a0\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0435\u0439.<\/p>\n<p>\u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c, \u0432\u0435\u0440\u043e\u044f\u0442\u043d\u043e, \u043f\u043e\u0441\u0442\u0430\u0432\u0438\u0442 \u0431\u043e\u043b\u0435\u0435 \u0437\u0430\u0432\u044b\u0448\u0435\u043d\u043d\u0443\u044e \u043e\u0446\u0435\u043d\u043a\u0443 \u0444\u0438\u043b\u044c\u043c\u0443, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043f\u0440\u0438\u0437\u043d\u0430\u043d \u043a\u0430\u043a\u0438\u043c-\u0442\u043e \u0441\u043e\u043e\u0431\u0449\u0435\u0441\u0442\u0432\u043e\u043c. \u0412 \u0442\u043e \u0432\u0440\u0435\u043c\u044f \u043a\u0430\u043a \u043c\u0435\u043d\u0435\u0435 \u043f\u043e\u043f\u0443\u043b\u044f\u0440\u043d\u044b\u0439 \u0444\u0438\u043b\u044c\u043c \u043f\u043e\u043b\u0443\u0447\u0438\u0442 \u0431\u043e\u043b\u0435\u0435 \u0443\u043c\u0435\u0440\u0435\u043d\u043d\u0443\u044e \u043e\u0446\u0435\u043d\u043a\u0443.<\/p>\n<p>\u0418\u043b\u0438, \u043c\u043e\u0436\u043d\u043e \u0440\u0430\u0437\u0434\u0435\u043b\u0438\u0442\u044c \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0435\u0439 \u043d\u0430 \u0431\u043e\u043b\u0435\u0435 \u0438 \u043c\u0435\u043d\u0435\u0435 \u043a\u0440\u0438\u0442\u0438\u0447\u043d\u044b\u0445. \u041a\u0442\u043e-\u0442\u043e \u043b\u0435\u0433\u043a\u043e \u0441\u0442\u0430\u0432\u0438\u0442 \u0432\u044b\u0441\u043e\u043a\u0438\u0435 \u0440\u0435\u0439\u0442\u0438\u043d\u0433\u0438, \u043a\u0442\u043e-\u0442\u043e &#8212; \u043d\u0430\u043e\u0431\u043e\u0440\u043e\u0442.<\/p>\n<p>\u042d\u0442\u0438 \u0441\u043c\u0435\u0449\u0435\u043d\u0438\u044f (\u043f\u0440\u0435\u0434\u0443\u0431\u0435\u0436\u0434\u0435\u043d\u0438\u044f) \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0443\u0447\u0438\u0442\u044b\u0432\u0430\u0442\u044c \u043f\u0440\u0438 \u043f\u0440\u043e\u0433\u043d\u043e\u0437\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0438.<\/p>\n<p>\u0412\u0432\u0435\u0434\u0435\u043c \u043d\u043e\u0432\u044b\u0435 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0435:<\/p>\n<ul>\n<li>\n<p>&#8212; \u0441\u0440\u0435\u0434\u043d\u0435\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u0431\u0430\u043b\u043b\u043e\u0432, \u0432\u044b\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u043d\u044b\u0445 \u043f\u043e \u0432\u0441\u0435\u043c items \u0432\u0441\u0435\u043c\u0438 users;<\/p>\n<\/li>\n<li>\n<p>&#8212; \u0441\u043c\u0435\u0449\u0435\u043d\u0438\u0435, \u0432\u043d\u043e\u0441\u0438\u043c\u043e\u0435 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u043e\u043c;<\/p>\n<\/li>\n<li>\n<p>&#8212; \u043f\u0440\u0435\u0434\u0432\u0437\u044f\u0442\u043e\u0441\u0442\u044c, \u0432\u043d\u0435\u0441\u0435\u043d\u043d\u0430\u044f \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0435\u043c;<\/p>\n<\/li>\n<\/ul>\n<p>\u0422\u043e\u0433\u0434\u0430, \u0441\u043a\u043e\u0440\u0440\u0435\u043a\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0439 \u043f\u0440\u043e\u0433\u043d\u043e\u0437 (\u0441 \u0443\u0447\u0435\u0442\u043e\u043c \u0441\u043c\u0435\u0449\u0435\u043d\u0438\u044f) :<\/p>\n<p>\u0412 \u0442\u0430\u043a\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u043c\u0438\u043d\u0438\u043c\u0438\u0437\u0438\u0440\u0443\u0435\u043c \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0439 \u0444\u0443\u043d\u043a\u0446\u0438\u043e\u043d\u0430\u043b:<\/p>\n<p>\u041e\u043f\u0442\u0438\u043c\u0430\u043b\u044c\u043d\u043e\u0435 \u0440\u0435\u0448\u0435\u043d\u0438\u0435 \u0431\u0443\u0434\u0435\u043c \u0438\u0441\u043a\u0430\u0442\u044c \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u0433\u0440\u0430\u0434\u0438\u0435\u043d\u0442\u043d\u043e\u0433\u043e \u0441\u043f\u0443\u0441\u043a\u0430.<\/p>\n<p>\u041e\u0448\u0438\u0431\u043a\u0443 \u043e\u0431\u043e\u0437\u043d\u0430\u0447\u0438\u043c \u043a\u0430\u043a <\/p>\n<p>\u0413\u0440\u0430\u0434\u0438\u0435\u043d\u0442\u044b \u043f\u043e , , , :<\/p>\n<\/p>\n<\/p>\n<p>\u0422\u043e\u0433\u0434\u0430 \u0433\u0440\u0430\u0434\u0438\u0435\u043d\u0442\u043d\u044b\u0439 \u0448\u0430\u0433 \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0435\u0442\u0441\u044f \u043f\u043e \u0444\u043e\u0440\u043c\u0443\u043b\u0430\u043c:<\/p>\n<\/p>\n<\/p>\n<p>\u0433\u0434\u0435  &#8212; \u043a\u043e\u044d\u0444\u0444\u0438\u0446\u0438\u0435\u043d\u0442 \u0441\u043a\u043e\u0440\u043e\u0441\u0442\u0438 \u043e\u0431\u0443\u0447\u0435\u043d\u0438\u044f <strong><em>learning rate<\/em><\/strong> (\u0433\u0438\u043f\u0435\u0440\u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440).<\/p>\n<p>\u0420\u0435\u0430\u043b\u0438\u0437\u0443\u0435\u043c \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c. <\/p>\n<p>\u0414\u0430\u043d\u043d\u044b\u0435 \u0432\u043e\u0437\u044c\u043c\u0435\u043c \u0438\u0437 <a href=\"https:\/\/habr.com\/ru\/articles\/751470\/#:~:text=%D0%97%D0%B0%D0%B4%D0%B0%D0%B4%D0%B8%D0%BC%20%D0%BF%D0%BE%D0%BB%D1%8C%D0%B7%D0%BE%D0%B2%D0%B0%D1%82%D0%B5%D0%BB%D0%B5%D0%B9%20%D0%B8%20%D1%84%D0%B8%D0%BB%D1%8C%D0%BC%D1%8B%3A\" rel=\"noopener noreferrer nofollow\">\u043f\u0435\u0440\u0432\u043e\u0439 \u0447\u0430\u0441\u0442\u0438 \u0441\u0442\u0430\u0442\u044c\u0438.<\/a> <\/p>\n<pre><code class=\"python\">import numpy as np import pandas as pd<\/code><\/pre>\n<pre><code class=\"python\">k = 10 # \u043c\u0430\u043a\u0441\u0438\u043c\u0430\u043b\u044c\u043d\u0430\u044f \u043e\u0446\u0435\u043d\u043a\u0430  movies = ['\u0424\u0430\u043d\u0442\u0430\u0437\u0438\u044f', '\u0412\u0410\u041b\u041b-\u0418', '\u041f\u0438\u043d\u043e\u043a\u043a\u0438\u043e', '\u0411\u0435\u043c\u0431\u0438' , '\u0428\u0440\u044d\u043a', '\u0414\u0430\u043c\u0431\u043e', '\u0421\u043f\u0430\u0441\u0430\u0442\u0435\u043b\u0438', '\u0413\u0435\u0440\u043a\u0443\u043b\u0435\u0441', '\u041a\u0443\u043d\u0433-\u0444\u0443 \u041f\u0430\u043d\u0434\u0430'] m_movies = len(movies)  users = ['\u0410\u043d\u0434\u0440\u0435\u0439', '\u0410\u043d\u044f', '\u0410\u043b\u0438\u0441\u0430', '\u0412\u0430\u043d\u044f', '\u041b\u0435\u0448\u0430', '\u041e\u043a\u0441\u0430\u043d\u0430', '\u0421\u0430\u0448\u0430', '\u041f\u0430\u0448\u0430', '\u0421\u0435\u043d\u044f', '\u0413\u0440\u0438\u0448\u0430']         n_users = len(users)<\/code><\/pre>\n<p>\u0421\u043e\u0437\u0434\u0430\u043d\u0438\u043c \u0440\u0435\u0439\u0442\u0438\u043d\u0433\u0438 R_train \u0441\u043b\u0443\u0447\u0430\u0439\u043d\u044b\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c<\/p>\n<pre><code class=\"python\">np.random.seed(42)  N = np.random.randint(50, 60) # \u0441\u043a\u043e\u043b\u044c\u043a\u043e \u043e\u0446\u0435\u043d\u043e\u043a \u0431\u0443\u0434\u0435\u0442 \u043f\u043e\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u043e  ind_users, ind_movies, rating = [], [], [] user_movie = [] # \u0447\u0442\u043e\u0431\u044b \u043f\u0430\u0440\u0430 user-movie \u043d\u0435 \u043f\u043e\u0432\u0442\u043e\u0440\u044f\u043b\u0438\u0441\u044c  for _ in range(N):     user = np.random.randint(0, n_users)     movie = np.random.randint(0, m_movies)     if not [user, movie] in user_movie:         ind_users.append(user)         ind_movies.append(movie)         rating.append(np.random.randint(1, k)) # \u0441\u043b\u0443\u0447\u0430\u0439\u043d\u0430\u044f \u043e\u0446\u0435\u043d\u043a\u0430 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f \u0444\u0438\u043b\u044c\u043c\u0443         user_movie.append([user, movie])         N = len(user_movie)  data = {'userId': ind_users, 'movieId': ind_movies, 'rating': rating} R_train = pd.DataFrame(data = data) R_train.head(3)<\/code><\/pre>\n<figure class=\"\"><\/figure>\n<p>\u041f\u043e\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u043a\u0430\u043a \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 User-item matrix<\/p>\n<pre><code class=\"python\">User_item_matrix = R_train.pivot(columns = 'movieId', index = 'userId', values = 'rating') User_item_matrix.rename(columns = dict(zip(User_item_matrix.columns, movies)), inplace = True) User_item_matrix.set_index(pd.Index(users), inplace=True) User_item_matrix<\/code><\/pre>\n<figure class=\"full-width\"><\/figure>\n<p>\u041d\u0430\u0439\u0434\u0435\u043c \u0441\u0440\u0435\u0434\u043d\u0435\u0435 \u043f\u043e \u0432\u0441\u0435\u043c \u0440\u0435\u0439\u0442\u0438\u043d\u0433\u0430\u043c:<\/p>\n<pre><code class=\"python\">mu = R_train['rating'].mean() mu  5.441860465116279<\/code><\/pre>\n<p>\u0418\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0438\u0440\u0443\u0435\u043c \u0441\u043c\u0435\u0449\u0435\u043d\u0438\u0435, \u0432\u043d\u043e\u0441\u0438\u043c\u043e\u0435 \u0444\u0438\u043b\u044c\u043c\u0430\u043c\u0438 \u0438 &#171;\u043f\u0440\u0435\u0434\u0432\u0437\u044f\u0442\u043e\u0441\u0442\u044c&#187; \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0435\u0439<\/p>\n<pre><code class=\"python\">bu = np.zeros(n_users) bm = np.zeros(m_movies) print(bu.shape, bm.shape)  (10,) (9,)<\/code><\/pre>\n<p>\u0418\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0438\u0440\u0443\u0435\u043c \u0441\u043a\u0440\u044b\u0442\u044b\u0435 \u0444\u0430\u043a\u0442\u043e\u0440\u044b \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0435\u0439 \u0438 \u0441\u043a\u0440\u044b\u0442\u044b\u0435 \u0444\u0430\u043a\u0442\u043e\u0440\u044b \u0444\u0438\u043b\u044c\u043c\u043e\u0432<\/p>\n<pre><code class=\"python\">d = 5  # \u0433\u043b\u0430\u0432\u043d\u044b\u0445 \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442 pu = np.random.normal(0, 0.1, (n_users, d)) qm = np.random.normal(0, 0.1, (m_movies, d)) print(pu.shape, qm.shape)  (10, 9) (9, 9)<\/code><\/pre>\n<p>\u0413\u0440\u0430\u0434\u0438\u0435\u043d\u0442\u043d\u044b\u0439 \u0441\u043f\u0443\u0441\u043a<\/p>\n<pre><code class=\"python\">epoch = 5 gamma = 0.02 lmbda = 0.03  for _ in range(epoch):          for index in range(R_train.shape[0]):          user_id = R_train['userId'][index]          movie_id = R_train['movieId'][index]          rating = R_train['rating'][index]          err = rating - (mu + bu[user_id] + bm[movie_id] + qm[movie_id] @ pu[user_id])          bu[user_id] += gamma * (err - lmbda * bu[user_id])          bm[movie_id] += gamma * (err - lmbda * bm[movie_id])          pu[user_id] += gamma * (err * qm[movie_id] - lmbda * pu[user_id])         qm[movie_id] += gamma * (err * pu[user_id] - lmbda * qm[movie_id])<\/code><\/pre>\n<p>\u041f\u043e\u0441\u0447\u0438\u0442\u0430\u0435\u043c \u043f\u0440\u0435\u0434\u0441\u043a\u0430\u0437\u0430\u043d\u0438\u044f \u0434\u043b\u044f \u0432\u0441\u0435\u0445 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0435\u0439 \u0438 \u0444\u0438\u043b\u044c\u043c\u043e\u0432:<\/p>\n<pre><code class=\"python\">R_pred = np.zeros((n_users, m_movies))  for user in range(n_users):     for movie in range(m_movies):         R_pred[user][movie] = round(mu + bu[user] + bm[movie] + qm[movie] @ pu[user], 2)  pd.DataFrame(R_pred, users, movies)<\/code><\/pre>\n<figure class=\"full-width\"><\/figure>\n<p>\u041c\u043e\u0436\u043d\u043e \u0432\u043e\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c\u0441\u044f \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u043e\u0439 <a href=\"https:\/\/surprise.readthedocs.io\/en\/stable\/matrix_factorization.html#surprise.prediction_algorithms.matrix_factorization.SVD\" rel=\"noopener noreferrer nofollow\">scikit-surprise<\/a>.<\/p>\n<pre><code class=\"python\">from surprise import Reader, Dataset, SVD from surprise.model_selection import train_test_split from surprise import accuracy  # \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u0435 \u043e\u0431\u044a\u0435\u043a\u0442\u0430 \u043a\u043b\u0430\u0441\u0441\u0430 Reader reader = Reader(rating_scale=(1, 10))  # \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u0435 \u043e\u0431\u044a\u0435\u043a\u0442\u0430 \u043a\u043b\u0430\u0441\u0441\u0430 Dataset dataset = Dataset.load_from_df(R_train[['userId', 'movieId', 'rating']], reader)  # \u0440\u0430\u0437\u0431\u0438\u0435\u043d\u0438\u0435 \u0434\u0430\u043d\u043d\u044b\u0445 \u043d\u0430 \u043e\u0431\u0443\u0447\u0430\u044e\u0449\u0443\u044e \u0438 \u0442\u0435\u0441\u0442\u043e\u0432\u0443\u044e \u0432\u044b\u0431\u043e\u0440\u043a\u0438 trainset, testset = train_test_split(dataset, test_size = 0.1)  # \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u0435 \u044d\u043a\u0437\u0435\u043c\u043f\u043b\u044f\u0440\u0430 \u043a\u043b\u0430\u0441\u0441\u0430 SVD model = SVD()  # \u043e\u0431\u0443\u0447\u0435\u043d\u0438\u0435 \u043c\u043e\u0434\u0435\u043b\u0438 \u043d\u0430 \u043e\u0431\u0443\u0447\u0430\u044e\u0449\u0435\u0439 \u0432\u044b\u0431\u043e\u0440\u043a\u0435 model.fit(trainset)  # \u043f\u0440\u0435\u0434\u0441\u043a\u0430\u0437\u0430\u043d\u0438\u0435 \u0440\u0435\u0439\u0442\u0438\u043d\u0433\u043e\u0432 \u043d\u0430 \u0442\u0435\u0441\u0442\u043e\u0432\u043e\u0439 \u0432\u044b\u0431\u043e\u0440\u043a\u0435 predictions = model.test(testset)  # \u043e\u0446\u0435\u043d\u043a\u0430 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0430 \u043c\u043e\u0434\u0435\u043b\u0438 print('RMSE:', accuracy.rmse(predictions)) print('MAE:', accuracy.mae(predictions))  R_pred_surprise = np.zeros((n_users, m_movies)) for u in range(n_users):     for m in range(m_movies):         R_pred_surprise[u][m] = model.predict(u, m).est          pd.DataFrame(np.round(R_pred_surprise, 2), users, movies)<\/code><\/pre>\n<figure class=\"full-width\"><\/figure>\n<p>\u0411\u044b\u0432\u0430\u0435\u0442 \u043f\u043e\u043b\u0435\u0437\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0438 \u0434\u0440\u0443\u0433\u0438\u0435 \u043c\u043e\u0434\u0438\u0444\u0438\u043a\u0430\u0446\u0438\u0438 \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u0430: <\/p>\n<h2>SVD++:<\/h2>\n<p>\u0433\u0434\u0435  &#8212; \u0434\u0440\u0443\u0433\u043e\u0439 \u043d\u0430\u0431\u043e\u0440 \u0432\u0435\u043a\u0442\u043e\u0440\u043e\u0432, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0433\u043e\u0432\u043e\u0440\u0438\u0442, \u0447\u0442\u043e \u043d\u0430\u0434\u043e \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u043a \u0432\u0435\u043a\u0442\u043e\u0440\u0443 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0442\u0435\u043b\u044f, \u0435\u0441\u043b\u0438 \u0443 \u043d\u0435\u0433\u043e \u0432 \u0438\u0441\u0442\u043e\u0440\u0438\u0438 \u0431\u044b\u043b \u044d\u0442\u043e\u0442 \u0430\u0439\u0442\u043e\u043c.<\/p>\n<h2>timeSVD++:<\/h2>\n<p>\u0414\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438 \u043e\u0442 \u0432\u0440\u0435\u043c\u0435\u043d\u0438 \u0431\u044b\u0432\u0430\u0435\u0442 \u043f\u043e\u043b\u0435\u0437\u043d\u043e, \u0435\u0441\u043b\u0438 \u0434\u0430\u043d\u043d\u044b\u0435 \u0440\u0430\u0441\u0442\u044f\u043d\u0443\u0442\u044b \u043d\u0430 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u043b\u0435\u0442 \u0438 \u0431\u043e\u043b\u0435\u0435, \u043a\u043e\u0433\u0434\u0430 \u0432\u043a\u0443\u0441\u044b \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f \u043c\u043e\u0433\u0443\u0442 \u043f\u043e\u043c\u0435\u043d\u044f\u0442\u044c\u0441\u044f (\u0438\u043d\u0430\u0447\u0435 \u043c\u043e\u0434\u0435\u043b\u044c\u043a\u0430 \u0431\u0443\u0434\u0435\u0442 \u0432\u044b\u0434\u0430\u0432\u0430\u0442\u044c \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u043e\u0435 &#171;\u0441\u0440\u0435\u0434\u043d\u0435\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u043f\u043e \u0432\u043a\u0443\u0441\u0443&#187;). <\/p>\n<p>\u0412\u0435\u043a\u0442\u043e\u0440 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f \u043c\u043e\u0436\u043d\u043e \u043f\u043e\u0431\u0438\u0442\u044c \u043d\u0430 \u0431\u0438\u043d\u044b. \u0422\u043e\u0433\u0434\u0430 \u0432 \u0440\u0430\u0437\u043d\u044b\u0435 \u043c\u043e\u043c\u0435\u043d\u0442\u044b \u0432\u0440\u0435\u043c\u0435\u043d\u0438 \u043f\u043e\u043b\u0443\u0447\u0430\u044e\u0442\u0441\u044f \u0440\u0430\u0437\u043d\u044b\u0435 \u0432\u0435\u043a\u0442\u043e\u0440\u0430 (\u043e\u0434\u043d\u0430\u043a\u043e, \u0435\u0441\u043b\u0438 \u0432\u044b\u0431\u0440\u0430\u0442\u044c \u0431\u043e\u043b\u044c\u0448\u043e\u0435 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0431\u0438\u043d\u043e\u0432, \u043c\u043e\u0436\u043d\u043e \u043b\u0435\u0433\u043a\u043e \u043f\u0435\u0440\u0435\u043e\u0431\u0443\u0447\u0438\u0442\u044c\u0441\u044f). \u0422\u0430\u043a\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c, \u043c\u044b \u043d\u0435 \u0432\u044b\u0431\u0440\u0430\u0441\u044b\u0432\u0430\u0435\u043c \u0441\u0442\u0430\u0440\u044b\u0435 \u0432\u0437\u0430\u0438\u043c\u043e\u0434\u0435\u0439\u0441\u0442\u0432\u0438\u044f, \u0430 \u0443\u043b\u0443\u0447\u0448\u0430\u0435\u043c \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u0438\u044f \u043e\u0431 \u0430\u0439\u0442\u0435\u043c\u0430\u0445 (\u043f\u0440\u0438 \u0443\u0441\u043b\u043e\u0432\u0438\u0438 \u0447\u0442\u043e \u043e\u043d \u043d\u0435 \u043c\u0435\u043d\u044f\u043b\u0441\u044f), \u043d\u0435 \u0443\u0445\u0443\u0434\u0448\u0430\u044f \u0442\u0435\u043a\u0443\u0449\u0435\u0433\u043e \u043f\u043e\u043d\u0438\u043c\u0430\u043d\u0438\u044f \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f. <\/p>\n<hr\/>\n<p>\u0412 \u043a\u043e\u043d\u0446\u0435 \u0441\u043e\u0440\u0435\u0432\u043d\u043e\u0432\u0430\u043d\u0438\u044f Netflix \u0432\u044b\u043f\u043b\u0430\u0442\u0438\u043b \u043c\u0438\u043b\u043b\u0438\u043e\u043d \u0434\u043e\u043b\u043b\u0430\u0440\u043e\u0432 \u043f\u043e\u0431\u0435\u0434\u0438\u0442\u0435\u043b\u044f\u043c. \u041f\u043e\u0437\u0436\u0435, \u043e\u0440\u0433\u0430\u043d\u0438\u0437\u0430\u0442\u043e\u0440\u044b \u043a\u043e\u043d\u043a\u0443\u0440\u0441\u0430 \u043f\u0440\u0438\u0437\u043d\u0430\u043b\u0438\u0441\u044c, \u0447\u0442\u043e \u0437\u0430 \u0442\u0430\u043a\u0443\u044e \u043d\u0438\u0447\u0442\u043e\u0436\u043d\u0443\u044e \u0441\u0443\u043c\u043c\u0443 \u043e\u043d\u0438 \u043d\u0435 \u0441\u043c\u043e\u0433\u043b\u0438 \u0431\u044b \u0437\u0430\u0441\u0442\u0430\u0432\u0438\u0442\u044c \u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c \u0441\u0442\u043e\u043b\u044c\u043a\u043e \u0443\u0447\u0435\u043d\u044b\u0445 \u043f\u043e \u0432\u0441\u0435\u043c\u0443 \u043c\u0438\u0440\u0443 \u0446\u0435\u043b\u044b\u0445 \u0442\u0440\u0438 \u0433\u043e\u0434\u0430.<\/p>\n<p>\u041e\u0434\u043d\u0430\u043a\u043e, \u0431\u043b\u0430\u0433\u043e\u0434\u0430\u0440\u044f \u043a\u043e\u043d\u043a\u0443\u0440\u0441\u0443, \u043c\u044b \u0442\u0435\u043f\u0435\u0440\u044c \u0437\u043d\u0430\u0435\u043c \u0432\u0441\u0435 \u043e \u0440\u0430\u0437\u043b\u043e\u0436\u0435\u043d\u0438\u0438 user-item. \u0422\u0430\u043a\u0438\u0435 \u0437\u0430\u0434\u0430\u0447\u0438 \u043f\u0440\u0438\u043d\u044f\u0442\u043e \u043d\u0430\u0437\u044b\u0432\u0430\u0442\u044c 2D-\u0437\u0430\u0434\u0430\u0447\u0438, \u043f\u043e\u0442\u043e\u043c\u0443 \u0447\u0442\u043e  \u0438\u043c\u0435\u0435\u043c \u0434\u0430\u043d\u043d\u044b\u0435 \u043e \u0432\u0437\u0430\u0438\u043c\u043e\u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0438 \u0434\u0432\u0443\u0445 \u0440\u0430\u0437\u043d\u044b\u0445 \u043c\u043d\u043e\u0436\u0435\u0441\u0442\u0432.<\/p>\n<p>\u041d\u043e \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u0443\u0447\u0438\u0442\u044b\u0432\u0430\u0442\u044c, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0441\u0438\u0442\u0443\u0430\u0442\u0438\u0432\u043d\u044b\u0439 \u043a\u043e\u043d\u0442\u0435\u043a\u0441\u0442 (\u0435\u0441\u043b\u0438 \u043f\u043b\u0430\u043d\u0438\u0440\u0443\u0435\u0442\u0441\u044f \u0441\u0435\u043c\u0435\u0439\u043d\u044b\u0439 \u043f\u0440\u043e\u0441\u043c\u043e\u0442\u0440 \u0444\u0438\u043b\u044c\u043c\u0430 &#8212; \u044d\u0442\u043e \u043e\u0434\u0438\u043d \u0432\u0438\u0434 \u0440\u0435\u043a\u043e\u043c\u0435\u043d\u0434\u0430\u0446\u0438\u0439, \u0435\u0441\u043b\u0438 \u0441 \u0434\u0440\u0443\u0437\u044c\u044f\u043c\u0438 &#8212; \u0434\u0440\u0443\u0433\u043e\u0439, \u0435\u0441\u043b\u0438 \u043d\u0430\u0435\u0434\u0438\u043d\u0435 &#8212; \u0442\u0440\u0435\u0442\u0438\u0439 \u0438 \u0442\u0434), \u0442\u043e\u0433\u0434\u0430 \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u0433\u043e\u0432\u043e\u0440\u0438\u0442\u044c \u043e \u0431\u043e\u043b\u044c\u0448\u0438\u0445 \u0440\u0430\u0437\u043c\u0435\u0440\u043d\u043e\u0441\u0442\u044f\u0445 \u0434\u043b\u044f \u0434\u0430\u043d\u043d\u043e\u0439 \u0437\u0430\u0434\u0430\u0447\u0438. \u0421\u043e\u0432\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0435 \u0440\u0435\u043a\u043e\u043c\u0435\u043d\u0434\u0430\u0442\u0435\u043b\u044c\u043d\u044b\u0435 \u0441\u0438\u0441\u0442\u0435\u043c\u044b \u0443\u0445\u043e\u0434\u044f\u0442 \u0438\u043c\u0435\u043d\u043d\u043e \u0442\u0443\u0434\u0430: \u043a\u0430\u043a \u0440\u0435\u043a\u043e\u043c\u0435\u043d\u0434\u043e\u0432\u0430\u0442\u044c \u0432 \u0443\u0441\u043b\u043e\u0432\u0438\u044f\u0445 \u043a\u043e\u0433\u0434\u0430 \u0443 \u043d\u0430\u0441 \u043c\u043d\u043e\u0433\u043e \u0440\u0430\u0437\u043d\u043e\u043e\u0431\u0440\u0430\u0437\u043d\u043e\u0439 \u0440\u0430\u0437\u043d\u043e\u0440\u043e\u0434\u043d\u043e\u0439 \u0434\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0439 \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u0438.<\/p>\n<\/p>\n<\/div>\n<\/div>\n<\/div>\n<p><!----><!----><\/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\/articles\/754744\/\"> https:\/\/habr.com\/ru\/articles\/754744\/<\/a><br \/><\/br><\/br><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"class_list":["post-352218","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/352218","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=352218"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/352218\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=352218"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=352218"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=352218"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}