Sei sulla pagina 1di 8

Naïve bayes

1.Based on bayes theorem.


2.It is a method for text categorization.
P(c/x)=P(x/c) P(c)
P(x)
General expression P(c/x)=P(x1\c)*P(x2/c)……
where, P(c/x)=posterior probability
P(x/c)=likelihood
P(x)=class prior probability
Output
Application in project

Here in the project we are going to predict if a person can get diabetes by using
some simple attributes. Naive bayes predicts that by using bayes theorem for
example, lets consider single attribute pregnancy to see true positive value. First
value is 6 so considering it as p(a)=6/100 and p(b)=4/100 then p(e1)=1/768
therefore after substituting the value in the formula
p(e/a)=p(e1/a).p(a)/p(e1/a)+p(e2/b) then we will get 0.65 which is the true
negative hence we can calculate true positive now it is 0.35
Java code for naïve bayes

//build model
NaïveBayes model=new Naïvebaiyes();
mode1.buildclassifier(train);
//use
Evaluation eval_train=new evaluation(test);
Eval train.evaluatemodel(model, test);
Logistic regression

1.Logical regression is a statistical method for


analysing a dataset in which there are one or more
independent variables that determine an outcome.
2.The outcome is measured with a dichotomous variable(in which there are only
two possible outcomes.

3.In order to map predicted values to probabilities,


we use the sigmoid function. The function maps any
real value into another value between 0 and 1.It is
expressed as follows
Formula

Expression for logistic regression


p(x) = 1
1+e-(βο +β᷂x)
Types of logistic regression

 True positive rate


 True negative rate
 False positive
 False negative
Application in project

 Is used to predict yes or no in(0,1) binary format


Example,
Consider one attribute of age, here by substituting the any number(age) in the
formula the regression predicts if the person may get diabetes in the future or
not, based on the resultant value we can say the false positive and negative
value of the regression.

Potrebbero piacerti anche