예제 #1
0
def logisticregression(samplerecords, lowage, upage,agetype ):
    lstrecords = getsample(samplerecords, lowage, upage, agetype )
    prewt = orange.FloatVariable('PREPREGNANCYWEIGHT')
    motherbmi = orange.FloatVariable('MOTHERPREPREGNANCYBMI')
    #gestWtGain = orange.FloatVariable('NETGESTATIONWEIGHTGAIN')
    gestWtGainRate = orange.FloatVariable('GESTATIONWEIGHTGAINRATE')
    wtdelivery = orange.FloatVariable('WEIGHTATDELIVERY')
    bweight = orange.FloatVariable('BIRTHWEIGHT')
    ethinicity = orange.EnumVariable('MOTHERETHINICITY',values = ['BL','WH', 'AS', 'HI', 'AI','UN'])
    obesity = orange.EnumVariable('OBESITY',values = ['1','0'])
    classAttributes = [prewt,motherbmi, gestWtGainRate,wtdelivery, bweight,ethinicity]
    domain = orange.Domain(classAttributes, obesity)
    ft = getallfeatures(lstrecords,domain,lowage, upage,agetype)
    data = orange.ExampleTable(domain, ft)
    countvariousattributes(data)
    lr = orngLR.LogRegLearner(data, removeSingular=1)
    TP = TN = FP = FN = 0
    for ex in data:
        
        if ex.getclass() == '1':
            if lr(ex) == '1':
                TP = TP +1
            else:
                FN = FN + 1
        elif ex.getclass() == '0':
            if lr(ex) == '0':
                TN = TN +1
            else:
                FP = FP + 1
    countNumberOfObese(lstrecords, lowage,upage, agetype)
    orngLR.printOUT(lr)
    print TP, ' ', FP , ' ', TN , ' ', FN
예제 #2
0
# Description: Demonstrates the use of logistic regression
# Category:    classification, logistic regression
# Classes:     LogRegLearner
# Uses:        titanic.tab

import orange
import orngLR

data = orange.ExampleTable("titanic")
lr = orngLR.LogRegLearner(data) 

correct = 0
for ex in data:
    if lr(ex) == ex.getclass():
        correct += 1
        
print "Classification accuracy:", correct/len(data)
orngLR.printOUT(lr) 
예제 #3
0
# Description: Demonstrates the use of logistic regression
# Category:    classification, logistic regression
# Classes:     LogRegLearner
# Uses:        titanic.tab

import orange
import orngLR

data = orange.ExampleTable("titanic")
lr = orngLR.LogRegLearner(data)

correct = 0
for ex in data:
    if lr(ex) == ex.getclass():
        correct += 1

print "Classification accuracy:", correct / len(data)
orngLR.printOUT(lr)