Exemplo n.º 1
0
		
		#--------------------------
		for i, his_test in enumerate( own_test ): # for each day
			sys.stdout.write( "\r%s" % "---------------------------- progress = " + str(i*100./len(own_test)) + " " + DBFILES[id_bus] + " " ); sys.stdout.flush()
			
			own_test_ = Util.shrink(i, own_test, TH1)
			fleet_test_ = [ Util.shrink(i, bus, TH1) for bus in fleet_test ]
			flat_fleet_test_ = Util.flatList( fleet_test_ )
			
			# ------
			# center = Util.centroid( own_test_ ); score1 = Util.dist(his_test, center); pvalue1 = 0.5; dir_imgs = "cosmo_centroid/"
			# pvalue1, score1 = como_anomaly.normalityProba_V3( "centroid", own_test_, his_test, all_buses, id_bus, i )
			# pvalue1, score1 = como_anomaly.normalityProba_V3( "medoid", own_test_, his_test, all_buses, id_bus, i )
			# ------
			
			pvalue1, score1 = como_anomaly.normalityProba_V1( "online", flat_fleet_test_, his_test, all_buses, id_bus, i, h )
			# pvalue1, score1 = como_anomaly.normalityProba_V1( "KNN", flat_fleet_test_, his_test, all_buses, id_bus, i ); dir_imgs = "cosmo_KNN/"
			# pvalue2, score2 = como_anomaly.normalityProba_V2( "RNN", own_test_, his_test, all_buses, id_bus, i ); dir_imgs = "cosmo_RNN/"
			# pvalue1, score1 = 0.5, 0.5
			pvalue2, score2 = pvalue1, score1
			
			h.train( [ bus[0] for bus in fleet_test_ ] )# ; print "nb_nodes", h.nb_nodes
			
			
			Z1.append( pvalue1 ); Z2.append( pvalue2 )
			S1.append( score1 ); S2.append( score2 )
		
		#--------------------------
		connexion_sig, cursor_sig = Util.connectDB(DB_PATH+filename)
		connexion_sig, cursor_sig_mil = Util.connectDB(DB_PATH+busname+"_16644.db")
		connexion_vsr, cursor_vsr = Util.connectDB(DB_PATH+"_vsr.db")
Exemplo n.º 2
0
            Z1.append(pvalue1)
            Z2.append(pvalue2)
            S1.append(score1)
            S2.append(score2)

            # --------------------------
        connexion_sig, cursor_sig = Util.connectDB(DB_PATH + filename)
        connexion_sig, cursor_sig_mil = Util.connectDB(DB_PATH + busname + "_16644.db")
        connexion_vsr, cursor_vsr = Util.connectDB(DB_PATH + "_vsr.db")
        if busname == "369":
            busname = "396"

        # --------------------------
        image = como_ploting.Ploting(busname, dates)

        Z1_means, Dev1 = como_anomaly.getZvalues(Z1)
        Z2_means, Dev2 = como_anomaly.getZvalues(Z2)
        image.plotScores(S1, S2)
        image.plotPValues(Z1, Z2, Z1_means, Z2_means)
        image.plotDeviations(Dev1, Dev2)

        # ----------
        repair_dates_str = cursor_vsr.execute(
            "SELECT DISTINCT Visits.Date FROM Visits,Operations WHERE Visits.VisitID = Operations.Visit AND Visits.Bus LIKE '%"
            + busname
            + "%'"
        )
        repair_dates = [Util.str2date(date_str, format="%Y-%m-%d") for date_str in repair_dates_str]

        interesting_repairs = []