AutoBNN
还没有人认领这个 Issue。
评估
- 难度
- 4/5
- 预计耗时
- 3-5 天
- 新手友好度
- 20/100
- Issue 类型
- 缺陷
- 描述清晰度
- 需要澄清
- 活跃度
- 停滞
- 技术栈
- numpy, pandas, python, scikit-learn
- 领域
- data, machine-learning
调研方向
复现提供的脚本,并检查 fit、predict 和 predict_quantiles 使用的 AutoBnnMapEstimator 入口点,包括配置的似然、周期、特征和缩放后的目标值。将报告的指标和预测图与训练/测试划分进行比较;完成的标准是找出错误的可复现原因,或确认在此设置下该行为符合预期。
由索引模型根据 Issue 内容生成。
描述
Hello, i am trying to use the codes of AutoBNN shared here to mdel my data but it gives very big values of MAE, RMSE and Rsquared, what adjustment can i make to reduce the eror ?
here is the code
-- coding: utf-8 --
"""
Created on Sun Oct 27 15:41:32 2024
@author: iO
"""
import jax
import jax.numpy as jnp
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
from sklearn.preprocessing import StandardScaler
from autobnn import estimators
from autobnn import training_util
Seed setup
seed = jax.random.PRNGKey(0)
Load data
data = pd.read_csv("path_to_data/Bukomansimbi.txt", delim_whitespace=True)
data.columns = data.columns.str.lower()
Date and rainfall extraction
data['date'] = pd.to_datetime(data[['year', 'month', 'day']])
rainfall_by_day = data['value'].values
Train/test split configuration
num_forecast_steps = 365
train_data = rainfall_by_day[:-num_forecast_steps]
test_data = rainfall_by_day[-num_forecast_steps:]
dates_train = data['date'].values[:-num_forecast_steps]
dates_test = data['date'].values[-num_forecast_steps:]
Normalize and scale data
scaler = StandardScaler()
train_scaled = scaler.fit_transform(train_data.reshape(-1, 1)).flatten()
test_scaled = scaler.transform(test_data.reshape(-1, 1)).flatten()
Add time feature for seasonality
month_sin = np.sin(2 * np.pi * data['month'].values / 12)
month_cos = np.cos(2 * np.pi * data['month'].values / 12)
x_train = np.stack([month_sin[:-num_forecast_steps], month_cos[:-num_forecast_steps]], axis=1)
x_test = np.stack([month_sin[-num_forecast_steps:], month_cos[-num_forecast_steps:]], axis=1)
Initialize AutoBNN
est = estimators.AutoBnnMapEstimator(
'sum_of_products',
likelihood_model='normal_likelihood_logistic_noise',
seed=seed,
periods=(1.0,), # one year period as float since date normalization handles scaling
num_particles=32
)
Fit the model
est.fit(x_train, train_scaled[:, None])
Prediction
preds = est.predict(x_test)[:, 0] # Squeeze predictions
quantiles = est.predict_quantiles(x_test, q=[2.5, 50., 90., 97.5])
lo, mid, p90, hi = quantiles[:, 0], quantiles[:, 1], quantiles[:, 2], quantiles[:, 3]
Plotting the results
plt.figure(figsize=(16, 10))
plt.plot(dates_train, train_scaled, label='Training Data')
plt.plot(dates_test, test_scaled, label='Actual')
plt.plot(dates_test, mid, label='Predictions', color='r')
plt.fill_between(dates_test, lo, hi, color='r', alpha=0.3, label='Confidence Interval')
plt.title('Rainfall Prediction in Bukomansimbi')
plt.xlabel('Date')
plt.ylabel('Standardized Rainfall')
plt.legend()
plt.show()
Performance Metrics
mae = np.mean(np.abs(preds - test_scaled))
rmse = np.sqrt(np.mean((preds - test_scaled) ** 2))
r_squared = 1 - np.sum((preds - test_scaled) ** 2) / np.sum((test_scaled - np.mean(test_scaled)) ** 2)
print(f"Mean Absolute Error (MAE): {mae:.2f}")
print(f"Root Mean Square Error (RMSE): {rmse:.2f}")
print(f"R-squared: {r_squared:.2f}")
- 主要语言
- Jupyter Notebook
- 星标
- 4.4k
- 派生
- 1.1k
- PR 合并指标
- 30 天内没有已合并 PR
环境准备
- 没有 Dockerfile 或 Docker Compose 文件
- 没有 Pull Request 模板
- 阅读贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
tensorflow/probability 的其他 Issue
-
KL divergence between two `TransformedDistribution`s with a shared non-injective bijector (`AbsoluteValue`) returns the base KL可能已有人在做 @Andreas-Hum 于 8 天前认领。 未关闭
难度 2/5 1-3 小时 新手友好度 72/100
tensorflow/probability#2036 ·
-
难度 3/5 1-2 天 新手友好度 68/100
tensorflow/probability#2034 ·
-
难度 5/5 一周以上 新手友好度 35/100
tensorflow/probability#2021 ·
-
难度 4/5 3-5 天 新手友好度 30/100
tensorflow/probability#2015 ·
-
难度 3/5 1-2 天 新手友好度 48/100
tensorflow/probability#2013 ·
查看 tensorflow/probability 的全部 Issue
相似的 Issue
-
Successor registrant to review: Navient Holdings, Inc. (CIK 2152623), 8-K12B 0001193125-26-436899未关闭successor-review
难度 2/5 1-3 小时 新手友好度 78/100
dgunning/edgartools#1889 ·
维护者通常 1 天内回复
-
discovery
难度 2/5 1-3 小时 新手友好度 64/100
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 72/100
Open-Systems-Pharmacology/OSPSuite.ParameterIdentification#377 ·
维护者通常 1 天内回复
-
GloFAS river spreading uses swapped longitude and latitude for the distance from the river mouth未关闭
难度 2/5 1-3 小时 新手友好度 72/100
nansencenter/NERSC-HYCOM-CICE#394 ·
-
documentation good first issue
难度 2/5 1-3 小时 新手友好度 85/100