2
$\begingroup$

I'm using the LogitModelFit function with a 32-columns design matrix and 0 or 1 output vector: LogitModelFit[{datax, datay}].

The fits seems to work, however the fit function has no bias term, unlike the other examples provided in the documentation.

For example, when I apply the fit function to the origin ConstantArray[0, 32], a value of 0.5 is returned.

The documentation specifies that for a design matrix m and response vector v, the model is $\hat{v}=1/(1+\exp(\mathbf m.\beta))$ (so no intercept term).

I don't understand how this is standard behaviour. How can I change it ?

$\endgroup$
2
$\begingroup$

Ok so the answer is simply to add an intercept column of 1s to the design matrix (here X):

X = ArrayFlatten[{{1,X}}];
fit = LogitModelFit[{X, y}];
results = MapThread[fit, Transpose[X]];

To test the hypothesis fit on a new datapoint however it's important to add 1 as its first parameter, ie. fit only works on the new feature space.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.