Github user feynmanliang commented on a diff in the pull request:

    https://github.com/apache/spark/pull/9513#discussion_r44202484
  
    --- Diff: mllib/src/main/scala/org/apache/spark/ml/clustering/LDA.scala ---
    @@ -0,0 +1,740 @@
    +/*
    + * 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.spark.ml.clustering
    +
    +import org.apache.spark.Logging
    +import org.apache.spark.annotation.{Experimental, Since}
    +import org.apache.spark.ml.util.{SchemaUtils, Identifiable}
    +import org.apache.spark.ml.{Estimator, Model}
    +import org.apache.spark.ml.param.shared.{HasCheckpointInterval, 
HasFeaturesCol, HasSeed, HasMaxIter}
    +import org.apache.spark.ml.param._
    +import org.apache.spark.mllib.clustering.{DistributedLDAModel => 
OldDistributedLDAModel,
    +    EMLDAOptimizer => OldEMLDAOptimizer, LDA => OldLDA, LDAModel => 
OldLDAModel,
    +    LDAOptimizer => OldLDAOptimizer, LocalLDAModel => OldLocalLDAModel,
    +    OnlineLDAOptimizer => OldOnlineLDAOptimizer}
    +import org.apache.spark.mllib.linalg.{VectorUDT, Vectors, Matrix, Vector}
    +import org.apache.spark.rdd.RDD
    +import org.apache.spark.sql.{SQLContext, DataFrame, Row}
    +import org.apache.spark.sql.functions.{col, monotonicallyIncreasingId, udf}
    +import org.apache.spark.sql.types.StructType
    +
    +
    +private[clustering] trait LDAParams extends Params with HasFeaturesCol 
with HasMaxIter
    +  with HasSeed with HasCheckpointInterval {
    +
    +  /**
    +   * Param for the number of topics (clusters). Must be > 1. Default: 10.
    +   * @group param
    +   */
    +  @Since("1.6.0")
    +  final val k = new IntParam(this, "k", "number of clusters to create", 
ParamValidators.gt(1))
    +
    +  /** @group getParam */
    +  @Since("1.6.0")
    +  def getK: Int = $(k)
    +
    +  /**
    +   * Concentration parameter (commonly named "alpha") for the prior placed 
on documents'
    +   * distributions over topics ("theta").
    +   *
    +   * This is the parameter to a Dirichlet distribution, where larger 
values mean more smoothing
    +   * (more regularization).
    +   *
    +   * If set to a singleton vector [-1], then docConcentration is set 
automatically. If set to
    +   * singleton vector [alpha] where alpha != -1, then alpha is replicated 
to a vector of
    +   * length k in fitting. Otherwise, the [[docConcentration]] vector must 
be length k.
    +   * (default = [-1] = automatic)
    +   *
    +   * Optimizer-specific parameter settings:
    +   *  - EM
    +   *     - Currently only supports symmetric distributions, so all values 
in the vector should be
    +   *       the same.
    +   *     - Values should be > 1.0
    --- End diff --
    
    IMO this validation logic is quite confusing and was there for backwards 
compatibility. Since we have this opportunity to implement a new API, I suggest:
     * Ditching the singleton vector option, requiring the user to specify a 
length `k` vector
     * Keeping the automatic init as the default, making the API easy for 
novice users
    
    The only feature that is lost is replication of `docConcentration` > 0 to a 
symmetric prior


---
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 infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org
For additional commands, e-mail: reviews-h...@spark.apache.org

Reply via email to