new_seq_item.append(item) expanded.append(new_seq_item) if (len(value["sequence"]) == 0): new_seq_item = [] for item in value["itemset"]: new_seq_item.append(item) expanded.append(new_seq_item) num_users = float(self.attributes["user"]["domain"]) * float( value["support"]) for i in range(int(num_users)): selected = random.randrange( 1, int(self.attributes["user"]["domain"])) selected_user = self.attributes["user"]["represent"] + str( selected) if selected_user not in self.exp_sequences: self.exp_sequences[selected_user] = {} self.exp_sequences[selected_user][key] = expanded if __name__ == '__main__': attribute = Attribute() attribute.load_dist_json() attribute.load_attr_cvs() pattern = Pattern(attribute.sem_to_rep) pattern.load() expanded_seq = Sequencepat(attribute.distribution, pattern.patterns) expanded_seq.expand() print expanded_seq.exp_sequences
import matplotlib as mpl mpl.use('Agg') import matplotlib.pyplot as plt from matplotlib.backends.backend_pdf import PdfPages import numpy as np from attribute import Attribute import random # normal function, parameter mu and sigma is the fit parameter def normal(k, mu, sigma): return 1/(sigma * np.sqrt(2 * np.pi)) * np.exp( - (k - mu)**2 / (2 * sigma**2) ) attribute = Attribute() attribute.load_dist_json() for key, value in attribute.distribution.iteritems(): name = key type = value["type"] domain = int(value["domain"]) # only draw normal distribution if (type != "normal" and type != "random"): continue; mu = int(value["mu"]) sigma = int(value["sigma"]) #s = np.random.normal(mu, sigma, 1000) # 1000 random number following normal distribution s = [] eventfile = "output/events.txt" with open(eventfile, 'rb') as file: