[ https://issues.apache.org/jira/browse/MAHOUT-1856?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15833744#comment-15833744 ]
ASF GitHub Bot commented on MAHOUT-1856:
----------------------------------------
Github user andrewpalumbo commented on a diff in the pull request:
https://github.com/apache/mahout/pull/246#discussion_r97236994
--- Diff: math-scala/src/test/scala/org/apache/mahout/math/algorithms/RegressionSuite.scala ---
@@ -0,0 +1,82 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.mahout.math.algorithms
+
+// arrange these proper
+import org.apache.mahout.math.algorithms.regression.OrdinaryLeastSquares
+import org.apache.mahout.math.drm.RLikeDrmOps._
+import org.apache.mahout.math.scalabindings.MahoutCollections._
+import org.apache.mahout.math.scalabindings.RLikeOps._
+import org.apache.mahout.math.scalabindings._
+import org.apache.mahout.math.drm._
+import org.apache.mahout.test.{DistributedMahoutSuite, MahoutSuite}
+import org.scalatest.{FunSuite, Matchers}
+
+trait RegressionSuite extends DistributedMahoutSuite with Matchers {
+ this: FunSuite =>
+
+ test("ordinary least squares") {
+ /*
+ R Prototype:
+ dataM <- matrix( c(2, 2, 10.5, 10, 29.509541,
+ 1, 2, 12, 12, 18.042851,
+ 1, 1, 12, 13, 22.736446,
+ 2, 1, 11, 13, 32.207582,
+ 1, 2, 12, 11, 21.871292,
+ 2, 1, 16, 8, 36.187559,
+ 6, 2, 17, 1, 50.764999,
+ 3, 2, 13, 7, 40.400208,
+ 3, 3, 13, 4, 45.811716), nrow=9, ncol=5, byrow=TRUE)
+
+
+ X = dataM[, c(1,2,3,4)]
+ y = dataM[, c(5)]
+
+ model <- lm(y ~ X - 1)
+ summary(model)
+
+ */
+
+ val drmData = drmParallelize(dense(
+ (2, 2, 10.5, 10, 29.509541), // Apple Cinnamon Cheerios
+ (1, 2, 12, 12, 18.042851), // Cap'n'Crunch
+ (1, 1, 12, 13, 22.736446), // Cocoa Puffs
+ (2, 1, 11, 13, 32.207582), // Froot Loops
+ (1, 2, 12, 11, 21.871292), // Honey Graham Ohs
+ (2, 1, 16, 8, 36.187559), // Wheaties Honey Gold
+ (6, 2, 17, 1, 50.764999), // Cheerios
+ (3, 2, 13, 7, 40.400208), // Clusters
+ (3, 3, 13, 4, 45.811716)), numPartitions = 2)
+
+ drmData.collect(::, 0 until 4)
+
+ val drmX = drmData(::, 0 until 4)
+ val drmY = drmData(::, 4 until 5)
+
+ val model = new OrdinaryLeastSquares[Int]()
+ model.fit(drmY, drmX)
+ val estimate = model.beta
+ val Ranswers = dvec(-1.336265, -13.157702, -4.152654, -5.679908, 163.179329)
+
+ val epsilon = 1E-6
+ (estimate - Ranswers).sum should be < epsilon
+
+ }
+
--- End diff --
It would be good to have a couple of more tests here; at least one for `Transform(...)`
Post by Andrew Palumbo (JIRA)Create a framework for new Mahout Clustering, Classification, and Optimization Algorithms
------------------------------------------------------------------------------------------
Key: MAHOUT-1856
URL: https://issues.apache.org/jira/browse/MAHOUT-1856
Project: Mahout
Issue Type: New Feature
Affects Versions: 0.12.1
Reporter: Andrew Palumbo
Assignee: Trevor Grant
Priority: Critical
Fix For: 0.13.0
To ensure that Mahout does not become "A loose bag of algorithms", Create basic traits with funtions common to each class of algorithm.
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)