Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
bfade12
Added lots of classes for new ML API:
jkbradley Nov 24, 2014
d35bb5d
fixed compilation issues, but have not added tests yet
jkbradley Nov 24, 2014
52f4fde
removing everything except for simple class hierarchy for classification
jkbradley Dec 1, 2014
d705e87
Added LinearRegression and Regressor back from ml-api branch
jkbradley Dec 4, 2014
601e792
Modified ParamMap to sort parameters in toString. Cleaned up classes…
jkbradley Dec 5, 2014
0617d61
Fixed bug from last commit (sorting paramMap by parameter names in to…
jkbradley Dec 5, 2014
54b7b31
Fixed issue with logreg threshold being set correctly
jkbradley Dec 5, 2014
e433872
Updated docs. Added LabeledPointSuite to spark.ml
jkbradley Dec 5, 2014
57d54ab
* Changed semantics of Predictor.train() to merge the given paramMap …
jkbradley Dec 5, 2014
58802e3
added train() to Predictor subclasses which does not take a ParamMap.
jkbradley Dec 6, 2014
adbe50a
* fixed LinearRegression train() to use embedded paramMap
jkbradley Dec 6, 2014
1680905
Added JavaLabeledPointSuite.java for spark.ml, and added constructor …
jkbradley Dec 6, 2014
8d13233
Added methods:
jkbradley Dec 8, 2014
bc654e1
Added spark.ml LinearRegressionSuite
jkbradley Dec 8, 2014
4e2f711
rat fix
jkbradley Dec 8, 2014
1c61723
* Made ProbabilisticClassificationModel into a subclass of Classifica…
jkbradley Dec 30, 2014
934f97b
Fixed bugs from previous commit.
jkbradley Dec 30, 2014
c3c8da5
small cleanup
jkbradley Dec 30, 2014
0a16da9
Fixed Linear/Logistic RegressionSuites
jkbradley Dec 31, 2014
82f340b
Fixed bug in LogisticRegression (introduced in this PR). Fixed Java …
jkbradley Dec 31, 2014
343e7bd
added blanket mima exclude for ml package
jkbradley Dec 31, 2014
f549e34
Updates based on code review. Major ones are:
jkbradley Jan 15, 2015
216d199
fixed after sql datatypes PR got merged
jkbradley Jan 15, 2015
f542997
Added MIMA excludes for VectorUDT (now public), and added DeveloperAp…
jkbradley Jan 19, 2015
9872424
fixed JavaLinearRegressionSuite.java Java sql api
jkbradley Jan 19, 2015
bcb9549
Fixed issues after rebasing from master (after move from SchemaRDD to…
jkbradley Jan 30, 2015
fc62406
fixed test suites after last commit
jkbradley Jan 30, 2015
8316d5e
fixes after rebasing on master
jkbradley Feb 5, 2015
fec348a
Added JavaDeveloperApiExample.java and fixed other issues: Made devel…
jkbradley Feb 6, 2015
405bfb8
Last edits based on code review. Small cleanups
jkbradley Feb 6, 2015
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
Fixed bugs from previous commit.
  • Loading branch information
jkbradley committed Feb 5, 2015
commit 934f97b7c876fe704dbe8a55d2b8bcff798b6b59
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ public static void main(String[] args) {
// 'probability' column since we renamed the lr.probabilityCol parameter previously.
model2.transform(test).registerTempTable("results");
DataFrame results =
jsql.sql("SELECT features, label, probability, prediction FROM results");
jsql.sql("SELECT features, label, myProbability, prediction FROM results");
for (Row r: results.collect()) {
System.out.println("(" + r.get(0) + ", " + r.get(1) + ") -> prob=" + r.get(2)
+ ", prediction=" + r.get(3));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,6 @@ object DeveloperApiExample {
import sqlContext._

// Prepare training data.
// We use LabeledPoint, which is a case class. Spark SQL can convert RDDs of Java Beans
// into SchemaRDDs, where it uses the bean metadata to infer the schema.
val training = sparkContext.parallelize(Seq(
LabeledPoint(1.0, Vectors.dense(0.0, 1.1, 0.1)),
LabeledPoint(0.0, Vectors.dense(2.0, 1.0, -1.0)),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ object SimpleParamsExample {
model2.transform(test)
.select('features, 'label, 'myProbability, 'prediction)
.collect()
.foreach { case Row(features: Vector, label: Double, prob: Double, prediction: Double) =>
.foreach { case Row(features: Vector, label: Double, prob: Vector, prediction: Double) =>
println("(" + features + ", " + label + ") -> prob=" + prob + ", prediction=" + prediction)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,6 @@

package org.apache.spark.ml.classification

import scala.reflect.runtime.universe._

import org.apache.spark.annotation.{DeveloperApi, AlphaComponent}
import org.apache.spark.ml.impl.estimator.{PredictionModel, Predictor, PredictorParams}
import org.apache.spark.ml.param.{Params, ParamMap, HasRawPredictionCol}
Expand Down Expand Up @@ -62,8 +60,6 @@ abstract class Classifier[
extends Predictor[FeaturesType, Learner, M]
with ClassifierParams {

setRawPredictionCol("") // Do not output by default

def setRawPredictionCol(value: String): Learner =
set(rawPredictionCol, value).asInstanceOf[Learner]

Expand All @@ -82,8 +78,6 @@ abstract class Classifier[
abstract class ClassificationModel[FeaturesType, M <: ClassificationModel[FeaturesType, M]]
extends PredictionModel[FeaturesType, M] with ClassifierParams {

setRawPredictionCol("") // Do not output by default

def setRawPredictionCol(value: String): M = set(rawPredictionCol, value).asInstanceOf[M]

/** Number of classes (values which the label can take). */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ package org.apache.spark.ml.classification
import org.apache.spark.annotation.AlphaComponent
import org.apache.spark.ml.param._
import org.apache.spark.mllib.classification.LogisticRegressionWithLBFGS
import org.apache.spark.mllib.linalg.{VectorUDT, Vectors, BLAS, Vector}
import org.apache.spark.mllib.linalg.{BLAS, Vector, VectorUDT, Vectors}
import org.apache.spark.sql._
import org.apache.spark.sql.Dsl._
import org.apache.spark.sql.types.{DoubleType, StructField, StructType}
Expand All @@ -35,6 +35,7 @@ private[classification] trait LogisticRegressionParams extends ProbabilisticClas

/**
* :: AlphaComponent ::
*
* Logistic regression.
* Currently, this class only supports binary classification.
*/
Expand Down Expand Up @@ -86,6 +87,7 @@ class LogisticRegression

/**
* :: AlphaComponent ::
*
* Model produced by [[LogisticRegression]].
*/
@AlphaComponent
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,6 @@

package org.apache.spark.ml.classification

import scala.reflect.runtime.universe._

import org.apache.spark.annotation.{AlphaComponent, DeveloperApi}
import org.apache.spark.ml.param.{HasProbabilityCol, ParamMap, Params}
import org.apache.spark.mllib.linalg.{Vector, VectorUDT}
Expand All @@ -42,8 +40,10 @@ private[classification] trait ProbabilisticClassifierParams
}
}


/**
* :: AlphaComponent ::
*
* Single-label binary or multiclass classifier which can output class conditional probabilities.
*
* @tparam FeaturesType Type of input features. E.g., [[Vector]]
Expand All @@ -57,13 +57,13 @@ abstract class ProbabilisticClassifier[
M <: ProbabilisticClassificationModel[FeaturesType, M]]
extends Classifier[FeaturesType, Learner, M] with ProbabilisticClassifierParams {

setProbabilityCol("") // Do not output by default

def setProbabilityCol(value: String): Learner = set(probabilityCol, value).asInstanceOf[Learner]
}


/**
* :: AlphaComponent ::
*
* Model produced by a [[ProbabilisticClassifier]].
* Classes are indexed {0, 1, ..., numClasses - 1}.
*
Expand All @@ -76,8 +76,6 @@ abstract class ProbabilisticClassificationModel[
M <: ProbabilisticClassificationModel[FeaturesType, M]]
extends ClassificationModel[FeaturesType, M] with ProbabilisticClassifierParams {

setProbabilityCol("") // Do not output by default

def setProbabilityCol(value: String): M = set(probabilityCol, value).asInstanceOf[M]

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ import org.apache.spark.sql.types.DoubleType

/**
* :: AlphaComponent ::
*
* Evaluator for binary classification, which expects two input columns: score and label.
*/
@AlphaComponent
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

package org.apache.spark.ml.impl.estimator

import org.apache.spark.annotation.DeveloperApi
import org.apache.spark.annotation.{AlphaComponent, DeveloperApi}
import org.apache.spark.ml.{Estimator, Model}
import org.apache.spark.ml.param._
import org.apache.spark.mllib.linalg.Vector
Expand Down Expand Up @@ -62,6 +62,8 @@ trait PredictorParams extends Params
}

/**
* :: AlphaComponent ::
*
* Abstraction for prediction problems (regression and classification).
*
* @tparam FeaturesType Type of features.
Expand All @@ -71,7 +73,7 @@ trait PredictorParams extends Params
* @tparam M Specialization of [[PredictionModel]]. If you subclass this type, use this type
* parameter to specify the concrete type for the corresponding model.
*/
@DeveloperApi
@AlphaComponent
abstract class Predictor[
FeaturesType,
Learner <: Predictor[FeaturesType, Learner, M],
Expand Down Expand Up @@ -124,7 +126,18 @@ abstract class Predictor[
}
}

private[ml] abstract class PredictionModel[FeaturesType, M <: PredictionModel[FeaturesType, M]]
/**
* :: AlphaComponent ::
*
* Abstraction for a model for prediction tasks (regression and classification).
*
* @tparam FeaturesType Type of features.
* E.g., [[org.apache.spark.mllib.linalg.VectorUDT]] for vector features.
* @tparam M Specialization of [[PredictionModel]]. If you subclass this type, use this type
* parameter to specify the concrete type for the corresponding model.
*/
@AlphaComponent
abstract class PredictionModel[FeaturesType, M <: PredictionModel[FeaturesType, M]]
extends Model[M] with PredictorParams {

def setFeaturesCol(value: String): M = set(featuresCol, value).asInstanceOf[M]
Expand Down
4 changes: 1 addition & 3 deletions mllib/src/main/scala/org/apache/spark/ml/param/params.scala
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,12 @@ package org.apache.spark.ml.param

import scala.annotation.varargs
import scala.collection.mutable
import scala.reflect.runtime.universe._

import java.lang.reflect.Modifier

import org.apache.spark.annotation.{DeveloperApi, AlphaComponent}
import org.apache.spark.annotation.{AlphaComponent, DeveloperApi}
import org.apache.spark.ml.Identifiable
import org.apache.spark.sql._
import org.apache.spark.sql.catalyst.ScalaReflection

/**
* :: AlphaComponent ::
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,8 @@ private[regression] trait LinearRegressionParams extends RegressorParams

/**
* :: AlphaComponent ::
* Logistic regression.
*
* Linear regression.
*/
@AlphaComponent
class LinearRegression extends Regressor[Vector, LinearRegression, LinearRegressionModel]
Expand Down Expand Up @@ -78,6 +79,7 @@ class LinearRegression extends Regressor[Vector, LinearRegression, LinearRegress

/**
* :: AlphaComponent ::
*
* Model produced by [[LinearRegression]].
*/
@AlphaComponent
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ trait RegressorParams extends PredictorParams

/**
* :: AlphaComponent ::
*
* Single-label regression
*
* @tparam FeaturesType Type of input features. E.g., [[org.apache.spark.mllib.linalg.Vector]]
Expand All @@ -49,6 +50,7 @@ abstract class Regressor[

/**
* :: AlphaComponent ::
*
* Model produced by a [[Regressor]].
*
* @tparam FeaturesType Type of input features. E.g., [[org.apache.spark.mllib.linalg.Vector]]
Expand Down
78 changes: 0 additions & 78 deletions mllib/src/test/java/org/apache/spark/ml/JavaLabeledPointSuite.java

This file was deleted.

59 changes: 0 additions & 59 deletions mllib/src/test/scala/org/apache/spark/ml/LabeledPointSuite.scala

This file was deleted.

Loading