楼主: lion003
16472 50

Scala for Machine Learning [推广有奖]

11楼
lxy444(未真实交易用户) 学生认证  发表于 2016-3-11 22:21:55
感谢分享!

12楼
andyhd(真实交易用户) 发表于 2016-3-15 17:13:42
好流弊的样子,下载看看。谢谢搂住

13楼
gxnnhsd(未真实交易用户) 发表于 2016-3-22 00:09:48
谢谢分享!

14楼
zhzhe3(未真实交易用户) 学生认证  发表于 2016-3-22 18:36:08
O(∩_∩)O谢谢

15楼
Nicolle(真实交易用户) 学生认证  发表于 2016-3-31 09:13:29
提示: 作者被禁止或删除 内容自动屏蔽

16楼
Nicolle(真实交易用户) 学生认证  发表于 2016-3-31 09:14:19
提示: 作者被禁止或删除 内容自动屏蔽

17楼
malloy666(未真实交易用户) 发表于 2016-4-3 21:37:30 来自手机
看看怎么样

18楼
leon_9930754(未真实交易用户) 发表于 2016-4-14 02:22:13
谢谢分享

19楼
Lisrelchen(真实交易用户) 发表于 2016-4-20 09:04:57
  1. Measuring similarity
  2. def manhattan[T <% Double, U <% Double](x: Array[T], y: Array[U]): Double = (x, y).zipped.foldLeft(0.0)((s, t) => s + Math.abs(t._1 - t._2))

  3. def euclidean[T <% Double, U <% Double](x: Array[T], y: Array[U]): Double =  Math.sqrt((x, y).zipped.foldLeft(0.0)((s, t) => { val d = t._1 - t._2; s + d*d} ))

  4. def cosine[T <% Double, U <% Double](x: Array[T], y: Array[U]): Double = {
  5.   val zeros = (0.0, 0.0, 0.0)
  6.   val norms = (x, y).zipped.foldLeft(zeros)((s, t) =>
  7.      (s._1 + t._1*t._2, s._2 + t._1*t._1, s._3 + t._2*t._2))
  8.   norms._1/Math.sqrt(norms._2*norms._3)
复制代码

20楼
Lisrelchen(真实交易用户) 发表于 2016-4-20 09:06:24
  1. Defining K-means

  2. Let's declare the K-means algorithm class, KMeans, with its public methods.

  3. The KMeans class takes the number of clusters, K, and the maximum number of iterations, maxIters, as parameters. The implicit conversion of type T to a Double is specified by the T <% Double view bound. The Ordering class has to be passed implicitly as a parameter because it is required by the sortWith method in the initialize and maxBy methods. The Manifest method is required to preserve the type erasure for Array[T] in the JVM:

  4. class KMeans[T <% Double](K: Int, maxIters: Int, distance: (DblVector,Array[T]) => Double)(implicit order: Ordering[T], m: Manifest[T]) extends PipeOperator[XTSeries[Array[T]], List[Cluster[T]]] {
  5.   def |> : PartialFunction[XTSeries[Array[T]], List[Cluster[T]]]
  6.   def initialize(xt:XTSeries[Array[T]]): List[Cluster[T]]
复制代码

您需要登录后才可以回帖 登录 | 我要注册

本版微信群
扫码
拉您进交流群
GMT+8, 2026-10-6 00:44