请选择 进入手机版 | 继续访问电脑版
楼主: lion003
9372 50

Scala for Machine Learning [推广有奖]

lxy444 学生认证  发表于 2016-3-11 22:21:55 |显示全部楼层 |坛友微信交流群
感谢分享!

使用道具

andyhd 发表于 2016-3-15 17:13:42 |显示全部楼层 |坛友微信交流群
好流弊的样子,下载看看。谢谢搂住

使用道具

gxnnhsd 发表于 2016-3-22 00:09:48 |显示全部楼层 |坛友微信交流群
谢谢分享!

使用道具

zhzhe3 学生认证  发表于 2016-3-22 18:36:08 |显示全部楼层 |坛友微信交流群
O(∩_∩)O谢谢

使用道具

Nicolle 学生认证  发表于 2016-3-31 09:13:29 |显示全部楼层 |坛友微信交流群
提示: 作者被禁止或删除 内容自动屏蔽

使用道具

Nicolle 学生认证  发表于 2016-3-31 09:14:19 |显示全部楼层 |坛友微信交流群
提示: 作者被禁止或删除 内容自动屏蔽

使用道具

malloy666 发表于 2016-4-3 21:37:30 来自手机 |显示全部楼层 |坛友微信交流群
看看怎么样

使用道具

leon_9930754 发表于 2016-4-14 02:22:13 |显示全部楼层 |坛友微信交流群
谢谢分享

使用道具

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)
复制代码

使用道具

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]]
复制代码

使用道具

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

本版微信群
加JingGuanBbs
拉您进交流群

京ICP备16021002-2号 京B2-20170662号 京公网安备 11010802022788号 论坛法律顾问:王进律师 知识产权保护声明   免责及隐私声明

GMT+8, 2024-3-29 14:36