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

    https://github.com/apache/spark/pull/12920#discussion_r62282420
  
    --- Diff: examples/src/main/python/ml/one_vs_rest_example.py ---
    @@ -0,0 +1,125 @@
    +#
    +# 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 __future__ import print_function
    +
    +import argparse
    +
    +from pyspark import SparkContext
    +
    +# $example on$
    +from pyspark.ml.classification import LogisticRegression, OneVsRest
    +from pyspark.mllib.evaluation import MulticlassMetrics
    +from pyspark.sql import SQLContext
    +# $example off$
    +
    +"""
    +An example runner for Multiclass to Binary Reduction with One Vs Rest.
    +The example uses Logistic Regression as the base classifier. All 
parameters that
    +can be specified on the base classifier can be passed in to the runner 
options.
    +Run with:
    +
    +  bin/spark-submit examples/src/main/python/ml/one_vs_rest_example.py
    +"""
    +
    +
    +def parse():
    +    parser = argparse.ArgumentParser()
    +    parser.add_argument("--input",
    +                        help="input path to labeled examples. This path 
must be specified")
    +    parser.add_argument("--fracTest", type=float, default=0.2,
    +                        help="fraction of data to hold out for testing.  
If given option testInput,"
    +                             " this option is ignored. default: 0.2")
    +    parser.add_argument("--testInput",
    +                        help="iinput path to test dataset. If given, 
option fracTest is ignored")
    +    parser.add_argument("--maxIter", type=int, default=100,
    +                        help="maximum number of iterations for Logistic 
Regression. default: 100")
    +    parser.add_argument("--tol", type=float, default=1e-6,
    +                        help="the convergence tolerance of iterations for 
Logistic Regression."
    +                             " default: 1e-6")
    +    parser.add_argument("--fitIntercept", default="true",
    +                        help="fit intercept for Logistic Regression. 
default: true")
    +    parser.add_argument("--regParam", type=float,
    +                        help="the regularization parameter for Logistic 
Regression. default: None")
    +    parser.add_argument("--elasticNetParam", type=float,
    +                        help="the ElasticNet mixing parameter for Logistic 
Regression. default:"
    +                             " None")
    +    params = parser.parse_args()
    +
    +    assert params.input is not None, "input is required"
    +    assert 0 <= params.fracTest < 1, "fracTest value incorrect; should be 
in [0,1)."
    +    assert params.fitIntercept in ("true", "false")
    +    params.fitIntercept = params.fitIntercept == "true"
    +
    +    return params
    +
    +if __name__ == "__main__":
    +
    +    params = parse()
    +
    +    sc = SparkContext(appName="PythonOneVsRestExample")
    --- End diff --
    
    Thanks!


---
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]

Reply via email to