Github user jkbradley commented on a diff in the pull request:
https://github.com/apache/spark/pull/15211#discussion_r95928470
--- Diff:
mllib/src/test/scala/org/apache/spark/ml/classification/LinearSVCSuite.scala ---
@@ -119,6 +140,35 @@ class LinearSVCSuite extends SparkFunSuite with
MLlibTestSparkContext with Defau
dataset.as[LabeledPoint], estimator, modelEquals, 42L)
}
+ test("linearSVC comparison with R e1071") {
+ val trainer1 = (new LinearSVC).setFitIntercept(true).setMaxIter(100)
+ val model1 = trainer1.fit(binaryDataset)
+
+ /*
+ Use the following R code to load the data and train the model using
glmnet package.
+
+ library(e1071)
+ data <-
read.csv("/home/yuhao/workspace/github/hhbyyh/Test/SVM/svm/part-00000",
header=FALSE)
+ label <- factor(data$V1)
+ features <- as.matrix(data.frame(data$V2, data$V3, data$V4, data$V5))
+ svm_model <- svm(features, label, type='C', kernel='linear',
cost=10, scale=F)
+ w <- t(svm_model$coefs) %*% svm_model$SV
+ w
+ -svm_model$rho
+
+ > w
+ data.V2 data.V3 data.V4 data.V5
+ [1,] -7.310475 -14.89742 -22.21019 -29.83495
+ > -svm_model$rho
+ [1] -7.440296
+
+ */
+ val coefficientsR = Vectors.dense(-7.310475, -14.89742, -22.21019,
-29.83495)
+ val interceptR = -7.440296
+ assert(model1.intercept / interceptR ~== -0.9 relTol 2E-2)
--- End diff --
This is a strange way to write the comparison. Was this a temporary thing
to make the tests pass?
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]