Hey! Thanks for opening this issue!

Đang mở
#1,977 1 bình luận 0 reaction 0 người được giao Xem trên GitHub

Chưa có ai nhận issue này.

Đánh giá

Độ khó
4/5
Thời gian dự kiến
3-5 ngày
Mức phù hợp với người mới
20/100
Loại issue
Lỗi
Độ rõ ràng
Cần làm rõ
Mức độ hoạt động
Đình trệ
Công nghệ
machine-learning, matplotlib, numpy, pandas, python, scikit-learn
Lĩnh vực
data, machine-learning

Hướng nghiên cứu

Bắt đầu với script Python được dán và cấu hình AutoBnnMapEstimator, sau đó tái hiện các giá trị metric đã được báo cáo bằng cách sử dụng scaling, likelihood, các period và các lệnh gọi prediction đi kèm. So sánh các prediction và target đã được scale với phép tính metric để xác định vấn đề nằm ở output của model hay ở bước evaluation. Công việc được xem là hoàn tất khi đã xác định rõ nguyên nhân và có bản sửa hoặc lời giải thích có thể tái hiện.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

          Hey! Thanks for opening this issue! 

I am also trying to use the codes for AutoBNN shared here to model this data, but it is giving me very big values of the performance metric, how may i adjust?

-- 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}")

Ngôn ngữ chính
Jupyter Notebook
Star
4.4k
Fork
1.1k
Chỉ số merge pull request
Không có pull request nào được merge trong 30 ngày

Chuẩn bị môi trường

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của tensorflow/probability

Tất cả issue của tensorflow/probability

Issue tương tự

Thêm issue về Data Engineering

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.