Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
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
Original file line number Diff line number Diff line change
Expand Up @@ -483,7 +483,7 @@ object LogisticRegression extends DefaultParamsReadable[LogisticRegression] {
@Experimental
class LogisticRegressionModel private[spark] (
@Since("1.4.0") override val uid: String,
@Since("1.6.0") val coefficients: Vector,
@Since("2.0.0") val coefficients: Vector,
@Since("1.3.0") val intercept: Double)
extends ProbabilisticClassificationModel[Vector, LogisticRegressionModel]
with LogisticRegressionParams with MLWritable {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -296,7 +296,7 @@ object MultilayerPerceptronClassifier
class MultilayerPerceptronClassificationModel private[ml] (
@Since("1.5.0") override val uid: String,
@Since("1.5.0") val layers: Array[Int],
@Since("1.5.0") val weights: Vector)
@Since("2.0.0") val weights: Vector)
extends PredictionModel[Vector, MultilayerPerceptronClassificationModel]
with Serializable with MLWritable {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -130,8 +130,8 @@ object NaiveBayes extends DefaultParamsReadable[NaiveBayes] {
@Experimental
class NaiveBayesModel private[ml] (
@Since("1.5.0") override val uid: String,
@Since("1.5.0") val pi: Vector,
@Since("1.5.0") val theta: Matrix)
@Since("2.0.0") val pi: Vector,
@Since("2.0.0") val theta: Matrix)
extends ProbabilisticClassificationModel[Vector, NaiveBayesModel]
with NaiveBayesParams with MLWritable {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ class KMeansModel private[ml] (

private[clustering] def predict(features: Vector): Int = parentModel.predict(features)

@Since("1.5.0")
@Since("2.0.0")
def clusterCenters: Array[Vector] = parentModel.clusterCenters.map(_.asML)

/**
Expand Down
4 changes: 2 additions & 2 deletions mllib/src/main/scala/org/apache/spark/ml/clustering/LDA.scala
Original file line number Diff line number Diff line change
Expand Up @@ -432,7 +432,7 @@ sealed abstract class LDAModel private[ml] (
* If Online LDA was used and [[optimizeDocConcentration]] was set to false,
* then this returns the fixed (given) value for the [[docConcentration]] parameter.
*/
@Since("1.6.0")
@Since("2.0.0")
def estimatedDocConcentration: Vector = getModel.docConcentration

/**
Expand All @@ -444,7 +444,7 @@ sealed abstract class LDAModel private[ml] (
* the Expectation-Maximization ("em") [[optimizer]], then this method could involve
* collecting a large amount of data to the driver (on the order of vocabSize x k).
*/
@Since("1.6.0")
@Since("2.0.0")
def topicsMatrix: Matrix = oldLocalModel.topicsMatrix.asML

/** Indicates whether this instance is of type [[DistributedLDAModel]] */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,11 @@ import org.apache.spark.sql.types.DataType
* multiplier.
*/
@Experimental
@Since("2.0.0")
class ElementwiseProduct @Since("2.0.0") (@Since("2.0.0") override val uid: String)
@Since("1.4.0")
class ElementwiseProduct @Since("1.4.0") (@Since("1.4.0") override val uid: String)
extends UnaryTransformer[Vector, Vector, ElementwiseProduct] with DefaultParamsWritable {

@Since("2.0.0")
@Since("1.4.0")
def this() = this(Identifiable.randomUID("elemProd"))

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,29 +31,29 @@ import org.apache.spark.sql.types.DataType
* Normalize a vector to have unit norm using the given p-norm.
*/
@Experimental
@Since("2.0.0")
class Normalizer @Since("2.0.0") (@Since("2.0.0") override val uid: String)
@Since("1.4.0")
class Normalizer @Since("1.4.0") (@Since("1.4.0") override val uid: String)
extends UnaryTransformer[Vector, Vector, Normalizer] with DefaultParamsWritable {

@Since("2.0.0")
@Since("1.4.0")
def this() = this(Identifiable.randomUID("normalizer"))

/**
* Normalization in L^p^ space. Must be >= 1.
* (default: p = 2)
* @group param
*/
@Since("2.0.0")
@Since("1.4.0")
val p = new DoubleParam(this, "p", "the p norm value", ParamValidators.gtEq(1))

setDefault(p -> 2.0)

/** @group getParam */
@Since("2.0.0")
@Since("1.4.0")
def getP: Double = $(p)

/** @group setParam */
@Since("2.0.0")
@Since("1.4.0")
def setP(value: Double): this.type = set(p, value)

override protected def createTransformFunc: Vector => Vector = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,30 +35,30 @@ import org.apache.spark.sql.types.DataType
* `(x, y)`, if we want to expand it with degree 2, then we get `(x, x * x, y, x * y, y * y)`.
*/
@Experimental
@Since("2.0.0")
class PolynomialExpansion @Since("2.0.0") (@Since("2.0.0") override val uid: String)
@Since("1.4.0")
class PolynomialExpansion @Since("1.4.0") (@Since("1.4.0") override val uid: String)
extends UnaryTransformer[Vector, Vector, PolynomialExpansion] with DefaultParamsWritable {

@Since("2.0.0")
@Since("1.4.0")
def this() = this(Identifiable.randomUID("poly"))

/**
* The polynomial degree to expand, which should be >= 1. A value of 1 means no expansion.
* Default: 2
* @group param
*/
@Since("2.0.0")
@Since("1.4.0")
val degree = new IntParam(this, "degree", "the polynomial degree to expand (>= 1)",
ParamValidators.gtEq(1))

setDefault(degree -> 2)

/** @group getParam */
@Since("2.0.0")
@Since("1.4.0")
def getDegree: Int = $(degree)

/** @group setParam */
@Since("2.0.0")
@Since("1.4.0")
def setDegree(value: Int): this.type = set(degree, value)

override protected def createTransformFunc: Vector => Vector = { v =>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,7 @@ class Word2VecModel private[ml] (
* of the word. Returns a dataframe with the words and the cosine similarities between the
* synonyms and the given word vector.
*/
@Since("1.5.0")
@Since("2.0.0")
def findSynonyms(word: Vector, num: Int): DataFrame = {
val spark = SparkSession.builder().getOrCreate()
spark.createDataFrame(wordVectors.findSynonyms(word, num)).toDF("word", "similarity")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -286,7 +286,7 @@ object AFTSurvivalRegression extends DefaultParamsReadable[AFTSurvivalRegression
@Since("1.6.0")
class AFTSurvivalRegressionModel private[ml] (
@Since("1.6.0") override val uid: String,
@Since("1.6.0") val coefficients: Vector,
@Since("2.0.0") val coefficients: Vector,
@Since("1.6.0") val intercept: Double,
@Since("1.6.0") val scale: Double)
extends Model[AFTSurvivalRegressionModel] with AFTSurvivalRegressionParams with MLWritable {
Expand All @@ -307,7 +307,7 @@ class AFTSurvivalRegressionModel private[ml] (
@Since("1.6.0")
def setQuantilesCol(value: String): this.type = set(quantilesCol, value)

@Since("1.6.0")
@Since("2.0.0")
def predictQuantiles(features: Vector): Vector = {
// scale parameter for the Weibull distribution of lifetime
val lambda = math.exp(BLAS.dot(coefficients, features) + intercept)
Expand All @@ -319,7 +319,7 @@ class AFTSurvivalRegressionModel private[ml] (
Vectors.dense(quantiles)
}

@Since("1.6.0")
@Since("2.0.0")
def predict(features: Vector): Double = {
math.exp(BLAS.dot(coefficients, features) + intercept)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -221,14 +221,14 @@ class IsotonicRegressionModel private[ml] (
def setFeatureIndex(value: Int): this.type = set(featureIndex, value)

/** Boundaries in increasing order for which predictions are known. */
@Since("1.5.0")
@Since("2.0.0")
def boundaries: Vector = Vectors.dense(oldModel.boundaries)

/**
* Predictions associated with the boundaries at the same index, monotone because of isotonic
* regression.
*/
@Since("1.5.0")
@Since("2.0.0")
def predictions: Vector = Vectors.dense(oldModel.predictions)

@Since("1.5.0")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -387,9 +387,9 @@ object LinearRegression extends DefaultParamsReadable[LinearRegression] {
@Since("1.3.0")
@Experimental
class LinearRegressionModel private[ml] (
override val uid: String,
val coefficients: Vector,
val intercept: Double)
@Since("1.4.0") override val uid: String,
@Since("2.0.0") val coefficients: Vector,
@Since("1.3.0") val intercept: Double)
extends RegressionModel[Vector, LinearRegressionModel]
with LinearRegressionParams with MLWritable {

Expand Down
8 changes: 4 additions & 4 deletions python/pyspark/ml/classification.py
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,7 @@ class LogisticRegressionModel(JavaModel, JavaMLWritable, JavaMLReadable):
"""

@property
@since("1.6.0")
@since("2.0.0")
def coefficients(self):
"""
Model coefficients.
Expand Down Expand Up @@ -1025,15 +1025,15 @@ class NaiveBayesModel(JavaModel, JavaMLWritable, JavaMLReadable):
"""

@property
@since("1.5.0")
@since("2.0.0")
def pi(self):
"""
log of class priors.
"""
return self._call_java("pi")

@property
@since("1.5.0")
@since("2.0.0")
def theta(self):
"""
log of class conditional probabilities.
Expand Down Expand Up @@ -1230,7 +1230,7 @@ def layers(self):
return self._call_java("javaLayers")

@property
@since("1.6.0")
@since("2.0.0")
def weights(self):
"""
vector of initial weights for the model that consists of the weights of layers.
Expand Down
8 changes: 6 additions & 2 deletions python/pyspark/ml/regression.py
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ class LinearRegressionModel(JavaModel, JavaMLWritable, JavaMLReadable):
"""

@property
@since("1.6.0")
@since("2.0.0")
def coefficients(self):
"""
Model coefficients.
Expand Down Expand Up @@ -511,13 +511,15 @@ class IsotonicRegressionModel(JavaModel, JavaMLWritable, JavaMLReadable):
"""

@property
@since("2.0.0")
def boundaries(self):
"""
Boundaries in increasing order for which predictions are known.
"""
return self._call_java("boundaries")

@property
@since("2.0.0")
def predictions(self):
"""
Predictions associated with the boundaries at the same index, monotone because of isotonic
Expand Down Expand Up @@ -1248,7 +1250,7 @@ class AFTSurvivalRegressionModel(JavaModel, JavaMLWritable, JavaMLReadable):
"""

@property
@since("1.6.0")
@since("2.0.0")
def coefficients(self):
"""
Model coefficients.
Expand All @@ -1271,12 +1273,14 @@ def scale(self):
"""
return self._call_java("scale")

@since("2.0.0")
def predictQuantiles(self, features):
"""
Predicted Quantiles
"""
return self._call_java("predictQuantiles", features)

@since("2.0.0")
def predict(self, features):
"""
Predicted value
Expand Down