Compreendendo a regressão logística e a probabilidade


12

Como a estimativa de parâmetros / treinamento de regressão logística realmente funciona? Vou tentar colocar o que tenho até agora.

  1. A saída é y a saída da função logística em forma de probabilidade, dependendo do valor de x:
    P(y=1|x)=11+e−ωTx≡σ(ωTx)
    P(y=0|x)=1−P(y=1|x)=1−11+e−ωTx
  2. Para uma dimensão, as chamadas Odds são definidas da seguinte forma:
    p(y=1|x)1−p(y=1|x)=p(y=1|x)p(y=0|x)=eω0+ω1x
  3. Agora adicionando a logfunção para obter W_0 e W_1 na forma linear:
    Logit(y)=log(p(y=1|x)1−p(y=1|x))=ω0+ω1x
  4. Agora, para a parte do problema Usando a probabilidade (X grande é y)
    L(X|P)=∏i=1,yi=1NP(xi)∏i=1,yi=0N(1−P(xi))
    Alguém pode dizer por que estamos considerando a probabilidade de y = 1 duas vezes? desde:
    P(y=0|x)=1−P(y=1|x)

e como obter os valores de ω disso?

Respostas:


10

Suponha, em geral, que você decidiu criar um modelo da forma

P(y=1|X=x)=h(x;Θ)

para algum parâmetro . Então você simplesmente anota a probabilidade disso, ou seja,Θ

L(Θ)=∏i∈{1,...,N},yi=1P(y=1|x=x;Θ)⋅∏i∈{1,...,N},yi=0P(y=0|x=x;Θ)

que é o mesmo que

L(Θ)=∏i∈{1,...,N},yi=1P(y=1|x=x;Θ)⋅∏i∈{1,...,N},yi=0(1−P(y=1|x=x;Θ))

Agora você decidiu 'assumir' (modelo)

P(y=1|X=x)=σ(Θ0+Θ1x)

onde

σ(z)=1/(1+e−z)

então você apenas calcula a fórmula para a probabilidade e algum tipo de algoritmo de otimização para encontrar o argmax Θ L ( Θ ) , por exemplo, o método newtons ou qualquer outro método baseado em gradiente.argmaxΘL(Θ)

Observe que, às vezes, as pessoas dizem que, quando estão fazendo regressão logística, não maximizam a probabilidade (como fizemos anteriormente), mas minimizam a função de perda

l(Θ)=−∑i=1Nyilog⁡(P(Yi=1|X=x;Θ))+(1−yi)log⁡(P(Yi=0|X=x;Θ))

mas observe que .−log⁡(L(Θ))=l(Θ)

Esse é um padrão geral no aprendizado de máquina: o lado prático (minimizar as funções de perda que medem o quão 'errado' é um modelo heurístico) é de fato igual ao 'lado teórico' (modelar explicitamente com o símbolo , maximizando quantidades estatísticas como probabilidades) e, de fato, muitos modelos que não parecem probabilísticos (SVMs, por exemplo) podem ser re-entendidos em um contexto probabilístico e, de fato, são maximizações de probabilidades.P


@ Werner obrigado pela sua resposta. Mas eu ainda preciso de um pouco de clarification.1st você pode explicar o que na terra a 2 estadia para na definição de L ( θ ) desde o mais longe que eu entendi Estou interessted no caso de y i = 1 . e como obter os valores de ω 1 e ω 0, muito obrigado pela sua ajuda! ∏L(θ)yi=1ω1ω0
— Motor

@ Engine: O grande 'pi' é um produto ... como um grande Sigma é uma soma ... você entende ou precisa de mais esclarecimentos sobre isso também? Na segunda pergunta: digamos que queremos minimizar uma função f ( x ) = x 2 e começamos com x = 3, mas vamos assumir que não sabemos / não podemos expressar / não podemos visualizar f , pois é complicado . Agora, a derivada de f é f ′ = 2 x . Curiosamente, se estivermos certos do mínimo x = 0Σf(x)=x2x=3fff′=2xx=0 it points to the right and if we are left of it it points left. Mathematically the derivative points into the direction of the 'strongest ascend'
— Fabian Werner

@Engine: In more dimensions you replace the derivative by the gradient, i.e. you start off at a random point x0 and compute the gradient ∂f at x and if you want to maximize then your next point x1 is x1=x0+∂f(x0). Then you compute ∂f(x1) and you next x is x2=x1+∂f(x1) and so forth. This is called gradient ascend/descent and is the most common technique in maximizing a function. Now you do that with L(Θ) or in your notation L(ω) in order to find the ω that maxeimizes L
— Fabian Werner

y=1ωωy=1y=1 as well as the y=0 'good'!
— Fabian Werner

8

Your likelihood function (4) consists of two parts: the product of the probability of success for only those people in your sample who experienced a success, and the product of the probability of failure for only those people in your sample who experienced a failure. Given that each individual experiences either a success or a failure, but not both, the probability will appear for each individual only once. That is what the ,yi=1 and ,yi=0 mean at the bottom of the product signs.

The coefficients are included in the likelihood function by substituting (1) into (4). That way the likelihood function becomes a function of ω. The point of maximum likelihood is to find the ω that will maximize the likelihood.


thanks so much for your answer, sorry but still don't get it. isn'tyi=0 means the probability that y =0[Don't occure] for all y's of the product. and vis versa for y_i=1. And still after the subtitutiing of how can I find ω values, caclulating the 2nd derivative ? or gradient ? thanks a lot for your help !
— Engine

∏i=1,y=1N should be read as "product for persons i=1 till N, but only if y=1. So the first part only applies to those persons in your data that experienced the event. Similarly, the second part only refers to persons who did not experienced the event.
— Maarten Buis

There are many possible algorithms for maximizing the likelihood function. The most common one, the Newton-Raphson method, indeed involves computing the first and second derivatives.
— Maarten Buis
Ao utilizar nosso site, você reconhece que leu e compreendeu nossa Política de Cookies e nossa Política de Privacidade.
Licensed under cc by-sa 3.0 with attribution required.