Back to home page

OSCL-LXR

 
 

    


0001 #
0002 # Licensed to the Apache Software Foundation (ASF) under one or more
0003 # contributor license agreements.  See the NOTICE file distributed with
0004 # this work for additional information regarding copyright ownership.
0005 # The ASF licenses this file to You under the Apache License, Version 2.0
0006 # (the "License"); you may not use this file except in compliance with
0007 # the License.  You may obtain a copy of the License at
0008 #
0009 #    http://www.apache.org/licenses/LICENSE-2.0
0010 #
0011 # Unless required by applicable law or agreed to in writing, software
0012 # distributed under the License is distributed on an "AS IS" BASIS,
0013 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
0014 # See the License for the specific language governing permissions and
0015 # limitations under the License.
0016 #
0017 
0018 from pyspark.mllib.common import inherit_doc, JavaModelWrapper
0019 
0020 
0021 __all__ = ["ChiSqTestResult", "KolmogorovSmirnovTestResult"]
0022 
0023 
0024 class TestResult(JavaModelWrapper):
0025     """
0026     Base class for all test results.
0027     """
0028 
0029     @property
0030     def pValue(self):
0031         """
0032         The probability of obtaining a test statistic result at least as
0033         extreme as the one that was actually observed, assuming that the
0034         null hypothesis is true.
0035         """
0036         return self._java_model.pValue()
0037 
0038     @property
0039     def degreesOfFreedom(self):
0040         """
0041         Returns the degree(s) of freedom of the hypothesis test.
0042         Return type should be Number(e.g. Int, Double) or tuples of Numbers.
0043         """
0044         return self._java_model.degreesOfFreedom()
0045 
0046     @property
0047     def statistic(self):
0048         """
0049         Test statistic.
0050         """
0051         return self._java_model.statistic()
0052 
0053     @property
0054     def nullHypothesis(self):
0055         """
0056         Null hypothesis of the test.
0057         """
0058         return self._java_model.nullHypothesis()
0059 
0060     def __str__(self):
0061         return self._java_model.toString()
0062 
0063 
0064 @inherit_doc
0065 class ChiSqTestResult(TestResult):
0066     """
0067     Contains test results for the chi-squared hypothesis test.
0068     """
0069 
0070     @property
0071     def method(self):
0072         """
0073         Name of the test method
0074         """
0075         return self._java_model.method()
0076 
0077 
0078 @inherit_doc
0079 class KolmogorovSmirnovTestResult(TestResult):
0080     """
0081     Contains test results for the Kolmogorov-Smirnov test.
0082     """