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

    https://github.com/apache/spark/pull/12788#discussion_r62111999
  
    --- Diff: examples/src/main/python/ml/gaussian_mixture_example.py ---
    @@ -0,0 +1,78 @@
    +#
    +# 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 sys
    +
    +import numpy as np
    +# $example on$
    +from pyspark import SparkContext
    +from pyspark.ml.clustering import GaussianMixture, GaussianMixtureModel
    +from pyspark.mllib.linalg import VectorUDT, _convert_to_vector
    +from pyspark.sql import SQLContext
    +from pyspark.sql.types import Row, StructField, StructType
    +# $example off$
    +
    +"""
    +A simple example demonstrating a Gaussian Mixture Model (GMM).
    +Run with:
    +  bin/spark-submit examples/src/main/python/ml/gaussian_mixture_example.py 
<input> <k>
    +"""
    +
    +
    +def parseVector(line):
    +    line_strip = line.strip()
    +    array = np.array([float(x) for x in line_strip.split(' ')])
    +    return _convert_to_vector(array)
    +
    +
    +if __name__ == "__main__":
    +
    +    FEATURES_COL = "features"
    +
    +    if len(sys.argv) != 3:
    +        print("Usage: gaussian_mixture_example.py <file> <k>", 
file=sys.stderr)
    +        exit(-1)
    +    path = sys.argv[1]
    +    k = sys.argv[2]
    +
    +    sc = SparkContext(appName="PythonGuassianMixtureExample")
    +    sqlContext = SQLContext(sc)
    +
    +    # $example on$
    +    lines = sc.textFile(path)
    +    data = lines.map(parseVector)
    +    row_rdd = data.map(lambda x: Row(x))
    +    schema = StructType([StructField(FEATURES_COL, VectorUDT(), False)])
    --- End diff --
    
    you're referencing `FEATURES_COL` here, which is not included in the user 
guide examples. Can you be sure this runs using spark-submit AND copy/paste 
into repl?


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