Predictions Logistic Regression model using fitglm

71 visualizaciones (últimos 30 días)
Eva
Eva el 18 de Oct. de 2021
Comentada: Ive J el 30 de Oct. de 2021
I created a logistic regression model with four continuous variables as input, using the function fitglm for binary classification. The functions 'predict' and 'feval' say in their documentation that they are only for linear regression models, but when I apply them on my model they do work. I am unsure how to interpret the output. My questions are:
  1. Is the output of both predict and feval the probability that the sample belongs to the positive class?
  2. Is there a different function for model evaluation that is a better fit for my model?
My code:
mdl = fitglm(data,modelspec,'Distribution','binomial');
out = predict(mdl,testdata);

Respuesta aceptada

the cyclist
the cyclist el 18 de Oct. de 2021
I have a couple of comments, before answering your specific questions.
First, you might benefit by reading up a little bit on generalized linear models (e.g. on this wikipedia page). You seem to think your model is not linear, but it is. A logistic regression is a linear model -- because you use a linking function to make it so.
In particular, the word "linear" in linear regression refers to the coefficients, not the terms themselves. For example, fitting a model of the form
y = alpha + beta1*x + beta2*x.^2
would be a linear regression. It's linear in alpha and beta (not in x).
Fitting the model
y = a * exp(b*x)
is a non-linear model, because it is not linear in b.
Second, by virtue of the fact that you used fitglm, you have fit a linear model. Whether that was the most appropriate model for your data is impossible to know, without seeing your data. (That is basically the answer to your second question.)
The answer to your first question is in this section of the documentation for predict. I'm pretty sure that when you say "positive", you mean the same as "success" in the documentation, so the answer to your question is yes.
  3 comentarios
the cyclist
the cyclist el 20 de Oct. de 2021
Yes, I think so.
Ive J
Ive J el 30 de Oct. de 2021
@Eva de Bock On a side note, you should be aware that the output of your model is predictive probability of your so-called 'success', and by definition logisitc regression is not a classifier (no '0' or '1' in the output), but generates a spectrum of values (in range of (0, 1)). In your case, predict function gives you the predicted probabilities of A using the model you specified above. A value of 0.99 can be safely regarded as success and a value close to 0 as failure. You may find also this elegant discussion by Frank Harrell of interest: https://www.fharrell.com/post/classification/

Iniciar sesión para comentar.

Más respuestas (0)

Productos


Versión

R2021b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by