def sample(self, n_samples): ts = TimeSeries() ts.y = self.model.sample(n_samples)[0] ts.x = range(len(ts.y)) out_path = "{}/plots/{}/sample.png".format(script_dir, self.__class__.__name__) plot_procedures.plot_ts(ts, out_path, compress=True)
def simulate(): ts_len = 1000 l1 = np.random.normal(1, 0.2, ts_len) l2 = np.random.normal(5, 0.2, ts_len) l = np.append(l1, l2) ts = TimeSeries(compressed=True) ts.x = range(1, len(l) + 1) ts.y = l return ts
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])