Exemple #1
0
def create_moving_average_model(graph, model, profile, colour):
    """
    Rendering the moving average model according to its computed properties.

    :param charts.Graph graph: the scatter plot to render new models
    :param model: the moving average model which to be rendered to the graph
    :param dict profile: the profile to obtains the x-coordinates
    :param colour: the color of the current model to distinguish in the case of several models in the graph
    :return charts.Graph: the modified graph with new moving average model
    """
    # Create legend for the plotted model
    legend = '{0}: window={1}, R^2={2:f}'.format(model['moving_method'],
                                                 model['window_width'],
                                                 model['r_square'])
    # Obtains the x-coordinates with the required uid to pair with current model
    params = {'of_key': 'amount', 'per_key': model['per_key']}
    for x_pts, _, uid in data_provider.data_provider_mapper(profile, **params):
        if uid == model['uid']:
            # Plot the model
            graph.line(x=sorted(x_pts),
                       y=model['bucket_stats'],
                       line_color=colour,
                       line_width=3.5,
                       legend=legend)
    return graph
Exemple #2
0
def postprocess(profile, **configuration):
    """Invoked from perun core, handles the postprocess actions

    Arguments:
        profile(dict): the profile to analyze
        configuration: the perun and options context
    """
    # Validate the input configuration
    tools.validate_dictionary_keys(configuration,
                                   ['method', 'regression_models', 'steps'],
                                   [])

    # Perform the regression analysis
    analysis = compute(data_provider.data_provider_mapper(profile),
                       configuration['method'],
                       configuration['regression_models'],
                       steps=configuration['steps'])

    # Store the results
    if 'models' not in profile['global']:
        profile['global']['models'] = analysis
    else:
        profile['global']['models'].extend(analysis)

    return PostprocessStatus.OK, "", {'profile': profile}
Exemple #3
0
def postprocess(profile, **configuration):
    """
    Invoked from perun core, handles the postprocess actions

    :param dict profile: the profile to analyze
    :param configuration: the perun and options context
    """
    # Perform the non-parametric analysis using the regressogram method
    regressogram_models = methods.compute_regressogram(
        data_provider.data_provider_mapper(profile, **configuration),
        configuration)

    # Return the profile after the execution of regressogram method
    return PostprocessStatus.OK, '', {
        'profile': tools.add_models_to_profile(profile, regressogram_models)
    }
Exemple #4
0
def postprocess(profile, **configuration):
    """Invoked from perun core, handles the postprocess actions

    :param dict profile: the profile to analyze
    :param configuration: the perun and options context
    """
    # Validate the input configuration
    tools.validate_dictionary_keys(configuration,
                                   ['method', 'regression_models', 'steps'],
                                   [])

    # Perform the regression analysis
    analysis = methods.compute(data_provider.data_provider_mapper(
        profile, **configuration),
                               configuration['method'],
                               configuration['regression_models'],
                               steps=configuration['steps'])

    # Store the results
    profile = tools.add_models_to_profile(profile, analysis)

    return PostprocessStatus.OK, "", {'profile': profile}