” 写作CS 506编程语言、 辅导Python程序设计CS 506 – HW3Social Networks and Recommendation SystemsDue date: December 7, 20201 BackgroundIn this homework, you will try to recommend new collaborations to researchersof the Machine Learning community. Our approach will follow the guidelines ofcollaborative filtering: If your past behavior/preferences were similar to someother users, your future behavior may be as well. As an example, imagine youlike Rolling Stones, Beatles and Jimmy Hendrix. It turns out that most peoplethat like the aforementioned artists, are also fans of Eric Clapton. Then, it isvery likely that if you listen to Eric Claptons music, you will like it as well.In this assignment you will implement a collaborative filtering recommendationsystem for Suggesting new collaborations to Machine Learning researchers.A network as a graph: A graph or network represents relationships amongdifferent entities (users of a social network, researchers, products, etc.). Thoseentities are represented as nodes and the relationships between them (friendson Facebook, co-authors of a research paper, products purchased together) asedges. When there is an edge between two nodes, x and y, we say that y is aneighbor (or friend) of x (and also – as the graphs we consider are undirected -x is also a neighbor of y).Representing a graph in Python: A widely used library in Python, forrepresenting graphs is NetworkX. You can read the documentation for moreinformation on how to use this library.2 Recommend new collaborations – The ML CommunitycaseIn order to provide new Collaborations and test the efficiency of the methodsused, you are given two files (you can find them on piazza):1 old edges.txt: In this file, every line contains the names of two researchersthat have co-authored a paper in one of the top Machine Learningconferences (NeurIPS, ICLR, ICML) between 2010 and 2016. new edges.txt: In this file, Every line contains the names of two researchers(from those existing in the above file) that formed a new (nonexistingbefore) collaboration, in either 2017 and 2018.With the first file in hand, you will answer the following question:For author X, list some non-collaborators in order, starting with the best collaboratorrecommendation and ending with the worst. A non-friend is a userwho is not X and is not a collaborator of X. Depending on the recommendationalgorithm you are going to choose, the list may include all non-collaborators orsome of them.Then, using the second file, with actual new collaborations formed in thenext 3 years, you will test the efficiency of these algorithms.3 Tasksa) [3 pts.] Write a function that reads the file old edges.txt and create agraph using NetworkX.b) [3 pts.] Write a function that reads the file new edges.txt and for eachauthor, keeps track of the New collaborations this user formed during2017-2018.In 2017 and 2018, there were 1,757 new edges formed between existing authors.For the next tasks, pick (and recommend new collaborations for) thoseauthors that formed at least 10 new connections between 2017-2018. In theremaining, when we talk about author X, we refer to one of those authors.c) [5 pts.] Recommend by number of common friendsif non-friend Y is your friends friend, then maybe Y should be your friendtoo. If person Y is the friend of many of your friends, then Y is an evenbetter recommendation.Write a function Common friends number(G, X) that given G and an authorX, returns a list of recommendations for X. The authors in this list are sortedby the number of common neighbors they have with X (and are not of coursealready friends with X). If there are ties, you can break them arbitrarily.2d) [5 pts.] Make recommendations using Jaccards IndexIf (X) is the set of neighbors of X, then the metric we used in part (c),assigns to a non-friend y, the following recommendation score (with respectto X): score(y) = |(X)(y)|. Jaccards Index scales this score bytaking into account the union of X and Y s neighbors. Intuitively, X andY are more similar, if what they have in common is as close as possible towhat they have together.Write a function jaccard index(G, X) that given G and an author X, returns alist of recommendations for X. The authors in this list are sorted by the numberof their Jaccard Index with respect to X (and are not of course already friendswith X). If there are ties, you can break them arbitrarily.Jaccard Index = |(X)(y)||(X)(y)|e) [5 pts.] Make recommendations using Adamic/Adar IndexFor part (c), we made recommendations using common neighbors. However,when assigning a score to Y , instead of just taking a count of thenumber of common neighbors, we take a weighted sum of them, where theweight of each common neighbor of X and Y , call her Z, is the inverse ofthe logarithm of the number of Zs neighbors. In that way, we value morecommon neighbors that are more selective.Write a Function adamic adar index(G, X) that given G and an author X,returns a list of recommendations for X. The authors in this list are sortedby the number of their Adamic/Adar Index with respect to X (and are not ofcourse already friends with X). If there are ties, you can break them arbitrarily.Adamic/Adar Index (y)= PZ(X)(y)1log|(Z)|f) [4 pts.] How good are the recommendations we make?Previously, you implemented 3 functions, that given a user X providerecommendations for this user. In this task, you will check how goodthese recommendations are using the actual new connections formed during2017-2018.You will use two different ways, to calculate the efficiency of every approach: For each user X, take the 10 first recommendations for this user,and calculate the Number of them that were actually formed during2017-2018. You should report the average among users X. For each newly formed collaboration of user X, calculate the rankof this collaboration (the index where this new node Y appears inthe recommendations list for X). Report the average among newlyformed edges.e) [Bonus Question] [2 pts.]Doing some literature search, suggest your own algorithm for recommend-3ing new links to a user X. Argue about the choice you make, why it makessense to suggest users that way? How is the efficiency of this algorithm,compared to the Ones you implemented in parts (c), (d) and (e)?如有需要,请加QQ:99515681 或邮箱:99515681@qq.com
“
添加老师微信回复‘’官网 辅导‘’获取专业老师帮助,或点击联系老师1对1在线指导。