Skip to content

Commit

Permalink
fix float
Browse files Browse the repository at this point in the history
  • Loading branch information
Davies Liu committed Nov 4, 2014
1 parent 5097d54 commit 0ab0764
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions python/pyspark/mllib/stat.py
Original file line number Diff line number Diff line change
Expand Up @@ -220,11 +220,11 @@ def chiSqTest(observed, expected=None):
>>> from pyspark.mllib.linalg import Vectors, Matrices
>>> observed = Vectors.dense([4, 6, 5])
>>> pearson = Statistics.chiSqTest(observed)
>>> pearson.statistic
>>> print pearson.statistic
0.4
>>> pearson.degreesOfFreedom
2
>>> round(pearson.pValue, 4)
>>> print round(pearson.pValue, 4)
0.8187
>>> pearson.method
u'pearson'
Expand All @@ -234,13 +234,13 @@ def chiSqTest(observed, expected=None):
>>> observed = Vectors.dense([21, 38, 43, 80])
>>> expected = Vectors.dense([3, 5, 7, 20])
>>> pearson = Statistics.chiSqTest(observed, expected)
>>> round(pearson.pValue, 4)
>>> print round(pearson.pValue, 4)
0.0027
>>> data = [40.0, 24.0, 29.0, 56.0, 32.0, 42.0, 31.0, 10.0, 0.0, 30.0, 15.0, 12.0]
>>> chi = Statistics.chiSqTest(Matrices.dense(3, 4, data))
>>> round(chi.statistic)
22.0
>>> print round(chi.statistic, 4)
21.9958
>>> from pyspark.mllib.regression import LabeledPoint
>>> data = [LabeledPoint(0.0, Vectors.dense([0.5, 10.0])),
Expand All @@ -251,9 +251,9 @@ def chiSqTest(observed, expected=None):
... LabeledPoint(1.0, Vectors.dense([3.5, 40.0])),]
>>> rdd = sc.parallelize(data, 4)
>>> chi = Statistics.chiSqTest(rdd)
>>> chi[0].statistic
>>> print chi[0].statistic
0.75
>>> chi[1].statistic
>>> print chi[1].statistic
1.5
"""
if isinstance(observed, RDD):
Expand Down

0 comments on commit 0ab0764

Please sign in to comment.