24.07.2016 Views

www.allitebooks.com

Learning%20Data%20Mining%20with%20Python

Learning%20Data%20Mining%20with%20Python

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Getting Started with Data Mining<br />

We can then print out the top five rules:<br />

for index in range(5):<br />

print("Rule #{0}".format(index + 1))<br />

premise, conclusion = sorted_support[index][0]<br />

print_rule(premise, conclusion, support, confidence, features)<br />

The result will look like the following:<br />

Similarly, we can print the top rules based on confidence. First, <strong>com</strong>pute the sorted<br />

confidence list:<br />

sorted_confidence = sorted(confidence.items(), key=itemgetter(1),<br />

reverse=True)<br />

Next, print them out using the same method as before. Note the change to<br />

sorted_confidence on the third line;<br />

for index in range(5):<br />

print("Rule #{0}".format(index + 1))<br />

premise, conclusion = sorted_confidence[index][0]<br />

print_rule(premise, conclusion, support, confidence, features)<br />

[ 14 ]

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!