def numb_trees(class_, method, y_train, y_test): trees = range(1, 50) #trees = [1,3,5, 10, 15, 20, 50, 100, 150] #trees = np.linspace(1,n,n) train_accuracy = [] val_accuracy = [] train_auc = [] val_auc = [] for i in trees: if method == 'random_forest': y_pred_train, y_pred_val = class_.random_forest(n_estimators=i)[:2] xlabel = 'Number of trees' title = 'Random forest - number of trees' name_fig = 'RF_numbTrees' anal = Analyse(y_train, y_test, y_pred_train, y_pred_val) accuracy_train, accuracy_val = anal.accuracy() auc_train, auc_val = anal.roc()[4:] train_accuracy.append(accuracy_train) val_accuracy.append(accuracy_val) train_auc.append(auc_train) val_auc.append(auc_val) #all_accuracies = cross_val_score(estimator=class_.gradient_boosting(n_estimators=i)) make_plot(trees, train_accuracy, val_accuracy, train_auc, val_auc, xlabel, title, name_fig)
def tree_depth(class_, method, y_train, y_test): depth = range(1, 30) #depth = [2,3,5,7,10,13,15,18, 20,30] train_accuracy = [] val_accuracy = [] train_auc = [] val_auc = [] for i in depth: if method == 'random_forest': y_pred_train, y_pred_val = class_.random_forest(max_depth=i)[:2] xlabel = 'max depth' title = 'Random forest - tree depth' name_fig = 'RF_TreeDepth' if method == 'decision_tree': y_pred_train, y_pred_val = class_.decision_tree(max_depth=i)[:2] xlabel = 'max depth' title = 'Decision tree - tree depth' name_fig = 'DT_TreeDepth' anal = Analyse(y_train, y_test, y_pred_train, y_pred_val) accuracy_train, accuracy_val = anal.accuracy() auc_train, auc_val = anal.roc()[4:] train_accuracy.append(accuracy_train) val_accuracy.append(accuracy_val) train_auc.append(auc_train) val_auc.append(auc_val) make_plot(depth, train_accuracy, val_accuracy, train_auc, val_auc, xlabel, title, name_fig)
def max_iterations(class_, method, y_train, y_test, max_it): iterations = np.linspace(1, max_it, dtype=int) train_accuracy = [] val_accuracy = [] train_auc = [] val_auc = [] for i in iterations: if method == 'neural_network': y_pred_train, y_pred_val = class_.neural_network(max_iter=i)[:2] xlabel = 'max iterations' title = 'Neural network - max iterations' name_fig = 'NN_max_iterations' elif method == 'logistic_regression': y_pred_train, y_pred_val = class_.logistic_regression( max_iter=i)[:2] xlabel = 'max iterations' title = 'Logistic regression- max iterations' name_fig = 'LR_max_iterations' anal = Analyse(y_train, y_test, y_pred_train, y_pred_val) accuracy_train, accuracy_val = anal.accuracy() auc_train, auc_val = anal.roc()[4:] train_accuracy.append(accuracy_train) val_accuracy.append(accuracy_val) train_auc.append(auc_train) val_auc.append(auc_val) make_plot(iterations, train_accuracy, val_accuracy, train_auc, val_auc, xlabel, title, name_fig)
def main(): block_db, resource_db = get_dbs(r'D:\Program Files\SteamLibrary') blocks, resources = unpack_dbs(block_db['data'], resource_db['data']) trim(blocks) print() Analyse(blocks, resources).analyse()
def get_bar_graph_data(self, data): """ Returns the bar graph data for a particular user :param data: Dictionary, schema: {'user_id' : ${user_id}} """ sql = """ select l.user_id, t.task, l.tstamp from %s l join %s t on l.task_id = t.task_id where l.user_id = %s order by l.tstamp asc """ % (self.work_tracker_log._name, self.tasks._name, '%(user_id)s') self.db._cur.execute(sql, data) cols = [desc[0] for desc in self.db._cur.description] data = self.db._cur.fetchall() self.db.commit() log_data = [dict(zip(cols, row)) for row in data] if log_data == []: return log_data bar_data = Analyse(log_data).get_bar_grouping_dict() for row in bar_data: row['x'] = row['task'] row['y'] = row['time_spent'] del row['task'] del row['time_spent'] return bar_data
def min_samples_leaf(class_, method, y_train, y_test): samples_leaf = [0.1, 0.25, 0.5, 1, 2, 3] #samples_leaf = np.linspace(0.1,0.05*n,n) train_accuracy = [] val_accuracy = [] train_auc = [] val_auc = [] for i in samples_leaf: if method == 'decision_tree': y_pred_train, y_pred_val = class_.random_forest( min_samples_leaf=i)[:2] xlabel = 'min samples leaf' title = 'Decision tree - min samples leaf' name_fig = 'DT_min_samples_leaf' if method == 'random_forest': y_pred_train, y_pred_val = class_.random_forest( min_samples_leaf=i)[:2] xlabel = 'min samples leaf' title = 'Random forest - min samples leaf' name_fig = 'RF_min_samples_leaf' anal = Analyse(y_train, y_test, y_pred_train, y_pred_val) accuracy_train, accuracy_val = anal.accuracy() auc_train, auc_val = anal.roc()[4:] train_accuracy.append(accuracy_train) val_accuracy.append(accuracy_val) train_auc.append(auc_train) val_auc.append(auc_val) make_plot(samples_leaf, train_accuracy, val_accuracy, train_auc, val_auc, xlabel, title, name_fig)
def analyse(args): analise_results = Analyse(args.original_swarm_file, args.corrected_swarm_file, args.failed_swarm_file, args.analyse_file, args.analyse_file_mode, args.dense_layers, args.threshold, args.pif, args.dataset, args.seed) analise_results.run_analise() analise_results.write_results_analyse()
def run(self): args = copy.deepcopy(vars(self)) jobs = [] if self.run_type == "merge": Analyse(args) elif self.run_type == "preprocess": for run in self.runs: print("Starting script for run {}\n".format(run)) args["asic"] = 0 args["runs"] = [run] p = multiprocessing.Process(target=Analyse, args=(args,)) jobs.append(p) p.start() for job in jobs: job.join() else: args_ch = copy.deepcopy(args) for m in self.module: for asic in self.asic_list: print("Starting script for module {} and asic {}\n" .format(m, asic)) args["module"] = m args["channel"] = None args["asic"] = asic p = multiprocessing.Process(target=Analyse, args=(args,)) jobs.append(p) p.start() for ch in self.channel: for asic in self.asic_list: print("Starting script for channel {} and asic {}\n" .format(ch, asic)) args_ch["module"] = None args_ch["channel"] = ch args_ch["asic"] = asic p = multiprocessing.Process(target=Analyse, args=(args_ch,)) jobs.append(p) p.start() for job in jobs: job.join()
def __send(self): self.__setTime() account_sid = 'AC7c4003f4b37c35d2e4249984df784b69' auth_token = '6345546fae4ad92e602570250760c0fe' client = Client(account_sid, auth_token) message = client.messages.create(body=self.__getInfo()[0], from_='(239) 237-3586', to=self.__phone_number) info = SetData(self.__getInfo()[1], self.__getInfo()[2]) print(self.__getInfo()[0]) info.write() x = Analyse('/Python/Code/data.xls') x.createPic() time.sleep(23 * 60 * 60)
def learning_rate(class_, method, y_train, y_test): rates = [0.0001, 0.001, 0.01, 0.1, 1.0] train_accuracy = [] val_accuracy = [] train_auc = [] val_auc = [] for i in rates: y_pred_train, y_pred_val = class_.gradient_boosting(learning_rate=i) anal = Analyse(y_train, y_test, y_pred_train, y_pred_val) accuracy_train, accuracy_val = anal.accuracy() auc_train, auc_val = anal.roc()[4:] train_accuracy.append(accuracy_train) val_accuracy.append(accuracy_val) train_auc.append(auc_train) val_auc.append(auc_val) xlabel = 'Learning rate' title = 'Gradient boosting - learning rate' name_fig = 'GB_learningrate' make_plot(rates, train_accuracy, val_accuracy, train_auc, val_auc, xlabel, title, name_fig)
def hidden_layers(class_, y_train, y_test): layers = [1, 4, 10, 20, 50, 100, 200, 250] train_accuracy = [] val_accuracy = [] train_auc = [] val_auc = [] for i in layers: y_pred_train, y_pred_val = class_.neural_network( hidden_layer_sizes=i)[:2] anal = Analyse(y_train, y_test, y_pred_train, y_pred_val) accuracy_train, accuracy_val = anal.accuracy() auc_train, auc_val = anal.roc()[4:] train_accuracy.append(accuracy_train) val_accuracy.append(accuracy_val) train_auc.append(auc_train) val_auc.append(auc_val) xlabel = 'hidden layers' title = 'Neural network - hidden layers' name_fig = 'NN_hiddenlayers' make_plot(layers, train_accuracy, val_accuracy, train_auc, val_auc, xlabel, title, name_fig)
def min_samples_split(class_, method, y_train, y_test): samples_split = [0.1, 0.5, 2, 4, 6] #samples_leaf = np.linspace(0.1,0.05*n,n) train_accuracy = [] val_accuracy = [] train_auc = [] val_auc = [] for i in samples_split: if method == 'decision_tree': y_pred_train, y_pred_val = class_.random_forest( min_samples_split=i)[:2] xlabel = 'min samples split' title = 'Decision tree - min samples spit' name_fig = 'DT_min_samples_split' if method == 'random_forest': y_pred_train, y_pred_val = class_.random_forest( min_samples_split=i)[:2] xlabel = 'min samples split' title = 'Random forest - min samples split' name_fig = 'RF_min_samples_split' if method == 'adaboost': y_pred_train, y_pred_val = class_.adaboost(min_samples_split=i)[:2] xlabel = 'min samples split' title = 'Gradient boosting - min samples split' name_fig = 'GB_min_samples_split' anal = Analyse(y_train, y_test, y_pred_train, y_pred_val) accuracy_train, accuracy_val = anal.accuracy() auc_train, auc_val = anal.roc()[4:] train_accuracy.append(accuracy_train) val_accuracy.append(accuracy_val) train_auc.append(auc_train) val_auc.append(auc_val) make_plot(samples_split, train_accuracy, val_accuracy, train_auc, val_auc, xlabel, title, name_fig)
def get_line_graph_data(self, data): """ Returns the line graph data for a particular user :param data: Dictionary, schema: {'user_id' : ${user_id}} """ sql = """ select l.user_id, t.task, l.tstamp from %s l join %s t on l.task_id = t.task_id where l.user_id = %s order by l.tstamp asc """ % (self.work_tracker_log._name, self.tasks._name, '%(user_id)s') self.db._cur.execute(sql, data) cols = [desc[0] for desc in self.db._cur.description] data = self.db._cur.fetchall() self.db.commit() log_data = [dict(zip(cols, row)) for row in data] if log_data == []: return [[]] line_data = Analyse(log_data).get_line_grouping_dict() # We have to slightly restructure it for use with react-easy-chart transformed = collections.defaultdict(list) for row in line_data: transformed[row['task']].append({ 'x': row['time'].split('.')[0], 'y': row['total_time_spent'] }) transformed = [v for k, v in transformed.items()] # Trim dates return transformed
print(f'NEW: {self.base_heatmap}') ax = sns.heatmap(self.base_heatmap) plt.show() class BarGraph: def __init__(self, data): self.data = data def draw_bar_graph(self): x_ref = list(self.data.keys()) y_ref = list(self.data.values()) x_pos = [i for i, _ in enumerate(x_ref)] plt.bar(x_pos, y_ref, color='green') plt.xlabel('Stagnation period (s)') plt.ylabel('Frequency') plt.xticks(x_pos, x_ref) plt.show() mouse_heatmap = HeatMap("./track4.csv") mouse_heatmap.create_base_heatmap() mouse_heatmap.fill_heatmap() analysis = Analyse("./track4.csv") analysis.get_file_content() mouse_bar_chart = BarGraph(analysis.get_mouse_movement_duration_by_frequency()) mouse_bar_chart.draw_bar_graph()
def setUpClass(cls): # Construct our original data set cls.data = [{ 'user_id': 'test user', 'task': '1', 'tstamp': datetime.datetime(2018, 7, 26, 20, 00, 00, 000000) }, { 'user_id': 'test user', 'task': '2', 'tstamp': datetime.datetime(2018, 7, 26, 20, 10, 00, 000000) }, { 'user_id': 'test user', 'task': '1', 'tstamp': datetime.datetime(2018, 7, 26, 20, 15, 00, 000000) }, { 'user_id': 'test user', 'task': '2', 'tstamp': datetime.datetime(2018, 7, 26, 20, 20, 00, 000000) }, { 'user_id': 'test user', 'task': '1', 'tstamp': datetime.datetime(2018, 7, 26, 20, 40, 00, 000000) }] # Initalise our instance of Analyse cls.analyse = Analyse(cls.data) # Construct some DataFrames to use later in our unit test package # For comparing analyse.df_raw cls.raw_df = DataFrame(cls.data) # For comparing analyse.df_transform cls.transform_df = DataFrame([{ 'task': '1', 'started': datetime.datetime(2018, 7, 26, 20, 00, 00, 000000), 'finished': datetime.datetime(2018, 7, 26, 20, 10, 00, 000000), 'time_spent': 600.00 }, { 'task': '2', 'started': datetime.datetime(2018, 7, 26, 20, 10, 00, 000000), 'finished': datetime.datetime(2018, 7, 26, 20, 15, 00, 000000), 'time_spent': 300.00 }, { 'task': '1', 'started': datetime.datetime(2018, 7, 26, 20, 15, 00, 000000), 'finished': datetime.datetime(2018, 7, 26, 20, 20, 00, 000000), 'time_spent': 300.00 }, { 'task': '2', 'started': datetime.datetime(2018, 7, 26, 20, 20, 00, 000000), 'finished': datetime.datetime(2018, 7, 26, 20, 40, 00, 000000), 'time_spent': 1200.00 }]) cls.transform_df = cls.transform_df[[ 'task', 'started', 'finished', 'time_spent' ]] # For comparing analyse.df_bar cls.bar_df = DataFrame([{ 'task': '1', 'time_spent': 900.00 }, { 'task': '2', 'time_spent': 1500.00 }]) cls.bar_df = cls.bar_df[['task', 'time_spent']] # For comparing analyse.df_line cls.line_df = DataFrame([ { 'task': '1', 'time': datetime.datetime(2018, 7, 26, 20, 00, 00, 000000), 'total_time_spent': 0.00 }, { 'task': '2', 'time': datetime.datetime(2018, 7, 26, 20, 10, 00, 000000), 'total_time_spent': 0.00 }, { 'task': '1', 'time': datetime.datetime(2018, 7, 26, 20, 15, 00, 000000), 'total_time_spent': 600.00 }, { 'task': '2', 'time': datetime.datetime(2018, 7, 26, 20, 20, 00, 000000), 'total_time_spent': 300.00 }, { 'task': '1', 'time': datetime.datetime(2018, 7, 26, 20, 10, 00, 000000), 'total_time_spent': 600.00 }, { 'task': '2', 'time': datetime.datetime(2018, 7, 26, 20, 15, 00, 000000), 'total_time_spent': 300.00 }, { 'task': '1', 'time': datetime.datetime(2018, 7, 26, 20, 20, 00, 000000), 'total_time_spent': 900.00 }, { 'task': '2', 'time': datetime.datetime(2018, 7, 26, 20, 40, 00, 000000), 'total_time_spent': 1500.00 }, ]) cls.line_df = cls.line_df[['task', 'time', 'total_time_spent']]
import os import sys from keylogger import Keylogger from analyse import Analyse def using(): print("Usage: python App.py {start|analys}\n") print("start - start keylogger, all symbols will write in file(~/pylogger.log or $pylogger_file)") print("analys - start analyse ~/pylogger and do plot and save it in ./analyse.png") sys.exit(2) if len(sys.argv) < 2: using() command = sys.argv[1] if command == "start": Keylogger().start() elif command == "analyse": analyse = Analyse() analyse.do_and_save_plot() else: using()
def qlearning(self, eps): #The Q-learning algorithm to train our agent self.set_velocity_mode(self.myControlledCarId, 0) reward_type = "security_distance" speedLimit = True state = None steps = 0 plottingList = { "collisions": [], "space_headway": [], "relative_speed": [], "speed": [], "steps": 0 } while True: print(state) if state: plottingList["space_headway"].append( state.get("space_headway")) plottingList["relative_speed"].append( round(state.get("relative_speed") * 3.6, 0)) #Metre par seconde from traci to km par seconde plottingList["speed"].append(round( state.get("speed") * 3.6, 0)) #Metre par seconde from traci to km par seconde d_t, ds_t, s_t = \ self.arrange(state.get('space_headway'), self.index_space_headway), \ self.arrange(state.get('relative_speed'), self.index_relative_speed), \ self.arrange(state.get('speed'), self.index_speed) a = self.Egreedy_policy(d_t, ds_t, s_t) q_t = self.q[self.index_space_headway.get(d_t), self.index_relative_speed.get(ds_t), self.index_speed.get(s_t), self.index_action.get(self.action[a])] #Get the updated speed update_speed = self.update_speed(self.action[a], state.get('speed')) #Update agent speed ,step from traci self.set_velocity(self.myControlledCarId, update_speed) #Simulate new step with traci self.generate_simulation_step() next_state = self.get_state(self.myControlledCarId) q_t_m = None #Check if our agent has been collided with an other vehicle if self.isCollided(self.myControlledCarId): #Affect reward -10 self.set_reward_after_collision( reward_type) #reward_type "collision" #Set agent speed to 0 self.set_velocity(self.myControlledCarId, 0) q_t_m = 0 state = None plottingList["collisions"].append(steps) elif next_state: if reward_type == "security_distance": self.set_reward_security_dist_volicity( next_state.get('space_headway'), next_state.get('speed'), speedLimit) print(f" total reward : {self.totalRewards}") d_t1, ds_t1, s_t1 = \ self.arrange(next_state.get('space_headway'), self.index_space_headway), \ self.arrange(next_state.get('relative_speed'), self.index_relative_speed), \ self.arrange(next_state.get('speed'), self.index_speed) q_t_m = np.max(self.q[self.index_space_headway.get(d_t1), self.index_relative_speed.get(ds_t1), self.index_speed.get(s_t1)]) state = next_state if q_t_m is not None: self.q[ self.index_space_headway.get(d_t), self.index_relative_speed.get(ds_t), self.index_speed.get(s_t), self.index_action.get(self.action[a])] = \ (1 - self.alpha) * q_t + self.alpha * (self.totalRewards + self.gamma * q_t_m) print( f"qlearning: {self.q[self.index_space_headway.get(d_t), self.index_relative_speed.get(ds_t), self.index_speed.get(s_t)]}" ) steps += 1 self.epsilon_period(steps) else: self.generate_simulation_step() state = self.get_state(self.myControlledCarId) self.set_velocity(self.myControlledCarId, 0) if steps > (eps * 10000): time.sleep(.1) if steps == eps * 10000: plottingList["steps"] = steps plotting = Analyse(self, plottingList) plotting.plot_all_result()
def main(): parser = _build_args_parser() args = parser.parse_args() # -------------------Gestion des données-------------------------- print("\n" + "Gestion des données...") bd = BaseDonnees(args.fichier, 'is_legendary') bd.voir_att() bd.enlever_attributs([ 'abilities', 'japanese_name', 'name', 'generation', 'pokedex_number', 'classfication' ]) bd.str_a_int(['capture_rate']) bd.str_a_vec(['type1', 'type2']) bd.normaliser_donnees() bd.methode_filtrage() if (bool(args.est_ech_poids)): poids = bd.definir_poids_att() else: poids = [] # -------------------Gestion du modèle---------------------------- print("\n" + "Création du modèle...") if (args.choix_modele == "bayes_naif"): modele = BayesNaif() elif (args.choix_modele == "perceptron"): modele = Perceptron(max_iter=args.max_iter_perceptron, tol=args.tol_perceptron) elif (args.choix_modele == "perceptron_mc"): modele = PerceptronMC(couches_cachees=tuple( [int(x) for x in args.couches_cachees.split(',')]), activation=args.activation, solutionneur=args.solutionneur, max_iter=args.max_iter_perceptron_mc) elif (args.choix_modele == "svm"): modele = SVM(noyau=args.noyau, tol=args.tol_svm, max_iter=args.max_iter_svm) elif (args.choix_modele == "fad"): modele = FAD(nb_arbres=args.nb_arbres, critere=args.critere, prof_max=args.prof_max_fad) elif (args.choix_modele == "adaboost"): modele = AdaBoost(max_prof=args.prof_max_adaboost) # -------------------Répétitions pour moyenner----------- analyse_mult = Analyse_multiple(args.repetitions) for rep in range(args.repetitions): print("\n" + "Génération des ensembles d'entrainement et de test...") x_entr, t_entr, x_test, t_test = bd.faire_ens_entr_test() # -------------------Entrainement ou validation croisée----------- if bool(args.vc) is False: print("\n" + "Début de l'entrainement simple...") modele.entrainement(x_entr, t_entr, args.est_ech_poids, poids) else: print("\n" + "Début de l'entrainement par validation croisée...") modele.validation_croisee(x_entr, t_entr, 10, args.est_ech_poids, poids) # -------------------Prédiction et erreur------------------------- print("\n" + "Calcul des erreurs...") predictions_entrainement = modele.prediction(x_entr) erreur_entrainement = modele.erreur( t_entr, predictions_entrainement) / len(t_entr) * 100 predictions_test = modele.prediction(x_test) erreur_test = modele.erreur(t_test, predictions_test) / len(t_test) * 100 print("Erreur d'entrainement = ", erreur_entrainement, '%') print("Erreur de test = ", erreur_test, '%') # -------------------Analyse des résultats------------------------ print("\n" + "Analyse des résultats...") prob = modele.confiance_test(x_test) analyse = Analyse(t_test, predictions_test, prob) analyse.calculer_comptes() analyse.afficher_comptes() analyse.calculer_metriques() analyse.afficher_metriques() if (bool(args.courbe_roc)): analyse.calculer_courbe_roc() analyse.afficher_courbe_roc() analyse_mult.ajouter_erreurs(erreur_entrainement, erreur_test) analyse_mult.ajouter_metriques(analyse.metriques) analyse_mult.augmenter_rep_courante() # -------------------Analyse des répétitions------------------------ if (args.repetitions > 1): print("\n" + "Analyse des répétitions...") analyse_mult.calculer_moyennes() analyse_mult.afficher_moyennes() analyse_mult.afficher_graphique()
DT_tuned = method.decision_tree(criterion='gini', max_depth=10, min_samples_leaf=2, min_samples_split=2, visualize_tree=False) NN_tuned = method.neural_network(activation='tanh', max_iter=50, learning_rate=0.1, hidden_layer_sizes=(250,)) AB_tuned = method.adaboost(base_estimator=base_estimator[-1], n_estimators=200, learning_rate=0.1 ) return RF_tuned, AB_tuned, DT_tuned, NN_tuned ## Each method, with y_pred_train, y_pred_val, and method #RF_tuned, AB_tuned, DT_tuned, NN_tuned = tuned_full_predictors() RF_tuned, AB_tuned, DT_tuned, NN_tuned = tuned_dropped_predictors() ## Assigning analysis class to each classifier anal_RF = Analyse(y_train, y_test, RF_tuned[0], RF_tuned[1]) anal_DT = Analyse(y_train, y_test, DT_tuned[0], DT_tuned[1]) anal_AB = Analyse(y_train, y_test, AB_tuned[0], AB_tuned[1]) anal_NN = Analyse(y_train, y_test, NN_tuned[0], NN_tuned[1]) ## Getting the most important predictors for each method, as well as bar plot DT = anal_DT.importance_predictors(DT_tuned[-1], feature_names, 'Feature importance - Decision tree', 'feature_importance_IP_DT') RF = anal_RF.importance_predictors(RF_tuned[-1], feature_names, 'Feature importance - Random forest', 'feature_importance_IP_RT') AB = anal_AB.importance_predictors(AB_tuned[-1], feature_names,'Feature importance - AnaBoost', 'feature_importance_IP_AB') ## Printing out accuracy and AUC print("Accuracy scores:") print("AdaBoost:", "train:", anal_AB.accuracy()[0], "val:", anal_AB.accuracy()[1]) print("Random forest:", "train:", anal_RF.accuracy()[0], "val:", anal_RF.accuracy()[1])
from datetime import datetime from analyse import Analyse logger = logging.getLogger() logger.setLevel(logging.DEBUG) ch = logging.StreamHandler() ch.setLevel(logging.DEBUG) formatter = logging.Formatter('[%(asctime)s][%(levelname)s] %(message)s') ch.setFormatter(formatter) logger.addHandler(ch) user_name = sys.argv[1] user_pwd = sys.argv[2] url = sys.argv[3] start = datetime.now() a = Analyse(user_name, user_pwd, url) end = datetime.now() print('新增缺陷数:{}, 未关闭缺陷数:{}, 缺陷周期大于7天数:{}, 低级缺陷数:{}, 低级缺陷率: {}, ' '严重缺陷数: {}, 严重缺陷率:{}, 验证不通过缺陷数:{}'.format(a.get_bugs_new(), a.get_bugs_open(), a.get_bugs_more_than_7days(), *a.get_bugs_small(), *a.get_bugs_big(), a.get_bugs_verified_nopass())) print(end - start)