시작하기무료로 시작하기

Forecast evaluation & experimentation

In this exercise, you'll evaluate the forecast model's performance to explore the use cases of experimentation.

The merged forecast (fc), combining predictions with actual test results, is preloaded. Evaluation functions (mape, rmse, coverage) and pandas (as pd) are also ready for use. Here's a quick reference for the functions:

def mape(y, yhat):
    mape = mean(abs(y - yhat) / y) 
    return mape

def rmse(y, yhat):
    rmse = (mean((y - yhat) ** 2)) ** 0.5
    return rmse

def coverage(y, lower, upper):
    coverage = sum((y <= upper) & (y >= lower)) / len(y)
    return coverage

First, compute performance metrics for the model. Then, answer a question about the goals of experimentation in forecasting.

이 연습은 강의의 일부입니다

Designing Forecasting Pipelines for Production

강의 보기

실습형 인터랙티브 연습

이 예제를 이 샘플 코드를 완성하여 풀어보세요.

performance_metrics = []

# Loop through models and calculate metrics
for model in ["LGBMRegressor", "XGBRegressor", "LinearRegression"]:
    performance_metrics.append({
        "model": model,
        "mape": ____(fc["y"], fc[model]),
        "rmse": ____(fc["y"], fc[____]),
        "coverage": ____(fc["y"], fc[f"{model}-lo-95"], fc[f"{model}-hi-95"])
    })

# Create DataFrame and sort by RMSE
fc_performance = pd.DataFrame(performance_metrics).sort_values("____")

print(fc_performance)
코드 편집 및 실행