bit of math with small example to get an initial understanding of the way logistic regression workslet us first take look at the following examplewhere we have an artificial feature value at the axis plotted with the corresponding class rangeeither or as we can seethe data is so noisy that classes overlap in the feature value range between and thereforeit is better to not directly model the discrete classesbut rather the probability that feature value belongs to class (xonce we possess such modelwe could then predict class if ( or class otherwisemathematicallyit is always difficult to model something that has finite rangeas is the case here with our discrete labels and we canhowevertweak the probabilities bit so that they always stay between and for thiswe will need the odds ratio and its logarithm let' say feature has the probability of that it belongs to class that isp( = the odds ratio is then ( = )/ ( = we could say that the chance is : that this feature maps to class if ( = )we would consequently have : chance that the instance is of class the odds ratio is bounded by but goes to infinity (the left graph in the following screenshotif we now take the logarithm of itwe can map all probabilities between and to the full range from negative to positive infinity (the right graph in the following screenshotthe best part is that we still maintain the relationship that higher probability leads to higher log of odds--it' just not limited to or anymore