Пример #1
0
    def test_plot_activities(self):
        from pyadlml.dataset.plot.activities import boxplot_duration, \
            heatmap_transitions, hist_cum_duration, ridge_line, hist_counts

        df = self.data.df_activities_one
        lst = self.data.lst_activities

        hist_counts(df)
        hist_counts(df, lst_act=lst)

        boxplot_duration(df)
        boxplot_duration(df, lst_act=lst)

        try:
            hist_cum_duration(df)
        except ValueError:
            pass
        hist_cum_duration(df, act_lst=lst)

        heatmap_transitions(df)
        heatmap_transitions(df, lst_act=lst)

        try:
            ridge_line(df)
        except ValueError:
            pass
        ridge_line(df, lst_act=lst, n=10)
Пример #2
0
def gen_plots_persons(dataset, data):
    from pyadlml.dataset.plot.activities import hist_counts, boxplot_duration, \
        hist_cum_duration, heatmap_transitions, ridge_line

    root_path = settings.MEDIA_ROOT + dataset.name + '/'
    for ps in dataset.person_statistics.all():
        sub_path = dataset.name + '/plots/' + ps.name + '/'
        path = settings.MEDIA_ROOT + sub_path

        try:
            hist_counts_filename = 'hist_counts.png'
            path_to_hist_counts = path + hist_counts_filename
            hist_counts(data.df_activities, file_path=path_to_hist_counts)
            ps.plot_hist_counts = sub_path + hist_counts_filename
        except:
            pass

        try:
            boxplot_duration_filename = 'boxplot_duration.png'
            path_to_boxplot_duration = path + boxplot_duration_filename
            boxplot_duration(data.df_activities,
                             file_path=path_to_boxplot_duration)
            ps.plot_boxplot_duration = sub_path + boxplot_duration_filename
        except:
            pass

        try:
            hist_cum_duration_filename = 'hist_cum_duration.png'
            path_to_hist_cum_duration = path + hist_cum_duration_filename
            hist_cum_duration(data.df_activities,
                              file_path=path_to_hist_cum_duration)
            ps.plot_hist_cum_duration = sub_path + hist_cum_duration_filename
        except:
            pass

        try:
            heatmap_transitions_filename = 'heatmap_transitions.png'
            path_to_heatmap_transitions = path + heatmap_transitions_filename
            heatmap_transitions(data.df_activities,
                                file_path=path_to_heatmap_transitions)
            ps.plot_heatmap_transitions = sub_path + heatmap_transitions_filename
        except:
            pass

        try:
            ridge_line_filename = 'ridge_line.png'
            path_to_ridge_line = path + ridge_line_filename
            ridge_line(data.df_activities, file_path=path_to_ridge_line)
            ps.plot_ridge_line = sub_path + ridge_line_filename
        except:
            pass

        ps.save()
Пример #3
0
    def test_plot_activities(self):
        from pyadlml.dataset.plot.activities import activities_duration_dist, boxplot_duration, \
            heatmap_transitions, hist_cum_duration, ridge_line, hist_counts

        df = self.data.df_activities_admin
        lst = self.data.lst_activities

        hist_counts(df)
        hist_counts(df, lst_act=lst)

        boxplot_duration(df)
        boxplot_duration(df, lst_act=lst)

        hist_cum_duration(df)
        hist_cum_duration(df, act_lst=lst)

        heatmap_transitions(df)
        heatmap_transitions(df, lst_act=lst)

        ridge_line(df)
        ridge_line(df, lst_act=lst, n=10)
Пример #4
0
    def test_plot_activities(self):
        from pyadlml.dataset.plot.activities import activities_duration_dist, boxplot_duration, \
            heatmap_transitions, hist_cum_duration, ridge_line, hist_counts

        for df_attr, lst_attr in zip(self.df_activity_attrs, self.lst_activity_attrs):
            df = getattr(self.data, df_attr)
            lst = getattr(self.data, lst_attr)

            hist_counts(df)
            hist_counts(df, lst_act=lst)

            boxplot_duration(df)
            boxplot_duration(df, lst_act=lst)

            hist_cum_duration(df)
            hist_cum_duration(df, act_lst=lst)

            heatmap_transitions(df)
            heatmap_transitions(df, lst_act=lst)

            ridge_line(df)
            ridge_line(df, lst_act=lst, n=10)
Пример #5
0
def gen_plots_persons(dataset, data):
    from pyadlml.dataset.plot.activities import hist_counts, boxplot_duration, \
        hist_cum_duration, heatmap_transitions, ridge_line

    root_path = settings.MEDIA_ROOT + dataset.name + '/'
    for ps in dataset.person_statistics.all():
        sub_path = dataset.name + '/plots/' + ps.name + '/'
        path = settings.MEDIA_ROOT + sub_path
        df_activities = getattr(data, 'df_activities_{}'.format(ps.name))
        lst_acts = data.lst_activities

        try:
            hist_counts_filename = settings.PLOT_ACT_HIST_COUNTS_FN
            path_to_hist_counts = path + hist_counts_filename
            hist_counts(df_activities,
                        lst_act=lst_acts,
                        file_path=path_to_hist_counts)
            ps.plot_hist_counts = sub_path + hist_counts_filename
            logger.info('created hist_counts for ' + str(ps.name))
        except:
            logger.error("couldn't create histogram counts")

        try:
            boxplot_duration_filename = settings.PLOT_ACT_BP_DURATION_FN
            path_to_boxplot_duration = path + boxplot_duration_filename
            boxplot_duration(df_activities,
                             lst_act=lst_acts,
                             file_path=path_to_boxplot_duration)
            ps.plot_boxplot_duration = sub_path + boxplot_duration_filename
            logger.info('created boxplot_duration for ' + str(ps.name))
        except Exception as e:
            print(e)
            logger.error("couldn't create boxplot_duration")

        try:
            hist_cum_duration_filename = settings.PLOT_ACT_CUM_DUR_FN
            path_to_hist_cum_duration = path + hist_cum_duration_filename
            hist_cum_duration(df_activities,
                              act_lst=lst_acts,
                              file_path=path_to_hist_cum_duration)
            ps.plot_hist_cum_duration = sub_path + hist_cum_duration_filename
            logger.info('created hist_cum_duration for ' + str(ps.name))
        except:
            logger.error("couldn't create hist_cum_duration")

        try:
            heatmap_transitions_filename = settings.PLOT_ACT_HM_TRANS_FN
            path_to_heatmap_transitions = path + heatmap_transitions_filename
            heatmap_transitions(df_activities,
                                lst_act=lst_acts,
                                file_path=path_to_heatmap_transitions)
            ps.plot_heatmap_transitions = sub_path + heatmap_transitions_filename
            logger.info('created heatmap_transitions for ' + str(ps.name))
        except Exception as e:
            print(e)
            logger.error("couldn't create heatmap_transitions")

        try:
            ridge_line_filename = settings.PLOT_ACT_RIDGE_FN
            path_to_ridge_line = path + ridge_line_filename
            ridge_line(df_activities,
                       lst_act=lst_acts,
                       file_path=path_to_ridge_line)
            ps.plot_ridge_line = sub_path + ridge_line_filename
            logger.info('created ridge_line for ' + str(ps.name))
        except:
            logger.error("couldn't create ridge_line")

        ps.save()