Ejemplo n.º 1
0
def forecast(time_series, args, session_file=None):
    """Computes a time-series forecast

    """

    local_time_series = TimeSeries(time_series, api=args.retrieve_api_)

    output = args.predictions
    # Local forecasts: Forecasts are computed locally
    message = u.dated("Creating local forecasts.\n")
    u.log_message(message, log_file=session_file, console=args.verbosity)
    input_data = []
    if args.test_set is not None:
        input_data = [u.read_json(args.test_set)]
    elif args.horizon is not None:
        input_data = [{local_time_series.objective_id: { \
            "horizon": args.horizon}}]
    write_forecasts(local_time_series.forecast(*input_data), output)
Ejemplo n.º 2
0
def forecast(time_series, args, session_file=None):
    """Computes a time-series forecast

    """

    local_time_series = TimeSeries(time_series,
                                   api=args.retrieve_api_)

    output = args.predictions
    # Local forecasts: Forecasts are computed locally
    message = u.dated("Creating local forecasts.\n")
    u.log_message(message, log_file=session_file, console=args.verbosity)
    input_data = []
    if args.test_set is not None:
        input_data = [u.read_json(args.test_set)]
    elif args.horizon is not None:
        input_data = [{local_time_series.objective_id: { \
            "horizon": args.horizon}}]
    write_forecasts(local_time_series.forecast(*input_data),
                    output)
Ejemplo n.º 3
0
def remote_forecast(time_series,
                    forecast_args,
                    args,
                    api,
                    resume,
                    prediction_file=None,
                    session_file=None,
                    path=None,
                    log=None):
    """Computes a remote forecast.

    """

    time_series_id = bigml.api.get_time_series_id( \
        time_series)
    # if resuming, try to extract dataset form log files
    if resume:
        message = u.dated("Forecast not found. Resuming.\n")
        resume, forecast = c.checkpoint(c.is_forecast_created,
                                        path,
                                        debug=args.debug,
                                        message=message,
                                        log_file=session_file,
                                        console=args.verbosity)
    if not resume:
        local_time_series = TimeSeries(time_series, api=args.retrieve_api_)
        output = args.predictions
        if args.test_set is not None:
            input_data = u.read_json(args.test_set)
        elif args.horizon is not None:
            input_data = {local_time_series.objective_id: { \
                "horizon": args.horizon}}

        forecast = create_forecast(time_series_id,
                                   input_data,
                                   forecast_args,
                                   args,
                                   api,
                                   session_file=session_file,
                                   path=path,
                                   log=log)

        write_forecasts(forecast["object"]["forecast"]["result"], output)
Ejemplo n.º 4
0
def create_local_time_series(step):
    world.local_time_series = TimeSeries(world.time_series["resource"],
                                         world.api)
Ejemplo n.º 5
0
def i_create_local_time_series_from_file(step, export_file):
    world.local_time_series = TimeSeries(res_filename(export_file))