Skip to content

Commit

Permalink
fix tests in python 3
Browse files Browse the repository at this point in the history
  • Loading branch information
mengxr committed May 5, 2015
1 parent babdde7 commit 25d7451
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 7 deletions.
11 changes: 5 additions & 6 deletions python/pyspark/ml/evaluation.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,10 @@ class BinaryClassificationEvaluator(JavaEvaluator, HasLabelCol, HasRawPrediction
columns: rawPrediction and label.
>>> from pyspark.mllib.linalg import Vectors
>>> scoreAndLabels = sc.parallelize([
... (0.1, 0.0), (0.1, 1.0), (0.4, 0.0), (0.6, 0.0), (0.6, 1.0), (0.6, 1.0), (0.8, 1.0)])
>>> rawPredictionAndLabels = scoreAndLabels.map(
... lambda x: (Vectors.dense([1.0 - x[0], x[0]]), x[1]))
>>> dataset = rawPredictionAndLabels.toDF(["raw", "label"])
>>> scoreAndLabels = map(lambda x: (Vectors.dense([1.0 - x[0], x[0]]), x[1]),
... [(0.1, 0.0), (0.1, 1.0), (0.4, 0.0), (0.6, 0.0), (0.6, 1.0), (0.6, 1.0), (0.8, 1.0)])
>>> dataset = sqlContext.createDataFrame(scoreAndLabels, ["raw", "label"])
...
>>> evaluator = BinaryClassificationEvaluator(rawPredictionCol="raw")
>>> evaluator.evaluate(dataset)
0.70...
Expand Down Expand Up @@ -97,7 +96,7 @@ def setParams(self, rawPredictionCol="rawPrediction", labelCol="label",
globs = globals().copy()
# The small batch size here ensures that we see multiple batches,
# even in these small test examples:
sc = SparkContext("local[2]", "ml.feature tests")
sc = SparkContext("local[2]", "ml.evaluation tests")
sqlContext = SQLContext(sc)
globs['sc'] = sc
globs['sqlContext'] = sqlContext
Expand Down
2 changes: 1 addition & 1 deletion python/pyspark/sql/_types.py
Original file line number Diff line number Diff line change
Expand Up @@ -652,7 +652,7 @@ def _python_to_sql_converter(dataType):

if isinstance(dataType, StructType):
names, types = zip(*[(f.name, f.dataType) for f in dataType.fields])
converters = map(_python_to_sql_converter, types)
converters = [_python_to_sql_converter(t) for t in types]

def converter(obj):
if isinstance(obj, dict):
Expand Down

0 comments on commit 25d7451

Please sign in to comment.