mob-ai commented on a change in pull request #26124: [SPARK-29224][ML]Implement
Factorization Machines as a ml-pipeline component
URL: https://github.com/apache/spark/pull/26124#discussion_r356380671
##########
File path: python/pyspark/ml/regression.py
##########
@@ -2126,6 +2127,172 @@ def __repr__(self):
return self._call_java("toString")
+@inherit_doc
+class FactorizationMachines(JavaPredictor, HasMaxIter, HasStepSize, HasTol,
HasSolver, HasLoss,
+ JavaMLWritable, JavaMLReadable):
+ """
+ Factorization Machines.
+
+ loss Supports:
+
+ * logisticLoss (default)
+ * squaredError
+
+ solver Supports:
+
+ * gd (normal mini-batch gradient descent)
+ * adamW (default)
+
+ >>> from pyspark.ml.linalg import Vectors
+ >>> from pyspark.ml.regression import FactorizationMachines
+ >>> df = spark.createDataFrame([
+ ... (1.0, Vectors.dense(1.0)),
+ ... (0.0, Vectors.sparse(1, [], []))], ["label", "features"])
+ >>> fm = FactorizationMachines(numFactors=2, )
+ >>> model = fm.fit(df)
+ >>> test0 = spark.createDataFrame([
+ ... (Vectors.dense(-1.0),),
+ ... (Vectors.dense(0.5),),
+ ... (Vectors.dense(1.0),),
+ ... (Vectors.dense(2.0),)], ["features"])
+ >>> model.transform(test0).show(10, False)
+ +--------+----------------------+
+ |features|prediction |
+ +--------+----------------------+
+ |[-1.0] |1.7219239347644947E-10|
+ |[0.5] |0.612429917023823 |
+ |[1.0] |0.99969782036162 |
+ |[2.0] |0.9999999999310394 |
+ +--------+----------------------+
+
+ .. versionadded:: 3.0.0
+ """
+
+ numFactors = Param(Params._dummy(), "numFactors", "dimensionality of the
factor vectors, " +
+ "which are used to get pairwise interactions between
variables",
Review comment:
It is resolved. The doc strings should start with a Capital (dimensionality
of .. -> Dimensionality of ...).
----------------------------------------------------------------
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]