Python Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me

The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.

Go Back   Dev Shed ForumsProgramming LanguagesPython Programming

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old November 1st, 2012, 09:26 PM
nasicode nasicode is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Nov 2012
Posts: 7 nasicode User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 h 39 m 24 sec
Reputation Power: 0
Why is it that the confidence of the second tuple in L not calculated?

Code:
supportData = {('nas','fat'): 0.5, ('nas'): 1.0, ('fat'):0.6, ('van'):0.72, ('jos'):0.55,('van','jos'):0.10}

L = [('nas','fat'),('van','jos')]

#for i in L:
for freqSet in L:#only get the sets with two or more items
    H = [''.join(list(i)) for i in freqSet]
    
    for conseq in H:
        print H
        freqsetlist = list(freqSet)
        freqsetlist.remove(conseq)
        print freqsetlist
        conf = supportData[freqSet]/supportData[tuple(freqsetlist)[0]]
        if conf >= 0.5:
              print freqsetlist,'-->',conseq,'conf:',conf


If I run the code I get:
Code:
['nas', 'fat']
['fat']
['fat'] --> nas conf: 0.833333333333
['nas', 'fat']
['nas']
['nas'] --> fat conf: 0.5
['van', 'jos']
['jos']
['van', 'jos']
['van']

Reply With Quote
  #2  
Old November 1st, 2012, 10:26 PM
b49P23TIvg's Avatar
b49P23TIvg b49P23TIvg is offline
Contributing User
Dev Shed Loyal (3000 - 3499 posts)
 
Join Date: Aug 2011
Posts: 3,389 b49P23TIvg User rank is Major (30000 - 40000 Reputation Level)b49P23TIvg User rank is Major (30000 - 40000 Reputation Level)b49P23TIvg User rank is Major (30000 - 40000 Reputation Level)b49P23TIvg User rank is Major (30000 - 40000 Reputation Level)b49P23TIvg User rank is Major (30000 - 40000 Reputation Level)b49P23TIvg User rank is Major (30000 - 40000 Reputation Level)b49P23TIvg User rank is Major (30000 - 40000 Reputation Level)b49P23TIvg User rank is Major (30000 - 40000 Reputation Level)b49P23TIvg User rank is Major (30000 - 40000 Reputation Level)b49P23TIvg User rank is Major (30000 - 40000 Reputation Level) 
Time spent in forums: 1 Month 2 Weeks 3 Days 14 h 22 m 25 sec
Reputation Power: 383
Given that your program doesn't work, and that I couldn't find the result you anticipated, I've modified your program to print better diagnostic information. First, you have this overly complicated statement
H = [''.join(list(i)) for i in freqSet]
which is equivalent to
H = list(freqSet)
making me think the program doesn't do what you expect.
Code:
supportData = {('nas','fat'): 0.5, ('nas'): 1.0, ('fat'):0.6, ('van'):0.72, ('jos'):0.55,('van','jos'):0.10}

L = [('nas','fat'),('van','jos')]

for freqSet in L: #only get the sets with two or more items
    H = list(freqSet)
    for conseq in H:
        freqsetlist = list(freqSet)
        freqsetlist.remove(conseq)
        print'numerator   key:value  == %s:%f'%(freqSet,supportData[freqSet])
        key = tuple(freqsetlist)[0]
        print'denominator key:value  == %s:%f'%(key,supportData[key])
        conf = supportData[freqSet]/supportData[tuple(freqsetlist)[0]]
        if conf >= 0.5:
              print freqsetlist,'-->',conseq,'conf:',conf


Run:
Code:
$ ( cd /tmp && python q.py )
numerator   key:value  == ('nas', 'fat'):0.500000
denominator key:value  == fat:0.600000
['fat'] --> nas conf: 0.833333333333
numerator   key:value  == ('nas', 'fat'):0.500000
denominator key:value  == nas:1.000000
['nas'] --> fat conf: 0.5
numerator   key:value  == ('van', 'jos'):0.100000
denominator key:value  == jos:0.550000
numerator   key:value  == ('van', 'jos'):0.100000
denominator key:value  == van:0.720000
__________________
[code]Code tags[/code] are essential for python code!

Reply With Quote
  #3  
Old November 2nd, 2012, 12:02 AM
nasicode nasicode is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Nov 2012
Posts: 7 nasicode User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 h 39 m 24 sec
Reputation Power: 0
Quote:
Originally Posted by b49P23TIvg
Given that your program doesn't work, and that I couldn't find the result you anticipated, I've modified your program to print better diagnostic information. First, you have this overly complicated statement
H = [''.join(list(i)) for i in freqSet]
which is equivalent to
H = list(freqSet)
making me think the program doesn't do what you expect.
Code:
supportData = {('nas','fat'): 0.5, ('nas'): 1.0, ('fat'):0.6, ('van'):0.72, ('jos'):0.55,('van','jos'):0.10}

L = [('nas','fat'),('van','jos')]

for freqSet in L: #only get the sets with two or more items
    H = list(freqSet)
    for conseq in H:
        freqsetlist = list(freqSet)
        freqsetlist.remove(conseq)
        print'numerator   key:value  == %s:%f'%(freqSet,supportData[freqSet])
        key = tuple(freqsetlist)[0]
        print'denominator key:value  == %s:%f'%(key,supportData[key])
        conf = supportData[freqSet]/supportData[tuple(freqsetlist)[0]]
        if conf >= 0.5:
              print freqsetlist,'-->',conseq,'conf:',conf


Run:
Code:
$ ( cd /tmp && python q.py )
numerator   key:value  == ('nas', 'fat'):0.500000
denominator key:value  == fat:0.600000
['fat'] --> nas conf: 0.833333333333
numerator   key:value  == ('nas', 'fat'):0.500000
denominator key:value  == nas:1.000000
['nas'] --> fat conf: 0.5
numerator   key:value  == ('van', 'jos'):0.100000
denominator key:value  == jos:0.550000
numerator   key:value  == ('van', 'jos'):0.100000
denominator key:value  == van:0.720000




But the confidence for tuple ('van','jos') hasn't been calculated like that of ('nas','fat'). The question is, what is stopping the the confidence calculation for the second tuple ?

Reply With Quote
  #4  
Old November 2nd, 2012, 12:21 AM
b49P23TIvg's Avatar
b49P23TIvg b49P23TIvg is offline
Contributing User
Dev Shed Loyal (3000 - 3499 posts)
 
Join Date: Aug 2011
Posts: 3,389 b49P23TIvg User rank is Major (30000 - 40000 Reputation Level)b49P23TIvg User rank is Major (30000 - 40000 Reputation Level)b49P23TIvg User rank is Major (30000 - 40000 Reputation Level)b49P23TIvg User rank is Major (30000 - 40000 Reputation Level)b49P23TIvg User rank is Major (30000 - 40000 Reputation Level)b49P23TIvg User rank is Major (30000 - 40000 Reputation Level)b49P23TIvg User rank is Major (30000 - 40000 Reputation Level)b49P23TIvg User rank is Major (30000 - 40000 Reputation Level)b49P23TIvg User rank is Major (30000 - 40000 Reputation Level)b49P23TIvg User rank is Major (30000 - 40000 Reputation Level) 
Time spent in forums: 1 Month 2 Weeks 3 Days 14 h 22 m 25 sec
Reputation Power: 383
nothing's stopping the calculation.
10/55 is less than a half,
10/72 is also less than a half.
This statement prevents them from printing:
Code:
        if conf >= 0.5:
              print freqsetlist,'-->',conseq,'conf:',conf

Reply With Quote
  #5  
Old November 2nd, 2012, 01:15 AM
nasicode nasicode is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Nov 2012
Posts: 7 nasicode User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 h 39 m 24 sec
Reputation Power: 0
Quote:
Originally Posted by b49P23TIvg
nothing's stopping the calculation.
10/55 is less than a half,
10/72 is also less than a half.
This statement prevents them from printing:
Code:
        if conf >= 0.5:
              print freqsetlist,'-->',conseq,'conf:',conf





Poor me! Thank you. I am very grateful

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming LanguagesPython Programming > Why is it that the confidence of the second tuple in L not calculated?

Developer Shed Advertisers and Affiliates



Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 


Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.

© 2003-2013 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap