Beispiel #1
0
    def test_plot_devices(self):
        from pyadlml.dataset.plot.devices import hist_counts, heatmap_trigger_one_day, heatmap_trigger_time,\
           hist_on_off, boxplot_on_duration, heatmap_cross_correlation, hist_trigger_time_diff

        df = self.data.df_devices
        lst = self.data.lst_devices

        hist_counts(df)
        hist_counts(df_dev=df, lst_dev=lst)

        heatmap_trigger_one_day(df)
        heatmap_trigger_one_day(df, lst_dev=lst)

        heatmap_trigger_time(df)
        heatmap_trigger_time(df, lst_dev=lst)

        hist_trigger_time_diff(df)

        hist_on_off(df)
        hist_on_off(df, lst_dev=lst)

        boxplot_on_duration(df)
        boxplot_on_duration(df, lst_dev=lst)

        heatmap_cross_correlation(df)
        heatmap_cross_correlation(df, lst_dev=lst)
    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)
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()
def gen_plots_devices(dataset, data):
    from pyadlml.dataset.plot.devices import hist_trigger_time_diff, boxplot_on_duration, \
        heatmap_trigger_one_day, heatmap_trigger_time, heatmap_cross_correlation, \
        hist_on_off, hist_counts

    sub_path = dataset.name + '/plots/'
    path = settings.MEDIA_ROOT + sub_path

    try:
        hist_trigger_time_diff_filename = 'hist_trigger_time_diff.png'
        path_to_hist_trigger_time_diff = path + hist_trigger_time_diff_filename
        hist_trigger_time_diff(data.df_devices,
                               file_path=path_to_hist_trigger_time_diff)
        dataset.plot_hist_trigger_time_diff = sub_path + hist_trigger_time_diff_filename
    except:
        pass

    try:
        heatmap_trigger_time_filename = 'heatmap_trigger_time.png'
        path_to_heatmap_trigger_time = path + heatmap_trigger_time_filename
        heatmap_trigger_time(data.df_devices,
                             file_path=path_to_heatmap_trigger_time)
        dataset.plot_heatmap_trigger_time = sub_path + heatmap_trigger_time_filename
    except:
        pass

    try:
        heatmap_trigger_one_day_filename = 'heatmap_trigger_one_day.png'
        path_to_heatmap_trigger_one_day = path + heatmap_trigger_one_day_filename
        heatmap_trigger_one_day(data.df_devices,
                                file_path=path_to_heatmap_trigger_one_day)
        dataset.plot_heatmap_trigger_one_day = sub_path + heatmap_trigger_one_day_filename
    except:
        pass

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

    #assign_plot_obj('boxplot_on_duration.png', boxplot_on_duration, dataset.plot_boxplot_on_duration,
    #                    path, sub_path, data.df_devices)
    #assign_plot_obj('hist_on_off.png', hist_on_off, dataset.plot_hist_on_off,
    #                    path, sub_path, data.df_devices)

    dataset.save()
Beispiel #5
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)
Beispiel #6
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)
Beispiel #7
0
def gen_plots_devices(dataset, data):
    from pyadlml.dataset.plot.devices import hist_trigger_time_diff, boxplot_on_duration, \
        heatmap_trigger_one_day, heatmap_trigger_time, heatmap_cross_correlation, \
        hist_on_off, hist_counts

    sub_path = dataset.name + '/plots/'
    path = settings.MEDIA_ROOT + sub_path

    try:
        hist_trigger_time_diff_filename = settings.PLOT_DEV_HIST_TRIG_TIME_FN
        path_to_hist_trigger_time_diff = path + hist_trigger_time_diff_filename
        hist_trigger_time_diff(data.df_devices,
                               file_path=path_to_hist_trigger_time_diff)
        dataset.plot_hist_trigger_time_diff = sub_path + hist_trigger_time_diff_filename
        logger.info('created hist_trigger_time_diff')
    except:
        logger.error("couldn't create hist_trigger_time_diff")

    try:
        heatmap_trigger_time_filename = settings.PLOT_DEV_HM_TRIG_TIME_FN
        path_to_heatmap_trigger_time = path + heatmap_trigger_time_filename
        heatmap_trigger_time(data.df_devices,
                             file_path=path_to_heatmap_trigger_time)
        dataset.plot_heatmap_trigger_time = sub_path + heatmap_trigger_time_filename
        logger.info('created heatmap_trigger_time')
    except:
        logger.error("couldn't create heatmap_trigger_time")

    try:
        heatmap_trigger_one_day_filename = settings.PLOT_DEV_HM_TRIG_ONE_DAY_FN
        path_to_heatmap_trigger_one_day = path + heatmap_trigger_one_day_filename
        heatmap_trigger_one_day(data.df_devices,
                                file_path=path_to_heatmap_trigger_one_day)
        dataset.plot_heatmap_trigger_one_day = sub_path + heatmap_trigger_one_day_filename
        logger.info('created heatmap_trigger_one_day')
    except:
        logger.error("couldn't create heatmap_trigger_one_day")

    try:
        hist_counts_filename = settings.PLOT_DEV_HIST_COUNTS_FN
        path_to_hist_counts = path + hist_counts_filename
        hist_counts(data.df_devices, file_path=path_to_hist_counts)
        dataset.plot_hist_counts = sub_path + hist_counts_filename
        logger.info('created hist_counts')
    except:
        logger.error("couldn't create hist_counts")

    try:
        hist_counts_filename = settings.PLOT_DEV_HIST_ON_OFF_FN
        path_to_hist_counts = path + hist_counts_filename
        hist_on_off(data.df_devices, file_path=path_to_hist_counts)
        dataset.plot_hist_on_off = sub_path + hist_counts_filename
        logger.info('created hist_on_off')
    except:
        logger.error("couldn't create hist_on_off")

    try:
        hist_counts_filename = settings.PLOT_DEV_BP_ON_DUR_FN
        path_to_hist_counts = path + hist_counts_filename
        boxplot_on_duration(data.df_devices, file_path=path_to_hist_counts)
        dataset.plot_boxplot_on_duration = sub_path + hist_counts_filename
        logger.info('created boxplot_on_duration')
    except:
        logger.error("couldn't create boxplot_on_duration")

    try:
        hist_counts_filename = settings.PLOT_DEV_HM_CROSS_CORR_FN
        path_to_hist_counts = path + hist_counts_filename
        heatmap_cross_correlation(data.df_devices,
                                  file_path=path_to_hist_counts)
        dataset.plot_heatmap_cross_correlation = sub_path + hist_counts_filename
        logger.info('created heatmap_cross_correlation')
    except:
        logger.error("couldn't create heatmap_cross_correlation")

    dataset.save()
Beispiel #8
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()