コード例 #1
0
def test_get_actual_peaks():
    actual_load_fname = 'ieso_ga_master_dataset_allWeather_updated2020.csv'
    forecasts_fname = 'ga_forecasts_top_2.csv'

    actual_load, forecasts = dataloader(actual_load_fname, forecasts_fname)

    # Test get_actual_peaks
    actual_peaks = get_actual_peaks(actual_load)

    assert isinstance(actual_peaks, pd.DataFrame)
コード例 #2
0
def test_summarize():
    actual_load_fname = 'ieso_ga_master_dataset_allWeather_updated2020.csv'
    forecasts_fname = 'ga_forecasts_top_2.csv'

    actual_load, forecasts = dataloader(actual_load_fname, forecasts_fname)

    # Test get_actual_peaks
    actual_peaks = get_actual_peaks(actual_load)

    summary = summarize(actual_peaks, forecasts, save_path='')

    assert isinstance(summary, pd.DataFrame)
コード例 #3
0
def test_summarize_top_n():
    actual_load_fname = 'ieso_ga_master_dataset_allWeather_updated2020.csv'
    forecasts_fname = 'ga_forecasts_top_2.csv'

    actual_load, forecasts = dataloader(actual_load_fname, forecasts_fname)

    # Test get_actual_peaks
    actual_peaks = get_actual_peaks(actual_load)

    top_n_results, top_n_sum = summarize_top_n(actual_peaks, forecasts, 1)

    assert isinstance(top_n_results, pd.DataFrame)
    assert isinstance(top_n_sum, pd.DataFrame) or isinstance(
        top_n_sum, pd.Series)
コード例 #4
0
def get_report(actual_load, forecasts, n_probs_to_use):
    """
    Arguments:
        actual_load:
            A dataframe. The entire ground-truth demands.

        forecasts:
            A dataframe. The entire forecasting results.

        n_probs_to_use:
            Number of top probabilities to use on each day

    Return:
        A dataframe. The performance report.

    This function generates the performance reports for top 
    1, top 5, top 10, and top 20 peak days.

    """

    mapper = {}
    attr_keys = [
        'Season', 'Top_n_peaks', 'Top_n_probs', 'HitRate(%)', 'Performance(%)'
    ]
    hour_keys = ['12', '15', '16', '17', '18', '19', '20']
    keys = attr_keys + hour_keys
    for key in keys:
        mapper[key] = []

    actual_peaks = get_actual_peaks(actual_load)
    top_n_forecasts = get_top_n_forecasts(forecasts, n_probs_to_use)

    for n_peaks_to_use in [1, 3, 5, 10, 20]:

        top_n_results, _ = summarize_top_n(actual_peaks, forecasts,
                                           n_peaks_to_use)
        top_n_adjusted = adjust_probs(top_n_results, top_n_forecasts,
                                      n_peaks_to_use, n_probs_to_use)

        # Update mapper with each season
        mapper = get_top_n_report(top_n_results, top_n_adjusted,
                                  n_peaks_to_use, n_probs_to_use, hour_keys,
                                  mapper)

    report_df = pd.DataFrame(data=mapper)

    return report_df
コード例 #5
0
def test_adjust_probs():
    actual_load_fname = 'ieso_ga_master_dataset_allWeather_updated2020.csv'
    forecasts_fname = 'ga_forecasts_top_2.csv'

    actual_load, forecasts = dataloader(actual_load_fname, forecasts_fname)

    n_peaks_to_use = 1
    n_probs_to_use = 3

    # Get top n forecasts
    top_n_forecasts = get_top_n_forecasts(forecasts, n_probs_to_use)

    # Get actual peaks
    actual_peaks = get_actual_peaks(actual_load)

    # Get top n results
    top_n_results, _ = summarize_top_n(actual_peaks, forecasts, n_peaks_to_use)

    # Get top n adjusted probabilities
    top_n_adjusted = adjust_probs(top_n_results, top_n_forecasts,
                                  n_peaks_to_use, n_probs_to_use)

    assert isinstance(top_n_adjusted, pd.DataFrame)
コード例 #6
0
    actual_load_fname = 'ieso_ga_master_dataset_allWeather_updated2020.csv'
    forecasts_fname = 'ga_forecasts_top_2.csv'

    actual_load, forecasts = dataloader(actual_load_fname, forecasts_fname)

    n_peaks_to_use = 1
    n_probs_to_use = 3

    n_probs = forecasts_fname.split('_')[3].split('.')[0]
    n_probs = int(n_probs)
    if n_probs_to_use > n_probs:
        print('n_probs_to_use must not exceed n_probs!')
        n_probs_to_use = n_probs

    # Get top n forecasts
    top_n_forecasts = get_top_n_forecasts(forecasts, n_probs_to_use)
    print('Top n forecasts:')
    print(top_n_forecasts.head(3))

    # Get actual peaks
    actual_peaks = get_actual_peaks(actual_load)

    # Get top n results
    top_n_results, _ = summarize_top_n(actual_peaks, forecasts, n_peaks_to_use)

    # Get top n adjusted probabilities
    top_n_adjusted = adjust_probs(top_n_results, top_n_forecasts,
                                  n_peaks_to_use, n_probs_to_use)
    print('Top n adjusted:')
    print(top_n_adjusted.head(3))