Skip to content
Closed
Changes from 1 commit
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
e4492a6
add pic framework (model, class etc)
wangmiao1981 Jun 13, 2016
7086249
change a comment
wangmiao1981 Jun 13, 2016
b73d8a7
add missing functions fit predict load save etc.
wangmiao1981 Jun 17, 2016
022fe52
add unit test flie
wangmiao1981 Jun 18, 2016
552cf54
add test cases part 1
wangmiao1981 Jun 20, 2016
0b4954d
add unit test part 2: test fit, parameters etc.
wangmiao1981 Jun 20, 2016
f22b01e
fix a type issue
wangmiao1981 Jun 20, 2016
305b194
add more unit tests
wangmiao1981 Jun 21, 2016
4b32cbf
delete unused import and add comments
wangmiao1981 Jun 21, 2016
f6eda88
change version to 2.1.0
wangmiao1981 Oct 25, 2016
45c4b1c
change PIC as a Transformer
wangmiao1981 Nov 3, 2016
e8d7ed3
add LabelCol
wangmiao1981 Nov 4, 2016
e4e1e05
change col implementation
wangmiao1981 Nov 4, 2016
8384422
address some of the comments
wangmiao1981 Feb 17, 2017
d6a199c
add additional test with dataset having more data
wangmiao1981 Feb 21, 2017
b0c3aff
change input data format
wangmiao1981 Mar 14, 2017
091225d
resolve warnings
wangmiao1981 Mar 15, 2017
8bb9956
add neighbor and weight cols
wangmiao1981 Mar 16, 2017
8ba82e8
address review comments 1
wangmiao1981 Aug 15, 2017
468a947
fix style
wangmiao1981 Aug 15, 2017
ec10f24
remove unused comments
wangmiao1981 Aug 15, 2017
5710cfc
add Since
wangmiao1981 Aug 15, 2017
88654b3
fix missing >
wangmiao1981 Aug 17, 2017
804adc6
fix doc
wangmiao1981 Aug 17, 2017
4a6dd79
address review comments
wangmiao1981 Oct 25, 2017
5cb8ed6
fix unit test
wangmiao1981 Oct 30, 2017
6abf602
cleanups to docs
jkbradley Apr 3, 2018
d927087
typo
jkbradley Apr 3, 2018
d215748
final updates for PIC PR
jkbradley Apr 17, 2018
375e150
fixed scala style
jkbradley Apr 19, 2018
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
add test cases part 1
  • Loading branch information
wangmiao1981 authored and jkbradley committed Apr 16, 2018
commit 552cf54fb03f88af023f080e60fa50f1f39060fc
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,7 @@

package org.apache.spark.ml.clustering

import scala.collection.mutable
import scala.util.Random
import org.apache.spark.{SparkContext, SparkFunSuite}
import org.apache.spark.SparkFunSuite
import org.apache.spark.graphx.{Edge, Graph}
import org.apache.spark.ml.util.DefaultReadWriteTest
import org.apache.spark.mllib.util.MLlibTestSparkContext
Expand All @@ -31,5 +29,51 @@ class PowerIterationClusteringSuite extends SparkFunSuite

import org.apache.spark.ml.clustering.PowerIterationClustering._

/** Generates a circle of points. */
private def genCircle(r: Double, n: Int): Array[(Double, Double)] = {
Array.tabulate(n) { i =>
val theta = 2.0 * math.Pi * i / n
(r * math.cos(theta), r * math.sin(theta))
}
}

/** Computes Gaussian similarity. */
private def sim(x: (Double, Double), y: (Double, Double)): Double = {
val dist2 = (x._1 - y._1) * (x._1 - y._1) + (x._2 - y._2) * (x._2 - y._2)
math.exp(-dist2 / 2.0)
}

test("default parameters") {
val pic = new PowerIterationClustering()

assert(pic.getK === 2)
assert(pic.getMaxIter === 20)
assert(pic.getInitMode === "random")
assert(pic.getFeaturesCol === "features")
assert(pic.getPredictionCol === "prediction")
}

test("set parameters") {
val pic = new PowerIterationClustering()
.setK(9)
.setMaxIter(33)
.setInitMode("degree")
.setFeaturesCol("test_feature")
.setPredictionCol("test_prediction")

assert(pic.getK === 9)
assert(pic.getMaxIter === 33)
assert(pic.getInitMode === "degree")
assert(pic.getFeaturesCol === "test_feature")
assert(pic.getPredictionCol === "test_prediction")
}

test("parameters validation") {
intercept[IllegalArgumentException] {
new PowerIterationClustering().setK(1)
}
intercept[IllegalArgumentException] {
new PowerIterationClustering().setInitMode("no_such_a_mode")
}
}
}