Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error with Forecaster Attribute 'validation_metric_value' #52

Closed
JPVercosa opened this issue Jun 12, 2023 · 2 comments
Closed

Error with Forecaster Attribute 'validation_metric_value' #52

JPVercosa opened this issue Jun 12, 2023 · 2 comments
Assignees
Labels
bug Something isn't working

Comments

@JPVercosa
Copy link

Hey, I've just started using Scalecast, and was trying to use the RandomForest Model. After initializing Forecaster and adding COVID19 Regressor and Time Trend, I got the error:

AttributeError: 'Forecaster' object has no attribute 'validation_metric_value'

Here is the code that I'm running:


def plot_test_export_summaries(f):
    """ exports the relevant statisitcal information and displays a plot of the test-set results for the last model run
    """
    f.plot_test_set(models=f.estimator,include_train=False)
    plt.title(f'{f.estimator} test-set results',size=16)
    plt.show()
    return f.export('model_summaries',determine_best_by='TestSetMAPE')[
        [
            'ModelNickname',
            'HyperParams',
            'TestSetMAPE',
            'InSampleMAPE',
        ]
    ]

icms = Forecaster(y=df.ICMS, current_dates=df.DATA, test_length=12, freq='MS')
icms.generate_future_dates(12)
icms.plot()

icms.add_covid19_regressor()
icms.add_time_trend()

icms.set_estimator('rf')
rf_grid = {
    'max_depth':[2,3,4,5],
    'n_estimators':[100,200,500],
    'max_features':['auto','sqrt','log2'],
    'max_samples':[.75,.9,1],
}
icms.ingest_grid(rf_grid)
icms.auto_forecast()
plot_test_export_summaries(icms)

Full error:
Error

I'm trying to figure out what is the problem, if anyone have any suggestion, I would aprecciate.

I still want to use other models ('xgboost', 'LSTM' and 'prophet'), but I get the same error. Am I missing something?

@mikekeith52
Copy link
Owner

Hi,

Before calling icms.auto_forecast() and after running icms.ingest_grid(), allow the object to select the optimal hyperparameters by calling either icms.tune() or icms.cross_validate(). This should avoid the error.

Next scalecast update, I will make sure there is a more descriptive error message or warning when this happens.

Thanks for raising the issue!

@mikekeith52 mikekeith52 self-assigned this Jun 12, 2023
@mikekeith52 mikekeith52 added the bug Something isn't working label Jun 12, 2023
@JPVercosa
Copy link
Author

Thank you, it solved the problem.

mikekeith52 added a commit that referenced this issue Jun 25, 2023
- Changed requirements to avoid a dask/lightgbm error when importing the Forecaster module (#46).
- Calling `auto_forecast()` without tuning a model first no longer raises an error when banking the model's history (#52).
- RNN and LSTM models no longer raise errors with default CV parameters.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants