Skip to content

Commit d75a7d6

Browse files
committed
[SPARK-51217][ML][CONNECT] ML model helper constructor clean up
### What changes were proposed in this pull request? ML model helper constructor clean up: 1, add comments; 2, set invalid values, e.g. empty uid, NaN efficient ### Why are the changes needed? 1, to avoid unintentionally incorrect usage; 2, to differentiate from normal models; ### Does this PR introduce _any_ user-facing change? no, internal change ### How was this patch tested? existing tests ### Was this patch authored or co-authored using generative AI tooling? no Closes #49956 from zhengruifeng/ml_connect_const. Authored-by: Ruifeng Zheng <[email protected]> Signed-off-by: Ruifeng Zheng <[email protected]>
1 parent b3dac88 commit d75a7d6

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+73
-68
lines changed

mllib/src/main/scala/org/apache/spark/ml/classification/DecisionTreeClassifier.scala

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -193,8 +193,7 @@ class DecisionTreeClassificationModel private[ml] (
193193
this(Identifiable.randomUID("dtc"), rootNode, numFeatures, numClasses)
194194

195195
// For ml connect only
196-
@Since("4.0.0")
197-
private[ml] def this() = this(Node.dummyNode, 0, 0)
196+
private[ml] def this() = this("", Node.dummyNode, -1, -1)
198197

199198
override def predict(features: Vector): Double = {
200199
rootNode.predictImpl(features).prediction

mllib/src/main/scala/org/apache/spark/ml/classification/FMClassifier.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -259,8 +259,8 @@ class FMClassificationModel private[classification] (
259259
with FMClassifierParams with MLWritable
260260
with HasTrainingSummary[FMClassificationTrainingSummary]{
261261

262-
private[ml] def this() = this(Identifiable.randomUID("fmc"),
263-
Double.NaN, Vectors.empty, Matrices.empty)
262+
// For ml connect only
263+
private[ml] def this() = this("", Double.NaN, Vectors.empty, Matrices.empty)
264264

265265
@Since("3.0.0")
266266
override val numClasses: Int = 2

mllib/src/main/scala/org/apache/spark/ml/classification/GBTClassifier.scala

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -273,9 +273,8 @@ class GBTClassificationModel private[ml](
273273
this(uid, _trees, _treeWeights, -1, 2)
274274

275275
// For ml connect only
276-
@Since("4.0.0")
277-
private[ml] def this() = this(Identifiable.randomUID("gbtc"),
278-
Array(new DecisionTreeRegressionModel), Array(0.0))
276+
private[ml] def this() = this("",
277+
Array(new DecisionTreeRegressionModel), Array(Double.NaN), -1, -1)
279278

280279
@Since("1.4.0")
281280
override def trees: Array[DecisionTreeRegressionModel] = _trees

mllib/src/main/scala/org/apache/spark/ml/classification/LinearSVC.scala

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -365,7 +365,8 @@ class LinearSVCModel private[classification] (
365365
extends ClassificationModel[Vector, LinearSVCModel]
366366
with LinearSVCParams with MLWritable with HasTrainingSummary[LinearSVCTrainingSummary] {
367367

368-
private[ml] def this() = this(Identifiable.randomUID("linearsvc"), Vectors.empty, 0.0)
368+
// For ml connect only
369+
private[ml] def this() = this("", Vectors.empty, Double.NaN)
369370

370371
@Since("2.2.0")
371372
override val numClasses: Int = 2

mllib/src/main/scala/org/apache/spark/ml/classification/LogisticRegression.scala

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1077,8 +1077,7 @@ class LogisticRegressionModel private[spark] (
10771077
Vectors.dense(intercept), 2, isMultinomial = false)
10781078

10791079
// For ml connect only
1080-
@Since("4.0.0")
1081-
private[ml] def this() = this(Identifiable.randomUID("logreg"), Vectors.empty, 0)
1080+
private[ml] def this() = this("", Matrices.empty, Vectors.empty, -1, false)
10821081

10831082
/**
10841083
* A vector of model coefficients for "binomial" logistic regression. If this model was trained

mllib/src/main/scala/org/apache/spark/ml/classification/MultilayerPerceptronClassifier.scala

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -283,7 +283,8 @@ class MultilayerPerceptronClassificationModel private[ml] (
283283
with MultilayerPerceptronParams with Serializable with MLWritable
284284
with HasTrainingSummary[MultilayerPerceptronClassificationTrainingSummary]{
285285

286-
private[ml] def this() = this(Identifiable.randomUID("mlpc"), Vectors.empty)
286+
// For ml connect only
287+
private[ml] def this() = this("", Vectors.empty)
287288

288289
@Since("1.6.0")
289290
override lazy val numFeatures: Int = $(layers).head

mllib/src/main/scala/org/apache/spark/ml/classification/NaiveBayes.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -401,8 +401,8 @@ class NaiveBayesModel private[ml] (
401401

402402
import NaiveBayes._
403403

404-
private[ml] def this() = this(Identifiable.randomUID("nb"),
405-
Vectors.empty, Matrices.empty, Matrices.empty)
404+
// For ml connect only
405+
private[ml] def this() = this("", Vectors.empty, Matrices.empty, Matrices.empty)
406406

407407
/**
408408
* mllib NaiveBayes is a wrapper of ml implementation currently.

mllib/src/main/scala/org/apache/spark/ml/classification/RandomForestClassifier.scala

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -256,8 +256,7 @@ class RandomForestClassificationModel private[ml] (
256256
this(Identifiable.randomUID("rfc"), trees, numFeatures, numClasses)
257257

258258
// For ml connect only
259-
@Since("4.0.0")
260-
private[ml] def this() = this(Array(new DecisionTreeClassificationModel), 0, 0)
259+
private[ml] def this() = this("", Array(new DecisionTreeClassificationModel), -1, -1)
261260

262261
@Since("1.4.0")
263262
override def trees: Array[DecisionTreeClassificationModel] = _trees

mllib/src/main/scala/org/apache/spark/ml/clustering/BisectingKMeans.scala

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -96,9 +96,8 @@ class BisectingKMeansModel private[ml] (
9696
extends Model[BisectingKMeansModel] with BisectingKMeansParams with MLWritable
9797
with HasTrainingSummary[BisectingKMeansSummary] {
9898

99-
@Since("4.0.0")
100-
private[ml] def this() = this(Identifiable.randomUID("bisecting-kmeans"),
101-
new MLlibBisectingKMeansModel(null))
99+
// For ml connect only
100+
private[ml] def this() = this("", null)
102101

103102
@Since("3.0.0")
104103
lazy val numFeatures: Int = parentModel.clusterCenters.head.size

mllib/src/main/scala/org/apache/spark/ml/clustering/GaussianMixture.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -93,8 +93,8 @@ class GaussianMixtureModel private[ml] (
9393
extends Model[GaussianMixtureModel] with GaussianMixtureParams with MLWritable
9494
with HasTrainingSummary[GaussianMixtureSummary] {
9595

96-
private[ml] def this() = this(Identifiable.randomUID("gmm"),
97-
Array.emptyDoubleArray, Array.empty)
96+
// For ml connect only
97+
private[ml] def this() = this("", Array.emptyDoubleArray, Array.empty)
9898

9999
@Since("3.0.0")
100100
lazy val numFeatures: Int = gaussians.head.mean.size

mllib/src/main/scala/org/apache/spark/ml/clustering/KMeans.scala

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -139,9 +139,7 @@ class KMeansModel private[ml] (
139139
with HasTrainingSummary[KMeansSummary] {
140140

141141
// For ml connect only
142-
@Since("4.0.0")
143-
private[ml] def this() = this(Identifiable.randomUID("kmeans"),
144-
new MLlibKMeansModel(clusterCenters = null))
142+
private[ml] def this() = this("", null)
145143

146144
@Since("3.0.0")
147145
lazy val numFeatures: Int = parentModel.clusterCenters.head.size

mllib/src/main/scala/org/apache/spark/ml/clustering/LDA.scala

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -617,7 +617,8 @@ class LocalLDAModel private[ml] (
617617
sparkSession: SparkSession)
618618
extends LDAModel(uid, vocabSize, sparkSession) {
619619

620-
private[ml] def this() = this(Identifiable.randomUID("lda"), -1, null, null)
620+
// For ml connect only
621+
private[ml] def this() = this("", -1, null, null)
621622

622623
oldLocalModel.setSeed(getSeed)
623624

@@ -715,7 +716,8 @@ class DistributedLDAModel private[ml] (
715716
private var oldLocalModelOption: Option[OldLocalLDAModel])
716717
extends LDAModel(uid, vocabSize, sparkSession) {
717718

718-
private[ml] def this() = this(Identifiable.randomUID("lda"), -1, null, null, None)
719+
// For ml connect only
720+
private[ml] def this() = this("", -1, null, null, None)
719721

720722
override private[clustering] def oldLocalModel: OldLocalLDAModel = {
721723
if (oldLocalModelOption.isEmpty) {

mllib/src/main/scala/org/apache/spark/ml/feature/BucketedRandomProjectionLSH.scala

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,8 @@ class BucketedRandomProjectionLSHModel private[ml](
6868
private[ml] val randMatrix: Matrix)
6969
extends LSHModel[BucketedRandomProjectionLSHModel] with BucketedRandomProjectionLSHParams {
7070

71-
private[ml] def this() = this(Identifiable.randomUID("brp-lsh"), Matrices.empty)
71+
// For ml connect only
72+
private[ml] def this() = this("", Matrices.empty)
7273

7374
private[ml] def this(uid: String, randUnitVectors: Array[Vector]) = {
7475
this(uid, Matrices.fromVectors(randUnitVectors.toImmutableArraySeq))

mllib/src/main/scala/org/apache/spark/ml/feature/ChiSqSelector.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -137,8 +137,8 @@ final class ChiSqSelectorModel private[ml] (
137137

138138
import ChiSqSelectorModel._
139139

140-
private[ml] def this() = this(
141-
Identifiable.randomUID("chiSqSelector"), Array.emptyIntArray)
140+
// For ml connect only
141+
private[ml] def this() = this("", Array.emptyIntArray)
142142

143143
override protected def isNumericAttribute = false
144144

mllib/src/main/scala/org/apache/spark/ml/feature/CountVectorizer.scala

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -277,7 +277,8 @@ class CountVectorizerModel(
277277

278278
import CountVectorizerModel._
279279

280-
private[ml] def this() = this(Identifiable.randomUID("cntVecModel"), Array.empty)
280+
// For ml connect only
281+
private[ml] def this() = this("", Array.empty)
281282

282283
@Since("1.5.0")
283284
def this(vocabulary: Array[String]) = {

mllib/src/main/scala/org/apache/spark/ml/feature/IDF.scala

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,8 @@ class IDFModel private[ml] (
121121

122122
import IDFModel._
123123

124-
private[ml] def this() = this(Identifiable.randomUID("idf"), null)
124+
// For ml connect only
125+
private[ml] def this() = this("", null)
125126

126127
/** @group setParam */
127128
@Since("1.4.0")

mllib/src/main/scala/org/apache/spark/ml/feature/Imputer.scala

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -246,7 +246,8 @@ class ImputerModel private[ml] (
246246

247247
import ImputerModel._
248248

249-
private[ml] def this() = this(Identifiable.randomUID("imputer"), null)
249+
// For ml connect only
250+
private[ml] def this() = this("", null)
250251

251252
/** @group setParam */
252253
@Since("3.0.0")

mllib/src/main/scala/org/apache/spark/ml/feature/MaxAbsScaler.scala

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,8 @@ class MaxAbsScalerModel private[ml] (
107107

108108
import MaxAbsScalerModel._
109109

110-
private[ml] def this() = this(Identifiable.randomUID("maxAbsScal"), Vectors.empty)
110+
// For ml connect only
111+
private[ml] def this() = this("", Vectors.empty)
111112

112113
/** @group setParam */
113114
@Since("2.0.0")

mllib/src/main/scala/org/apache/spark/ml/feature/MinHashLSH.scala

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,8 @@ class MinHashLSHModel private[ml](
4848
private[ml] val randCoefficients: Array[(Int, Int)])
4949
extends LSHModel[MinHashLSHModel] {
5050

51-
private[ml] def this() = this(Identifiable.randomUID("mh-lsh"), Array.empty)
51+
// For ml connect only
52+
private[ml] def this() = this("", Array.empty)
5253

5354
/** @group setParam */
5455
@Since("2.4.0")

mllib/src/main/scala/org/apache/spark/ml/feature/MinMaxScaler.scala

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,8 @@ class MinMaxScalerModel private[ml] (
154154

155155
import MinMaxScalerModel._
156156

157-
private[ml] def this() = this(Identifiable.randomUID("minMaxScal"), Vectors.empty, Vectors.empty)
157+
// For ml connect only
158+
private[ml] def this() = this("", Vectors.empty, Vectors.empty)
158159

159160
/** @group setParam */
160161
@Since("1.5.0")

mllib/src/main/scala/org/apache/spark/ml/feature/OneHotEncoder.scala

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -234,7 +234,8 @@ class OneHotEncoderModel private[ml] (
234234

235235
import OneHotEncoderModel._
236236

237-
private[ml] def this() = this(Identifiable.randomUID("oneHotEncoder)"), Array.emptyIntArray)
237+
// For ml connect only
238+
private[ml] def this() = this("", Array.emptyIntArray)
238239

239240
// Returns the category size for each index with `dropLast` and `handleInvalid`
240241
// taken into account.

mllib/src/main/scala/org/apache/spark/ml/feature/PCA.scala

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -128,9 +128,7 @@ class PCAModel private[ml] (
128128
import PCAModel._
129129

130130
// For ml connect only
131-
@Since("4.0.0")
132-
private[ml] def this() = this(Identifiable.randomUID("pca"),
133-
DenseMatrix.zeros(1, 1), Vectors.empty)
131+
private[ml] def this() = this("", Matrices.empty, Vectors.empty)
134132

135133
/** @group setParam */
136134
@Since("1.5.0")

mllib/src/main/scala/org/apache/spark/ml/feature/RFormula.scala

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -349,7 +349,8 @@ class RFormulaModel private[feature](
349349
private[ml] val pipelineModel: PipelineModel)
350350
extends Model[RFormulaModel] with RFormulaBase with MLWritable {
351351

352-
private[ml] def this() = this(Identifiable.randomUID("rFormula"), null, null)
352+
// For ml connect only
353+
private[ml] def this() = this("", null, null)
353354

354355
@Since("2.0.0")
355356
override def transform(dataset: Dataset[_]): DataFrame = {

mllib/src/main/scala/org/apache/spark/ml/feature/RobustScaler.scala

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -230,7 +230,8 @@ class RobustScalerModel private[ml] (
230230

231231
import RobustScalerModel._
232232

233-
private[ml] def this() = this(Identifiable.randomUID("robustScal"), Vectors.empty, Vectors.empty)
233+
// For ml connect only
234+
private[ml] def this() = this("", Vectors.empty, Vectors.empty)
234235

235236
/** @group setParam */
236237
def setInputCol(value: String): this.type = set(inputCol, value)

mllib/src/main/scala/org/apache/spark/ml/feature/StandardScaler.scala

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,8 @@ class StandardScalerModel private[ml] (
147147

148148
import StandardScalerModel._
149149

150-
private[ml] def this() = this(Identifiable.randomUID("stdScal"), Vectors.empty, Vectors.empty)
150+
// For ml connect only
151+
private[ml] def this() = this("", Vectors.empty, Vectors.empty)
151152

152153
/** @group setParam */
153154
@Since("1.2.0")

mllib/src/main/scala/org/apache/spark/ml/feature/StringIndexer.scala

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -302,8 +302,7 @@ class StringIndexerModel (
302302
def this(labelsArray: Array[Array[String]]) = this(Identifiable.randomUID("strIdx"), labelsArray)
303303

304304
// For ml connect only
305-
@Since("4.0.0")
306-
private[ml] def this() = this(labels = Array.empty)
305+
private[ml] def this() = this("", Array.empty[Array[String]])
307306

308307
@deprecated("`labels` is deprecated and will be removed in 3.1.0. Use `labelsArray` " +
309308
"instead.", "3.0.0")

mllib/src/main/scala/org/apache/spark/ml/feature/TargetEncoder.scala

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -286,7 +286,8 @@ class TargetEncoderModel private[ml] (
286286
@Since("4.0.0") private[ml] val stats: Array[Map[Double, (Double, Double)]])
287287
extends Model[TargetEncoderModel] with TargetEncoderBase with MLWritable {
288288

289-
private[ml] def this() = this(Identifiable.randomUID("TargetEncoder"), Array.empty)
289+
// For ml connect only
290+
private[ml] def this() = this("", Array.empty)
290291

291292
/** @group setParam */
292293
@Since("4.0.0")

mllib/src/main/scala/org/apache/spark/ml/feature/UnivariateFeatureSelector.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -289,8 +289,8 @@ class UnivariateFeatureSelectorModel private[ml](
289289
extends Model[UnivariateFeatureSelectorModel] with UnivariateFeatureSelectorParams
290290
with MLWritable {
291291

292-
private[ml] def this() = this(
293-
Identifiable.randomUID("UnivariateFeatureSelector"), Array.emptyIntArray)
292+
// For ml connect only
293+
private[ml] def this() = this("", Array.emptyIntArray)
294294

295295
/** @group setParam */
296296
@Since("3.1.1")

mllib/src/main/scala/org/apache/spark/ml/feature/VarianceThresholdSelector.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -126,8 +126,8 @@ class VarianceThresholdSelectorModel private[ml](
126126
extends Model[VarianceThresholdSelectorModel] with VarianceThresholdSelectorParams
127127
with MLWritable {
128128

129-
private[ml] def this() = this(
130-
Identifiable.randomUID("VarianceThresholdSelector"), Array.emptyIntArray)
129+
// For ml connect only
130+
private[ml] def this() = this("", Array.emptyIntArray)
131131

132132
if (selectedFeatures.length >= 2) {
133133
require(selectedFeatures.sliding(2).forall(l => l(0) < l(1)),

mllib/src/main/scala/org/apache/spark/ml/feature/VectorIndexer.scala

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -298,7 +298,8 @@ class VectorIndexerModel private[ml] (
298298

299299
import VectorIndexerModel._
300300

301-
private[ml] def this() = this(Identifiable.randomUID("vecIdx"), -1, Map.empty)
301+
// For ml connect only
302+
private[ml] def this() = this("", -1, Map.empty)
302303

303304
/** Java-friendly version of [[categoryMaps]] */
304305
@Since("1.4.0")

mllib/src/main/scala/org/apache/spark/ml/feature/Word2Vec.scala

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -211,7 +211,8 @@ class Word2VecModel private[ml] (
211211

212212
import Word2VecModel._
213213

214-
private[ml] def this() = this(Identifiable.randomUID("w2v"), null)
214+
// For ml connect only
215+
private[ml] def this() = this("", null)
215216

216217
/**
217218
* Returns a dataframe with two fields, "word" and "vector", with "word" being a String and

mllib/src/main/scala/org/apache/spark/ml/fpm/FPGrowth.scala

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -223,7 +223,8 @@ class FPGrowthModel private[ml] (
223223
private val numTrainingRecords: Long)
224224
extends Model[FPGrowthModel] with FPGrowthParams with MLWritable {
225225

226-
private[ml] def this() = this(Identifiable.randomUID("fpgrowth"), null, Map.empty, 0L)
226+
// For ml connect only
227+
private[ml] def this() = this("", null, Map.empty, -1L)
227228

228229
/** @group setParam */
229230
@Since("2.2.0")

mllib/src/main/scala/org/apache/spark/ml/recommendation/ALS.scala

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -281,8 +281,7 @@ class ALSModel private[ml] (
281281
extends Model[ALSModel] with ALSModelParams with MLWritable {
282282

283283
// For ml connect only
284-
@Since("4.0.0")
285-
private[ml] def this() = this(Identifiable.randomUID("als"), 0, null, null)
284+
private[ml] def this() = this("", -1, null, null)
286285

287286
/** @group setParam */
288287
@Since("1.4.0")

mllib/src/main/scala/org/apache/spark/ml/regression/AFTSurvivalRegression.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -371,8 +371,8 @@ class AFTSurvivalRegressionModel private[ml] (
371371
extends RegressionModel[Vector, AFTSurvivalRegressionModel] with AFTSurvivalRegressionParams
372372
with MLWritable {
373373

374-
private[ml] def this() = this(Identifiable.randomUID("aftSurvReg"),
375-
Vectors.empty, Double.NaN, Double.NaN)
374+
// For ml connect only
375+
private[ml] def this() = this("", Vectors.empty, Double.NaN, Double.NaN)
376376

377377
@Since("3.0.0")
378378
override def numFeatures: Int = coefficients.size

mllib/src/main/scala/org/apache/spark/ml/regression/DecisionTreeRegressor.scala

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -188,8 +188,7 @@ class DecisionTreeRegressionModel private[ml] (
188188
this(Identifiable.randomUID("dtr"), rootNode, numFeatures)
189189

190190
// For ml connect only
191-
@Since("4.0.0")
192-
private[ml] def this() = this(Node.dummyNode, 0)
191+
private[ml] def this() = this("", Node.dummyNode, -1)
193192

194193
override def predict(features: Vector): Double = {
195194
rootNode.predictImpl(features).prediction

mllib/src/main/scala/org/apache/spark/ml/regression/FMRegressor.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -461,8 +461,8 @@ class FMRegressionModel private[regression] (
461461
extends RegressionModel[Vector, FMRegressionModel]
462462
with FMRegressorParams with MLWritable {
463463

464-
private[ml] def this() = this(Identifiable.randomUID("fmr"),
465-
Double.NaN, Vectors.empty, Matrices.empty)
464+
// For ml connect only
465+
private[ml] def this() = this("", Double.NaN, Vectors.empty, Matrices.empty)
466466

467467
@Since("3.0.0")
468468
override val numFeatures: Int = linear.size

mllib/src/main/scala/org/apache/spark/ml/regression/GBTRegressor.scala

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -243,9 +243,7 @@ class GBTRegressionModel private[ml](
243243
this(uid, _trees, _treeWeights, -1)
244244

245245
// For ml connect only
246-
@Since("4.0.0")
247-
private[ml] def this() = this(Identifiable.randomUID("gbtr"),
248-
Array(new DecisionTreeRegressionModel), Array(0.0))
246+
private[ml] def this() = this("", Array(new DecisionTreeRegressionModel), Array(Double.NaN), -1)
249247

250248
@Since("1.4.0")
251249
override def trees: Array[DecisionTreeRegressionModel] = _trees

0 commit comments

Comments
 (0)