import numpy as np
from collections import defaultdict
#First,how many rows contain our premise:that a person is buying apples
'''num_apple_purchases=0
for sample in X:
if sample[3]==1: #this person bought apples
num_apple_purchases+=1
print num_apple_purchases'''
def calS(X,n_features):
#print n_features
#print X[:5]#every row is a purchase record,evey column is a product
#five kinds of product
#bread,milk,cheese,apple and banana
valid_rules=defaultdict(int)
invalid_rules=defaultdict(int)
num_occurances=defaultdict(int)
print X
for sample in X:
for premise in range(5):
if sample[premise]==0:con