Esempio n. 1
0
 def plot(self, ts, ts_raw, correct, pred, conf, out_path):
     _, ts_dist = self.slide(ts)
     plot_procedures.plot_ts_share_x(ts,
                                     ts_dist,
                                     out_path,
                                     compress=True,
                                     title1="median filtered",
                                     title2="mean distance sliding windows",
                                     dt_axvline1=np.asarray(ts.x)[correct],
                                     dt_axvline2=np.asarray(ts.x)[pred],
                                     y_axhline2=[self.thresh],
                                     xlabel="$i$",
                                     ylabel2="$D_{i}$ (ms)",
                                     ylabel1="RTT (ms)")
Esempio n. 2
0
    def plot(self, ts, ts_raw, correct, pred, conf, out_path):
        ts_cp_prob = self.get_cp_prob(ts)

        ylabel1 = plot_procedures.get_default_ylabel(ts)
        plot_procedures.plot_ts_share_x(ts,
                                        ts_cp_prob,
                                        out_path,
                                        compress=True,
                                        title1="median filtered",
                                        ylim2=[-0.02, 1.02],
                                        yticks2=np.arange(0.0, 1.0 + 0.1, 0.1),
                                        dt_axvline1=np.asarray(ts.x)[correct],
                                        dt_axvline2=np.asarray(ts.x)[pred],
                                        y_axhline2=[self.thresh],
                                        title2="probabilities",
                                        ylabel1=ylabel1,
                                        ylabel2="p($i$ is change point)",
                                        xlabel="$i$")
Esempio n. 3
0
    def plot(self, server, mac, dt_start, dt_end, ts, hidden_state_path):
        ts_hidden_state_path = TimeSeries()
        ts_hidden_state_path.x = copy.deepcopy(ts.x)
        ts_hidden_state_path.y = copy.deepcopy(hidden_state_path)

        out_file_name = utils.get_out_file_name(server, mac, dt_start, dt_end)
        out_path = "{}/plots/{}/{}.png".format(script_dir,
                                               self.__class__.__name__,
                                               out_file_name)
        plot_procedures.plot_ts_share_x(
            ts,
            ts_hidden_state_path,
            out_path,
            compress=True,
            title1="raw time series",
            title2="best hidden state path",
            plot_type2="scatter",
            yticks2=range(self.model.n_components),
            ylim2=[-0.5, self.model.n_components - 0.5])
Esempio n. 4
0
def sliding_window(ts):
    ts_dist = TimeSeries(compressed=True)

    win_len = 100
    for i in xrange(win_len, len(ts.y) - win_len + 1):
        dist = cmp_win.hellinger_dist(ts.y[i - win_len:i],
                                      ts.y[i:i + win_len],
                                      bins=np.arange(0.02, 10.02, 0.02))
        ts_dist.x.append(ts.x[i])
        ts_dist.y.append(dist)

    plot_procedures.plot_ts_share_x(ts,
                                    ts_dist,
                                    "./sliding_window_toy_example.png",
                                    compress=True,
                                    plot_type1="plot",
                                    ylim1=[0, max(ts.y)],
                                    ylabel1="$y_{i}$",
                                    ylabel2="$H_{i}$",
                                    xlabel="$i$")
Esempio n. 5
0
def plot_per_node(dt_start, dt_end, metric, only_unique_traceroute):
    dt_dir = utils.get_dt_dir(dt_start, dt_end)
    str_dt = utils.get_str_dt(dt_start, dt_end)

    utils.create_dirs([
        "{}/plots/".format(script_dir), "{}/plots/nodes".format(script_dir),
        "{}/plots/nodes/{}".format(script_dir, str_dt),
        "{}/plots/nodes/{}/{}".format(script_dir, str_dt, metric)
    ])

    valid_nodes = read_input.get_valid_nodes()
    mac_node = read_input.get_mac_node()

    macs_unique_traceroute = read_input.get_macs_traceroute_filter(
        dt_start, dt_end, "filtered")

    for server, mac, in_path in utils.iter_server_mac(dt_dir, True):
        if only_unique_traceroute and (mac not in macs_unique_traceroute):
            continue

        if mac_node[mac] in valid_nodes:
            utils.create_dirs([
                "{}/plots/nodes/{}/{}/{}".format(script_dir, str_dt, metric,
                                                 mac_node[mac])
            ])
            out_file_name = utils.get_out_file_name(server, mac, dt_start,
                                                    dt_end)
            out_path = ("{}/plots/nodes/{}/{}/{}/{}.png".format(
                script_dir, str_dt, metric, mac_node[mac], out_file_name))

            ts = TimeSeries(in_path, metric, dt_start, dt_end)
            ts_filter = TimeSeries(in_path, metric, dt_start, dt_end)
            ts_filter.percentile_filter(win_len=13, p=0.5)
            plot_procedures.plot_ts_share_x(ts,
                                            ts_filter,
                                            out_path,
                                            compress=False,
                                            plot_type2="scatter")
Esempio n. 6
0
 def plot(self, ts, ts_raw, correct, pred, conf, out_path):
     if "unsupervised" in out_path:
         ylabel = plot_procedures.get_default_ylabel(ts)
         plot_procedures.plot_ts(ts,
                                 out_path,
                                 dt_axvline=np.asarray(ts.x)[correct],
                                 ylabel=ylabel,
                                 xlabel="$i$",
                                 compress=True,
                                 title="median filtered")
     else:
         dt_axvline1 = np.asarray(ts.x)[correct]
         dt_axvline2 = np.asarray(ts.x)[pred]
         plot_procedures.plot_ts_share_x(
             ts_raw,
             ts,
             out_path,
             compress=False,
             title1="correct",
             dt_axvline1=dt_axvline1,
             dt_axvline2=dt_axvline2,
             title2="predicted. conf={}".format(conf),
             plot_type2="scatter")