if classifier == None or len(remainder) < 1: print_help() exit() try: with open(classifier, 'rb') as f: classifier = pickle.load(f) assert hasattr(classifier, 'classify') except: print "could not load classifier" print_help() exit() def _plot(eprobs): print 'plotting' probs = numpy.array([0.5, 0.5]) lst = [oneclasstree.bayesian(eprobs[:x,:])[1] for x in range(1, eprobs.shape[0]+1)] plt.figure() plt.plot(lst) plt.show() for pcap in remainder: X = pacumen.make_feature_vectors_from_pcap(pcap) eprobs = classifier.classify(X) if visualize: _plot(eprobs) eprobs = oneclasstree.bayesian(eprobs) print '%f %s' % (eprobs[1], pcap)
try: with open(classifier, 'rb') as f: classifier = pickle.load(f) assert hasattr(classifier, 'classify') except: print "could not load classifier" print_help() exit() def _plot(eprobs): print 'plotting' probs = numpy.array([0.5, 0.5]) lst = [ oneclasstree.bayesian(eprobs[:x, :])[1] for x in range(1, eprobs.shape[0] + 1) ] plt.figure() plt.plot(lst) plt.show() for pcap in remainder: X = pacumen.make_feature_vectors_from_pcap(pcap) eprobs = classifier.classify(X) if visualize: _plot(eprobs) eprobs = oneclasstree.bayesian(eprobs) print '%f %s' % (eprobs[1], pcap)
minbias = float(arg) elif opt == '-G': gaussian = True elif opt == '-k': k = int(arg) if len(remainder) != 1 or len(targets) == 0 or len(nontargets) == 0: print_help() exit() outfilename = remainder[0] print 'reading pcaps' ntmat = sparse.vstack([ pacumen.make_feature_vectors_from_pcap(pcap) for pcap in nontargets ]).tocsr() tmat = sparse.vstack([ pacumen.make_feature_vectors_from_pcap(pcap) for pcap in targets ]).tocsr() classifier = None print 'have %d rows of target data and %d rows of non-target data' % ( tmat.shape[0], ntmat.shape[0]) all_data = sparse.vstack([ntmat, tmat]).tocsr() oracle = oneclasstree.bincount_oracle(all_data) best = None