zhengruifeng commented on a change in pull request #26832: [SPARK-30202][ML][PYSPARK] impl QuantileTransform URL: https://github.com/apache/spark/pull/26832#discussion_r359141753
########## File path: mllib/src/main/scala/org/apache/spark/ml/feature/QuantileTransform.scala ########## @@ -0,0 +1,438 @@ +/* + * 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.feature + +import java.{util => ju} + +import org.apache.commons.math3.distribution.NormalDistribution +import org.apache.hadoop.fs.Path + +import org.apache.spark.annotation.Since +import org.apache.spark.ml.{Estimator, Model} +import org.apache.spark.ml.linalg._ +import org.apache.spark.ml.param._ +import org.apache.spark.ml.param.shared._ +import org.apache.spark.ml.util._ +import org.apache.spark.mllib.util.MLUtils +import org.apache.spark.sql._ +import org.apache.spark.sql.catalyst.util.QuantileSummaries +import org.apache.spark.sql.functions._ +import org.apache.spark.sql.types._ + +/** + * Params for [[QuantileTransform]]. + */ +private[feature] trait QuantileTransformParams extends Params + with HasInputCol with HasOutputCol with HasRelativeError { + + /** + * Number of quantiles to be computed. It corresponds to the number of landmarks used + * to discretize the cumulative distribution function. + * Default: 1000 + * @group param + */ + val numQuantiles: IntParam = new IntParam(this, "numQuantiles", + "Number of quantiles to be computed", ParamValidators.gt(2)) + + /** @group getParam */ + def getNumQuantiles: Int = $(numQuantiles) + + setDefault(numQuantiles -> 1000) + + /** + * Marginal distribution for the transformed data. + * Supported options: "uniform", and "gaussian". + * (default = uniform) + * @group param + */ + val distribution: Param[String] = new Param(this, "distribution", + "Marginal distribution for the transformed data.", + ParamValidators.inArray[String](QuantileTransform.supportedDistributions)) + + /** @group getParam */ + def getDistribution: String = $(distribution) + + setDefault(distribution -> "uniform") + + /** + * Whether the zero entries of the input are discarded to compute the quantile statistics. + * If True, the zero-valued entries of the vectors are discarded to compute the quantile + * statistics. If False, these entries are taken into account. + * Default: false + * + * @group param + */ + val skipZero: BooleanParam = new BooleanParam(this, "skipZero", Review comment: Just to follow sklearn's impl. However, sklearn deal with this param on sparse/dense in differcent way. I think I need to remove this param. ---------------------------------------------------------------- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: [email protected] With regards, Apache Git Services --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
