Git Product home page Git Product logo

recommend's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

recommend's Issues

几个小建议

1、函数式编程需要加强,通过看代码看出来还是比较熟悉Java而可能刚接触Scala。
2、RDD操作带来的效率问题需要斟酌提高。

比如在UBCF.scala文件中,在生成user->user矩阵中先用到了groupBy(),然后在合并中用到了reduce(),这是两段代码比较累赘。scala中尽量不要用var,并且对RDD的操作不需要map。

下面是按照你的代码个人的修改的一些想法(两段代码合并为一段),也不能说一定是最好的,只是共同学习。

val userMatrixsRDD = itemsUserCollectionRDD.groupBy(_.1).flatMap(
      x =>
        for (
          ri <- x._2.iterator;
          rj <- x._2.iterator
          if ri.id < rj.id
        )
          yield {
            ((ri.id, rj.id), 1L
          }
    )

    val userAndUserMatrixCollection = userMatrixsRDD 
      .reduceByKey((x, y) => x + y)
      .map { x =>
        val ((uid, vid), counts) = x
        (uid, vid, similarity(uid, vid, counts) // similarity是自定义计算相似度的函数
      }

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.