[{"data":1,"prerenderedAt":749},["ShallowReactive",2],{"content-query-VKosxoi3TF":3},{"_path":4,"_dir":5,"_draft":6,"_partial":6,"_locale":7,"title":8,"description":9,"date":10,"cover":11,"type":12,"category":13,"body":14,"_type":743,"_id":744,"_source":745,"_file":746,"_stem":747,"_extension":748},"/technology-blogs/zh/760","zh",false,"","【跟着小Mi一起机器学习吧！】推荐系统","什么是机器学习，什么是机器学习，如果你想知道什么是机器学习，那么小Mi带你一起研究！","2021-10-22","https://obs-mindspore-file.obs.cn-north-4.myhuaweicloud.com/file/2021/10/22/0c208c2b74264df0b286bc869f785773.png","technology-blogs","基础知识",{"type":15,"children":16,"toc":733},"root",[17,25,31,42,47,52,57,62,70,75,80,89,98,125,143,157,166,171,188,195,206,217,231,246,266,271,281,288,322,327,334,339,346,355,360,367,372,389,396,401,408,419,424,444,449,477,486,491,508,515,538,545,552,561,566,571,582,587,594,599,606,674,679,688,693,700,705,710,717,728],{"type":18,"tag":19,"props":20,"children":22},"element","h1",{"id":21},"跟着小mi一起机器学习吧推荐系统",[23],{"type":24,"value":8},"text",{"type":18,"tag":26,"props":27,"children":28},"p",{},[29],{"type":24,"value":30},"一周未见，甚是想念，今天小Mi带大家学习推荐系统(Recommender Systems)！推荐系统是机器学习中一个很重要的应用，比如某易推荐的歌曲呀，某宝推荐的购物清单呀等等，既然应该这么广泛，那就废话不多说，我们开始吧~",{"type":18,"tag":32,"props":33,"children":35},"h3",{"id":34},"_1-定义",[36],{"type":18,"tag":37,"props":38,"children":39},"strong",{},[40],{"type":24,"value":41},"1 定义",{"type":18,"tag":26,"props":43,"children":44},{},[45],{"type":24,"value":46},"推荐系统是个很有意思的问题，机器学习的学术会议上通常不太会关注推荐系统问题，但是在我们生活中却随处可见。",{"type":18,"tag":26,"props":48,"children":49},{},[50],{"type":24,"value":51},"同时对机器学习来说，特征是很重要的，选择的特征将对学习算法的性能有很大影响。因此，在机器学习中有一种大思想，针对一些问题，可以通过算法自动学习一套比较好的特征，从而代替手动设计，其中推荐系统就是类型设置的一个例子。",{"type":18,"tag":26,"props":53,"children":54},{},[55],{"type":24,"value":56},"那么什么是推荐系统问题呢？我们从一个例子开始定义推荐系统的问题。",{"type":18,"tag":26,"props":58,"children":59},{},[60],{"type":24,"value":61},"假使一个电影供应商有5部电影和4个用户，我们要求用户为电影打分。",{"type":18,"tag":26,"props":63,"children":64},{},[65],{"type":18,"tag":66,"props":67,"children":69},"img",{"alt":7,"src":68},"https://bbs-img.huaweicloud.com/data/forums/attachment/forum/202110/22/161621ry9hkhsytp4qx3zz.png",[],{"type":18,"tag":26,"props":71,"children":72},{},[73],{"type":24,"value":74},"前三部电影是爱情片，后两部则是动作片，图中可以发现Alice和Bob似乎更倾向与爱情片，而Carol和Dave似乎更倾向与动作片，同时每个用户都并未给全部的电影都打过分。这时可以构建一个算法，预测每个人可能会给各自没看过的电影打多少分，并以此作为推荐的依据。",{"type":18,"tag":26,"props":76,"children":77},{},[78],{"type":24,"value":79},"下面引入一些相关参数：",{"type":18,"tag":26,"props":81,"children":82},{},[83,87],{"type":18,"tag":66,"props":84,"children":86},{"alt":7,"src":85},"https://bbs-img.huaweicloud.com/data/forums/attachment/forum/202110/22/1617030at7zv65vtiyvfgc.png",[],{"type":24,"value":88},"：用户数量；",{"type":18,"tag":26,"props":90,"children":91},{},[92,96],{"type":18,"tag":66,"props":93,"children":95},{"alt":7,"src":94},"https://bbs-img.huaweicloud.com/data/forums/attachment/forum/202110/22/161717ucapzy9mu08m36z8.png",[],{"type":24,"value":97},"：电影数量；",{"type":18,"tag":26,"props":99,"children":100},{},[101,105,107,111,113,117,119,123],{"type":18,"tag":66,"props":102,"children":104},{"alt":7,"src":103},"https://bbs-img.huaweicloud.com/data/forums/attachment/forum/202110/22/1617334o6zyvknrjkvrtv3.png",[],{"type":24,"value":106},"：如果用户",{"type":18,"tag":66,"props":108,"children":110},{"alt":7,"src":109},"https://bbs-img.huaweicloud.com/data/forums/attachment/forum/202110/22/1617483zrrgyzxaipz4dxn.png",[],{"type":24,"value":112},"给电影",{"type":18,"tag":66,"props":114,"children":116},{"alt":7,"src":115},"https://bbs-img.huaweicloud.com/data/forums/attachment/forum/202110/22/161800u0829zdwpkzoxthk.png",[],{"type":24,"value":118},"评过分，则",{"type":18,"tag":66,"props":120,"children":122},{"alt":7,"src":121},"https://bbs-img.huaweicloud.com/data/forums/attachment/forum/202110/22/1618255suhjqaoii91muky.png",[],{"type":24,"value":124},"；",{"type":18,"tag":26,"props":126,"children":127},{},[128,132,134,137,138,141],{"type":18,"tag":66,"props":129,"children":131},{"alt":7,"src":130},"https://bbs-img.huaweicloud.com/data/forums/attachment/forum/202110/22/161841hkefds0kf1myknkj.png",[],{"type":24,"value":133},"：用户",{"type":18,"tag":66,"props":135,"children":136},{"alt":7,"src":109},[],{"type":24,"value":112},{"type":18,"tag":66,"props":139,"children":140},{"alt":7,"src":115},[],{"type":24,"value":142},"的评分；",{"type":18,"tag":26,"props":144,"children":145},{},[146,150,151,155],{"type":18,"tag":66,"props":147,"children":149},{"alt":7,"src":148},"https://bbs-img.huaweicloud.com/data/forums/attachment/forum/202110/22/161901r2kr91vk46yvudra.png",[],{"type":24,"value":133},{"type":18,"tag":66,"props":152,"children":154},{"alt":7,"src":153},"https://bbs-img.huaweicloud.com/data/forums/attachment/forum/202110/22/161916blddfp6repdofp07.png",[],{"type":24,"value":156},"评过分的电影总数。",{"type":18,"tag":32,"props":158,"children":160},{"id":159},"_2-特征与算法",[161],{"type":18,"tag":37,"props":162,"children":163},{},[164],{"type":24,"value":165},"2 特征与算法",{"type":18,"tag":26,"props":167,"children":168},{},[169],{"type":24,"value":170},"在一个基于内容的推荐系统算法中，对于用户希望推荐的电影有一些数据，而这些数据更准确地说就是相关的特征。",{"type":18,"tag":26,"props":172,"children":173},{},[174,176,180,182,186],{"type":24,"value":175},"假设每部电影都有两个特征，",{"type":18,"tag":66,"props":177,"children":179},{"alt":7,"src":178},"https://bbs-img.huaweicloud.com/data/forums/attachment/forum/202110/22/161933dx0ahx1whmizgcsg.png",[],{"type":24,"value":181},"如代表电影的浪漫程度，",{"type":18,"tag":66,"props":183,"children":185},{"alt":7,"src":184},"https://bbs-img.huaweicloud.com/data/forums/attachment/forum/202110/22/162004tlnljw2ulbpyl9cj.png",[],{"type":24,"value":187},"代表电影的动作程度。",{"type":18,"tag":26,"props":189,"children":190},{},[191],{"type":18,"tag":66,"props":192,"children":194},{"alt":7,"src":193},"https://bbs-img.huaweicloud.com/data/forums/attachment/forum/202110/22/162023iaiit07q0pcyagvl.png",[],{"type":18,"tag":26,"props":196,"children":197},{},[198,200,204],{"type":24,"value":199},"那么每部电影都有一个特征向量，如",{"type":18,"tag":66,"props":201,"children":203},{"alt":7,"src":202},"https://bbs-img.huaweicloud.com/data/forums/attachment/forum/202110/22/162047fyn1e3ievz9as8oo.png",[],{"type":24,"value":205},"是第一部电影的特征向量：[0.9 0]。",{"type":18,"tag":26,"props":207,"children":208},{},[209,211,215],{"type":24,"value":210},"基于这些特征来构建一个推荐系统算法，采用线性回归模型，我们可以针对每一个用户都训练一个线性回归模型，如",{"type":18,"tag":66,"props":212,"children":214},{"alt":7,"src":213},"https://bbs-img.huaweicloud.com/data/forums/attachment/forum/202110/22/16212153ht5jil4ksjltml.png",[],{"type":24,"value":216},"是第一个用户的模型参数。于是就有：",{"type":18,"tag":26,"props":218,"children":219},{},[220,224,225,229],{"type":18,"tag":66,"props":221,"children":223},{"alt":7,"src":222},"https://bbs-img.huaweicloud.com/data/forums/attachment/forum/202110/22/162135tdpiixqzg8jqrad7.png",[],{"type":24,"value":133},{"type":18,"tag":66,"props":226,"children":228},{"alt":7,"src":227},"https://bbs-img.huaweicloud.com/data/forums/attachment/forum/202110/22/162227ao0idbh65v5i7wo1.png",[],{"type":24,"value":230},"的参数向量；",{"type":18,"tag":26,"props":232,"children":233},{},[234,238,240,244],{"type":18,"tag":66,"props":235,"children":237},{"alt":7,"src":236},"https://bbs-img.huaweicloud.com/data/forums/attachment/forum/202110/22/1622428lp7fhfmebcfrwjs.png",[],{"type":24,"value":239},"：电影",{"type":18,"tag":66,"props":241,"children":243},{"alt":7,"src":242},"https://bbs-img.huaweicloud.com/data/forums/attachment/forum/202110/22/162300bgihhzrmpvwbxdsq.png",[],{"type":24,"value":245},"的特征向量；",{"type":18,"tag":26,"props":247,"children":248},{},[249,251,254,256,259,261,265],{"type":24,"value":250},"对于用户",{"type":18,"tag":66,"props":252,"children":253},{"alt":7,"src":227},[],{"type":24,"value":255},"和电影",{"type":18,"tag":66,"props":257,"children":258},{"alt":7,"src":242},[],{"type":24,"value":260},"，我们预测评分为：",{"type":18,"tag":66,"props":262,"children":264},{"alt":7,"src":263},"https://bbs-img.huaweicloud.com/data/forums/attachment/forum/202110/22/162323lx20de6m6n7yxly1.png",[],{"type":24,"value":124},{"type":18,"tag":26,"props":267,"children":268},{},[269],{"type":24,"value":270},"代价函数",{"type":18,"tag":26,"props":272,"children":273},{},[274,276,279],{"type":24,"value":275},"针对用户",{"type":18,"tag":66,"props":277,"children":278},{"alt":7,"src":227},[],{"type":24,"value":280},"，该线性回归模型的代价为预测误差的平方和，加上正则化项：",{"type":18,"tag":26,"props":282,"children":283},{},[284],{"type":18,"tag":66,"props":285,"children":287},{"alt":7,"src":286},"https://bbs-img.huaweicloud.com/data/forums/attachment/forum/202110/22/162354kgjimeidhxd3wigg.png",[],{"type":18,"tag":26,"props":289,"children":290},{},[291,293,297,299,302,304,308,310,314,316,320],{"type":24,"value":292},"其中",{"type":18,"tag":66,"props":294,"children":296},{"alt":7,"src":295},"https://bbs-img.huaweicloud.com/data/forums/attachment/forum/202110/22/162411mucx9sixu4c17z35.png",[],{"type":24,"value":298},"表示只计算那些用户",{"type":18,"tag":66,"props":300,"children":301},{"alt":7,"src":227},[],{"type":24,"value":303},"评过分的电影。在一般的线性回归模型中，误差项和正则项应该都是乘以",{"type":18,"tag":66,"props":305,"children":307},{"alt":7,"src":306},"https://bbs-img.huaweicloud.com/data/forums/attachment/forum/202110/22/162435ft1grf7dtfuxtr53.png",[],{"type":24,"value":309},"，在这里的话我们选择将",{"type":18,"tag":66,"props":311,"children":313},{"alt":7,"src":312},"https://bbs-img.huaweicloud.com/data/forums/attachment/forum/202110/22/162449bwm9dofgmeeap4o0.png",[],{"type":24,"value":315},"去掉，同时也不会对方差项",{"type":18,"tag":66,"props":317,"children":319},{"alt":7,"src":318},"https://bbs-img.huaweicloud.com/data/forums/attachment/forum/202110/22/162504pnro1pvliuz5yle4.png",[],{"type":24,"value":321},"进行正则化处理。",{"type":18,"tag":26,"props":323,"children":324},{},[325],{"type":24,"value":326},"上面的代价函数只是针对一个用户的，为了学习所有用户，将所有用户的代价函数求和：",{"type":18,"tag":26,"props":328,"children":329},{},[330],{"type":18,"tag":66,"props":331,"children":333},{"alt":7,"src":332},"https://bbs-img.huaweicloud.com/data/forums/attachment/forum/202110/22/162521kkgoojjvtdmxoc9t.png",[],{"type":18,"tag":26,"props":335,"children":336},{},[337],{"type":24,"value":338},"如果要用梯度下降法来求解最优解，计算代价函数的偏导数后得到梯度下降的更新公式为：",{"type":18,"tag":26,"props":340,"children":341},{},[342],{"type":18,"tag":66,"props":343,"children":345},{"alt":7,"src":344},"https://bbs-img.huaweicloud.com/data/forums/attachment/forum/202110/22/162541q7xobynhrkizebvl.png",[],{"type":18,"tag":32,"props":347,"children":349},{"id":348},"_3-协同过滤",[350],{"type":18,"tag":37,"props":351,"children":352},{},[353],{"type":24,"value":354},"3 协同过滤",{"type":18,"tag":26,"props":356,"children":357},{},[358],{"type":24,"value":359},"在基于内容的推荐系统中，对于每一部电影，我们都掌握了可用的特征，使用这些特征训练出了每一个用户的参数。举一反三，如果我们拥有用户的参数，那么其实也可以学习得出电影的特征，有没有？！",{"type":18,"tag":26,"props":361,"children":362},{},[363],{"type":18,"tag":66,"props":364,"children":366},{"alt":7,"src":365},"https://bbs-img.huaweicloud.com/data/forums/attachment/forum/202110/22/162603s2x59meiduryny1u.png",[],{"type":18,"tag":26,"props":368,"children":369},{},[370],{"type":24,"value":371},"但是如果既没有用户的参数，也没有电影的特征，那么应该如何解决呢？不用担心，协同过滤算法闪亮登场~",{"type":18,"tag":26,"props":373,"children":374},{},[375,377,381,383,387],{"type":24,"value":376},"优化目标将同时针对",{"type":18,"tag":66,"props":378,"children":380},{"alt":7,"src":379},"https://bbs-img.huaweicloud.com/data/forums/attachment/forum/202110/22/162636iralwglgkmxhjrnj.png",[],{"type":24,"value":382},"和",{"type":18,"tag":66,"props":384,"children":386},{"alt":7,"src":385},"https://bbs-img.huaweicloud.com/data/forums/attachment/forum/202110/22/1626506gpf72y8cx1kan9c.png",[],{"type":24,"value":388},"进行，对代价函数求偏导数的结果如下：",{"type":18,"tag":26,"props":390,"children":391},{},[392],{"type":18,"tag":66,"props":393,"children":395},{"alt":7,"src":394},"https://bbs-img.huaweicloud.com/data/forums/attachment/forum/202110/22/173308topxlneekhssyex3.png",[],{"type":18,"tag":26,"props":397,"children":398},{},[399],{"type":24,"value":400},"注：在协同过滤算法中，通常不使用方差项，如果需要的话，算法会自动学得。 协同过滤算法使用步骤如下：",{"type":18,"tag":26,"props":402,"children":403},{},[404],{"type":18,"tag":66,"props":405,"children":407},{"alt":7,"src":406},"https://bbs-img.huaweicloud.com/data/forums/attachment/forum/202110/22/1728070fgup5o3jzwptcfe.png",[],{"type":18,"tag":26,"props":409,"children":410},{},[411,413,417],{"type":24,"value":412},"1.初始",{"type":18,"tag":66,"props":414,"children":416},{"alt":7,"src":415},"https://bbs-img.huaweicloud.com/data/forums/attachment/forum/202110/22/162806wratsbybnjdgburj.png",[],{"type":24,"value":418},"为一些随机小值",{"type":18,"tag":26,"props":420,"children":421},{},[422],{"type":24,"value":423},"2.使用梯度下降算法最小化代价函数",{"type":18,"tag":26,"props":425,"children":426},{},[427,429,433,435,438,439,442],{"type":24,"value":428},"3.在训练完算法后，预测",{"type":18,"tag":66,"props":430,"children":432},{"alt":7,"src":431},"https://bbs-img.huaweicloud.com/data/forums/attachment/forum/202110/22/1628210ny5vtqckshymqbz.png",[],{"type":24,"value":434},"为用户",{"type":18,"tag":66,"props":436,"children":437},{"alt":7,"src":227},[],{"type":24,"value":112},{"type":18,"tag":66,"props":440,"children":441},{"alt":7,"src":242},[],{"type":24,"value":443},"的评分",{"type":18,"tag":26,"props":445,"children":446},{},[447],{"type":24,"value":448},"通过这个学习过程获得的特征矩阵包含了有关电影的重要数据，可以用这些数据作为给用户推荐电影的依据。",{"type":18,"tag":26,"props":450,"children":451},{},[452,454,458,460,464,466,470,472,475],{"type":24,"value":453},"例如，如果一位用户正在观看电影",{"type":18,"tag":66,"props":455,"children":457},{"alt":7,"src":456},"https://bbs-img.huaweicloud.com/data/forums/attachment/forum/202110/22/162908zn4gvn4bjjfv0hul.png",[],{"type":24,"value":459},"，寻找另一部电影",{"type":18,"tag":66,"props":461,"children":463},{"alt":7,"src":462},"https://bbs-img.huaweicloud.com/data/forums/attachment/forum/202110/22/162926iyrs4t3kr2dctgly.png",[],{"type":24,"value":465},"，依据两部电影的特征向量之间的距离大小",{"type":18,"tag":66,"props":467,"children":469},{"alt":7,"src":468},"https://bbs-img.huaweicloud.com/data/forums/attachment/forum/202110/22/1629475bjzwvaop6fsugzc.png",[],{"type":24,"value":471},"，距离越小，那么",{"type":18,"tag":66,"props":473,"children":474},{"alt":7,"src":462},[],{"type":24,"value":476},"就越符合该用户的品味。",{"type":18,"tag":32,"props":478,"children":480},{"id":479},"_4-协同过滤算法",[481],{"type":18,"tag":37,"props":482,"children":483},{},[484],{"type":24,"value":485},"4 协同过滤算法",{"type":18,"tag":26,"props":487,"children":488},{},[489],{"type":24,"value":490},"协同过滤优化目标：",{"type":18,"tag":26,"props":492,"children":493},{},[494,496,500,502,506],{"type":24,"value":495},"给定",{"type":18,"tag":66,"props":497,"children":499},{"alt":7,"src":498},"https://bbs-img.huaweicloud.com/data/forums/attachment/forum/202110/22/163014ta5f29e0x4ytowmm.png",[],{"type":24,"value":501},"，估计：",{"type":18,"tag":66,"props":503,"children":505},{"alt":7,"src":504},"https://bbs-img.huaweicloud.com/data/forums/attachment/forum/202110/22/163030bfvupsiknsmiqgoj.png",[],{"type":24,"value":507},"：",{"type":18,"tag":26,"props":509,"children":510},{},[511],{"type":18,"tag":66,"props":512,"children":514},{"alt":7,"src":513},"https://bbs-img.huaweicloud.com/data/forums/attachment/forum/202110/22/163054lv0xaoihqgbuhzal.png",[],{"type":18,"tag":26,"props":516,"children":517},{},[518,519,523,525,528,530,533,534,537],{"type":24,"value":495},{"type":18,"tag":66,"props":520,"children":522},{"alt":7,"src":521},"https://bbs-img.huaweicloud.com/data/forums/attachment/forum/202110/22/163119deho12bfjza4i0jj.png",[],{"type":24,"value":524},"，估计",{"type":18,"tag":66,"props":526,"children":527},{"alt":7,"src":498},[],{"type":24,"value":529},"，同时最小化",{"type":18,"tag":66,"props":531,"children":532},{"alt":7,"src":521},[],{"type":24,"value":382},{"type":18,"tag":66,"props":535,"children":536},{"alt":7,"src":498},[],{"type":24,"value":507},{"type":18,"tag":26,"props":539,"children":540},{},[541],{"type":18,"tag":66,"props":542,"children":544},{"alt":7,"src":543},"https://bbs-img.huaweicloud.com/data/forums/attachment/forum/202110/22/173317jzaytmnjlbucujsl.png",[],{"type":18,"tag":26,"props":546,"children":547},{},[548],{"type":18,"tag":66,"props":549,"children":551},{"alt":7,"src":550},"https://bbs-img.huaweicloud.com/data/forums/attachment/forum/202110/22/17351759wsdbplwflnxmn6.png",[],{"type":18,"tag":32,"props":553,"children":555},{"id":554},"_5-算法的向量化实现",[556],{"type":18,"tag":37,"props":557,"children":558},{},[559],{"type":24,"value":560},"5 算法的向量化实现",{"type":18,"tag":26,"props":562,"children":563},{},[564],{"type":24,"value":565},"根据五部电影的数据集，将这些用户的电影评分，进行分组并存到一个矩阵中。",{"type":18,"tag":26,"props":567,"children":568},{},[569],{"type":24,"value":570},"由于数据集有五部电影和四位用户，那么这个矩阵Y就是一个5行4列的矩阵，同时包含了这些电影的用户评分数据：",{"type":18,"tag":26,"props":572,"children":573},{},[574,578],{"type":18,"tag":66,"props":575,"children":577},{"alt":7,"src":576},"https://bbs-img.huaweicloud.com/data/forums/attachment/forum/202110/22/16324380clpmahfbqvjncu.png",[],{"type":18,"tag":66,"props":579,"children":581},{"alt":7,"src":580},"https://bbs-img.huaweicloud.com/data/forums/attachment/forum/202110/22/1633042z6utgce3oxsbg5u.png",[],{"type":18,"tag":26,"props":583,"children":584},{},[585],{"type":24,"value":586},"推出评分：",{"type":18,"tag":26,"props":588,"children":589},{},[590],{"type":18,"tag":66,"props":591,"children":593},{"alt":7,"src":592},"https://bbs-img.huaweicloud.com/data/forums/attachment/forum/202110/22/163322n37sbz6dgqrkv64k.png",[],{"type":18,"tag":26,"props":595,"children":596},{},[597],{"type":24,"value":598},"找到相关影片：",{"type":18,"tag":26,"props":600,"children":601},{},[602],{"type":18,"tag":66,"props":603,"children":605},{"alt":7,"src":604},"https://bbs-img.huaweicloud.com/data/forums/attachment/forum/202110/22/163344a5g9mz6jfwolca8j.png",[],{"type":18,"tag":26,"props":607,"children":608},{},[609,611,614,616,619,621,624,626,629,630,633,635,638,639,642,644,647,649,652,654,657,659,662,664,667,669,672],{"type":24,"value":610},"前期小Mi已经带大家对特征参数向量进行了学习，那么其实如何度量两部电影之间的相似性就很好解决啦。例如说：电影",{"type":18,"tag":66,"props":612,"children":613},{"alt":7,"src":242},[],{"type":24,"value":615},"有一个特征向量",{"type":18,"tag":66,"props":617,"children":618},{"alt":7,"src":456},[],{"type":24,"value":620},"，而另一部不同的电影",{"type":18,"tag":66,"props":622,"children":623},{"alt":7,"src":227},[],{"type":24,"value":625},"，只要保证两部电影的特征向量之间的距离",{"type":18,"tag":66,"props":627,"children":628},{"alt":7,"src":456},[],{"type":24,"value":382},{"type":18,"tag":66,"props":631,"children":632},{"alt":7,"src":462},[],{"type":24,"value":634},"很小，那就能很有力地表明电影",{"type":18,"tag":66,"props":636,"children":637},{"alt":7,"src":242},[],{"type":24,"value":255},{"type":18,"tag":66,"props":640,"children":641},{"alt":7,"src":227},[],{"type":24,"value":643},"在某种程度上有相似，至少在某种意义上，某些人喜欢电影",{"type":18,"tag":66,"props":645,"children":646},{"alt":7,"src":242},[],{"type":24,"value":648},"，或许更有可能也对电影",{"type":18,"tag":66,"props":650,"children":651},{"alt":7,"src":242},[],{"type":24,"value":653},"感兴趣。也就是说，当用户在看某部电影",{"type":18,"tag":66,"props":655,"children":656},{"alt":7,"src":242},[],{"type":24,"value":658},"的时候，如果需要找出5部与电影",{"type":18,"tag":66,"props":660,"children":661},{"alt":7,"src":242},[],{"type":24,"value":663},"非常相似的电影，为了能给用户推荐5部新电影，我们需要做的是找出电影",{"type":18,"tag":66,"props":665,"children":666},{"alt":7,"src":227},[],{"type":24,"value":668},"，在这些不同的电影中与我们要找的电影",{"type":18,"tag":66,"props":670,"children":671},{"alt":7,"src":242},[],{"type":24,"value":673},"的距离最小，这样你就能给你的用户推荐几部不同的电影了。",{"type":18,"tag":26,"props":675,"children":676},{},[677],{"type":24,"value":678},"通过这个方法，相信大家可以知道，应该如何进行一个向量化的计算来对所有的用户和所有的电影进行评分计算，同时也能掌握通过学习特征参数，来找到相关电影和产品的方法。",{"type":18,"tag":32,"props":680,"children":682},{"id":681},"_6-均值归一化",[683],{"type":18,"tag":37,"props":684,"children":685},{},[686],{"type":24,"value":687},"6 均值归一化",{"type":18,"tag":26,"props":689,"children":690},{},[691],{"type":24,"value":692},"用户评分数据：",{"type":18,"tag":26,"props":694,"children":695},{},[696],{"type":18,"tag":66,"props":697,"children":699},{"alt":7,"src":698},"https://bbs-img.huaweicloud.com/data/forums/attachment/forum/202110/22/163742tom40jdctfw5sdft.png",[],{"type":18,"tag":26,"props":701,"children":702},{},[703],{"type":24,"value":704},"如果新增一个用户Sky，并且Sky没有为任何电影评分，那么我们以什么为依据为Sky推荐电影呢？",{"type":18,"tag":26,"props":706,"children":707},{},[708],{"type":24,"value":709},"首先需要对矩阵Y进行均值归一化处理，将每一个用户对某一部电影的评分减去所有用户对该电影评分的平均值：",{"type":18,"tag":26,"props":711,"children":712},{},[713],{"type":18,"tag":66,"props":714,"children":716},{"alt":7,"src":715},"https://bbs-img.huaweicloud.com/data/forums/attachment/forum/202110/22/163805iofaxld8zmjfwmxj.png",[],{"type":18,"tag":26,"props":718,"children":719},{},[720,722,726],{"type":24,"value":721},"然后利用这个新的矩阵来训练算法，如果我们要用新训练出的算法来预测评分，则需要将平均值重新加回去，预测",{"type":18,"tag":66,"props":723,"children":725},{"alt":7,"src":724},"https://bbs-img.huaweicloud.com/data/forums/attachment/forum/202110/22/163832n9afhbaneldvpy7k.png",[],{"type":24,"value":727},"，而对于用户Sky，新模型会认为她给每部电影的评分都是该电影的平均分。",{"type":18,"tag":26,"props":729,"children":730},{},[731],{"type":24,"value":732},"好啦，对于推荐系统的学习就先到这咯~下周小Mi给大家安排大规模机器学习！我们，下周再见呦（挥手十分钟！）",{"title":7,"searchDepth":734,"depth":734,"links":735},4,[736,738,739,740,741,742],{"id":34,"depth":737,"text":41},3,{"id":159,"depth":737,"text":165},{"id":348,"depth":737,"text":354},{"id":479,"depth":737,"text":485},{"id":554,"depth":737,"text":560},{"id":681,"depth":737,"text":687},"markdown","content:technology-blogs:zh:760.md","content","technology-blogs/zh/760.md","technology-blogs/zh/760","md",1776506140655]