Github user davies commented on a diff in the pull request:
https://github.com/apache/spark/pull/4151#discussion_r23657099
--- Diff: python/pyspark/ml/classification.py ---
@@ -0,0 +1,88 @@
+#
+# 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.
+#
+
+from pyspark.sql import inherit_doc
+from pyspark.ml import JavaEstimator, JavaModel
+from pyspark.ml.param.shared import HasFeaturesCol, HasLabelCol,
HasPredictionCol, HasMaxIter,\
+ HasRegParam
+
+
+@inherit_doc
+class LogisticRegression(JavaEstimator, HasFeaturesCol, HasLabelCol,
HasPredictionCol, HasMaxIter,
+ HasRegParam):
+ """
+ Logistic regression.
+
+ >>> from pyspark.sql import Row
+ >>> from pyspark.mllib.linalg import Vectors
+ >>> dataset = sqlCtx.inferSchema(sc.parallelize([ \
+ Row(label=1.0, features=Vectors.dense(1.0)), \
+ Row(label=0.0, features=Vectors.sparse(1, [], []))]))
+ >>> lr = LogisticRegression() \
+ .setMaxIter(5) \
+ .setRegParam(0.01)
+ >>> model = lr.fit(dataset)
+ >>> test0 =
sqlCtx.inferSchema(sc.parallelize([Row(features=Vectors.dense(-1.0))]))
+ >>> print model.transform(test0).first().prediction
+ 0.0
+ >>> test1 =
sqlCtx.inferSchema(sc.parallelize([Row(features=Vectors.sparse(1, [0],
[1.0]))]))
+ >>> print model.transform(test1).first().prediction
+ 1.0
+ """
+
+ def __init__(self):
+ super(LogisticRegression, self).__init__()
+
+ @property
+ def _java_class(self):
+ return "org.apache.spark.ml.classification.LogisticRegression"
+
+ def _create_model(self, java_model):
+ return LogisticRegressionModel(java_model)
+
+
+@inherit_doc
+class LogisticRegressionModel(JavaModel):
+ """
+ Model fitted by LogisticRegression.
+ """
+
+ def __init__(self, java_model):
+ super(LogisticRegressionModel, self).__init__()
+ self._java_model = java_model
--- End diff --
I'd like to move this into JavaModel
---
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 [email protected] or file a JIRA ticket
with INFRA.
---
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]