Changeset 10346:c99dada8a093 in orange for docs/reference/rst/Orange.classification.logreg.rst
Legend:
 Unmodified
 Added
 Removed

docs/reference/rst/Orange.classification.logreg.rst
r10246 r10346 9 9 ******************************** 10 10 11 `Logistic regression <http://en.wikipedia.org/wiki/Logistic_regression>`_ 12 is a statistical classification methods that fits data to a logistic 13 function. Orange's implementation of algorithm 14 can handle various anomalies in features, such as constant variables and 15 singularities, that could make direct fitting of logistic regression almost 16 impossible. Stepwise logistic regression, which iteratively selects the most 17 informative features, is also supported. 11 `Logistic regression 12 <http://en.wikipedia.org/wiki/Logistic_regression>`_ is a statistical 13 classification method that fits data to a logistic function. Orange 14 provides various enhancement of the method, such as stepwise selection 15 of variables and handling of constant variables and singularities. 18 16 19 17 .. autoclass:: LogRegLearner … … 44 42 that beta coefficients differ from 0.0. The probability is 45 43 computed from squared Wald Z statistics that is distributed with 46 ChiSquaredistribution.44 chisquared distribution. 47 45 48 46 .. attribute :: likelihood 49 47 50 The probability of the sample (ie. learning examples) observed on 51 the basis of the derived model, as a function of the regression 52 parameters. 48 The likelihood of the sample (ie. learning data) given the 49 fitted model. 53 50 54 51 .. attribute :: fit_status 55 52 56 Tells how the model fitting ended  either regularly 57 (:obj:`LogRegFitter.OK`), or it was interrupted due to one of beta 58 coefficients escaping towards infinity (:obj:`LogRegFitter.Infinity`) 59 or since the values didn't converge (:obj:`LogRegFitter.Divergence`). The 60 value tells about the classifier's "reliability"; the classifier 61 itself is useful in either case. 53 Tells how the model fitting ended, either regularly 54 (:obj:`LogRegFitter.OK`), or it was interrupted due to one of 55 beta coefficients escaping towards infinity 56 (:obj:`LogRegFitter.Infinity`) or since the values did not 57 converge (:obj:`LogRegFitter.Divergence`). 58 59 Although the model is functional in all cases, it is 60 recommended to inspect whether the coefficients of the model 61 if the fitting did not end normally. 62 62 63 63 .. method:: __call__(instance, result_type) … … 78 78 .. class:: LogRegFitter 79 79 80 :obj:`LogRegFitter` is the abstract base class for logistic fitters. It 81 defines the form of call operator and the constants denoting its 82 (un)success: 83 84 .. attribute:: OK 85 86 Fitter succeeded to converge to the optimal fit. 87 88 .. attribute:: Infinity 89 90 Fitter failed due to one or more beta coefficients escaping towards infinity. 91 92 .. attribute:: Divergence 93 94 Beta coefficients failed to converge, but none of beta coefficients escaped. 95 96 .. attribute:: Constant 97 98 There is a constant attribute that causes the matrix to be singular. 99 100 .. attribute:: Singularity 101 102 The matrix is singular. 80 :obj:`LogRegFitter` is the abstract base class for logistic 81 fitters. Fitters can be called with a data table and return a 82 vector of coefficients and the corresponding statistics, or a 83 status signifying an error. The possible statuses are 84 85 .. attribute:: OK 86 87 Optimization converged 88 89 .. attribute:: Infinity 90 91 Optimization failed due to one or more beta coefficients 92 escaping towards infinity. 93 94 .. attribute:: Divergence 95 96 Beta coefficients failed to converge, but without any of beta 97 coefficients escaping toward infinity. 98 99 .. attribute:: Constant 100 101 The data is singular due to a constant variable. 102 103 .. attribute:: Singularity 104 105 The data is singular. 103 106 104 107 105 108 .. method:: __call__(data, weight_id) 106 109 107 Performs the fitting. There can be two different cases: either 108 the fitting succeeded to find a set of beta coefficients (although 109 possibly with difficulties) or the fitting failed altogether. The 110 two cases return different results. 111 112 `(status, beta, beta_se, likelihood)` 113 The fitter managed to fit the model. The first element of 114 the tuple, result, tells about the problems occurred; it can 115 be either :obj:`OK`, :obj:`Infinity` or :obj:`Divergence`. In 116 the latter cases, returned values may still be useful for 117 making predictions, but it's recommended that you inspect 118 the coefficients and their errors and make your decision 119 whether to use the model or not. 120 121 `(status, attribute)` 122 The fitter failed and the returned attribute is responsible 123 for it. The type of failure is reported in status, which 124 can be either :obj:`Constant` or :obj:`Singularity`. 125 126 The proper way of calling the fitter is to expect and handle all 127 the situations described. For instance, if fitter is an instance 128 of some fitter and examples contain a set of suitable examples, 129 a script should look like this:: 110 Fit the model and return a tuple with the fitted values and 111 the corresponding statistics or an error indicator. The two 112 cases differ by the tuple length and the status (the first 113 tuple element). 114 115 ``(status, beta, beta_se, likelihood)`` Fitting succeeded. The 116 first element, ``status`` is either :obj:`OK`, 117 :obj:`Infinity` or :obj:`Divergence`. In the latter cases, 118 returned values may still be useful for making 119 predictions, but it is recommended to inspect the 120 coefficients and their errors and decide whether to use 121 the model or not. 122 123 ``(status, variable)`` 124 The fitter failed due to the indicated 125 ``variable``. ``status`` is either :obj:`Constant` or 126 :obj:`Singularity`. 127 128 The proper way of calling the fitter is to handle both scenarios :: 130 129 131 130 res = fitter(examples) … … 141 140 142 141 The sole fitter available at the 143 moment. Itis a C++ translation of `Alan Miller's logistic regression144 code <http://users.bigpond.net.au/amiller/>`_ . It uses NewtonRaphson142 moment. This is a C++ translation of `Alan Miller's logistic regression 143 code <http://users.bigpond.net.au/amiller/>`_ that uses NewtonRaphson 145 144 algorithm to iteratively minimize least squares error computed from 146 learning examples.145 training data. 147 146 148 147 … … 158 157  159 158 160 The first example shows a very simple induction of a logistic regression 161 classifier (:download:`logregrun.py <code/logregrun.py>`). 159 The first example shows a straightforward use a logistic regression (:download:`logregrun.py <code/logregrun.py>`). 162 160 163 161 .. literalinclude:: code/logregrun.py … … 210 208 211 209 If :obj:`remove_singular` is set to 0, inducing a logistic regression 212 classifier would returnan error::210 classifier returns an error:: 213 211 214 212 Traceback (most recent call last): … … 221 219 orange.KernelException: 'orange.LogRegLearner': singularity in workclass=Neverworked 222 220 223 We can see that the attribute workclass is causing a singularity.221 The attribute variable which causes the singularity is ``workclass``. 224 222 225 223 The example below shows how the use of stepwise logistic regression can help to
Note: See TracChangeset
for help on using the changeset viewer.