Hacktoberfest 2026:メンテナが10月に向けて印を付けた、オープンで初心者向けの issue。 Hacktoberfest の issue を見る

Bootstrap prediction interval

オープン
#323 コメント 9 件 リアクション 0 件 担当者 1 名 GitHub で見る

メンテナーはふだん 1 日以内に返信

@bashtage がすでに取り組んでいます。

2019年11月9日 から。

評価

この issue はまだ評価されていません。

説明

enhancement

I'm trying to bootstrap the prediction interval for an sklearn style non-parametric estimator (specifically catboost regression). I want the prediction interval for the sum of n predictions (the data has time order). I'm using the method from Davison and Hinkley "Bootstrap Methods and their Applications" algorithm 6.4 i.e.

fit the model to X,y with residuals e
repeat R times
  X* = X, e*=sample(e), y*=F(X*) + e*
  fit y*=F'(X*)
  repeat M times
     e+=sample(e,n)
     Yhat-Y+ = sum(F(X*)-(F'(X*)+e+))

As far as I can see, there's no convience wrapper for a prediction interval similar bs.conf_int()?

Also like in https://github.com/bashtage/arch/issues/165 I only want the first n samples for e+ - I assume I still have to use the workaround from this issue?

My main question though is how to implement the two loops? I don't think creating two seperate CircularBlockBootstrap() instances is correct though since the random state of the inner bootstrap will be reset to whatever the default seed is? I think what I should do is create one bootstrap instance and use it as follows:

bs=CircularBlockBootstrap(block_size,e)
R=10
M=10

it = bs.bootstrap(N*(M+1))

for r in range(R):
    pos, _ = next(it)
    estar = pos[0]
    
    for m in range(M):
        pos, _ = next(it)
        eplus = pos[0][:n]  

My issue though is when I sample estar and eplus - because the data is blocked I need to ensure the block boundaries are the same - specifically if the block size is one week and X and Xplus don't both start on the same hour of the week then sampling from the same CircularBlockBootstrap() object will result in misalignment of the eplus samples?

Edit: As is usually the case, taking the time to write out the problem gave me enough time to think it out. I compute the offset from the start of e to the same time of week of the start of the X+ and then simply sample as follows:

    eplus = pos[0][offset:n+offset]  
主要言語
Python
スター
1.6k
フォーク
298
平均マージ
14時間 46分
マージ済み PR(30日)
106

環境構築

このプロジェクトには開発コンテナ、Dockerfile、コントリビューションガイドがありません。まず README を読み、一般的な手順ははじめてのコントリビューションガイドを参照してください。

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

bashtage/arch のほかの issue

bashtage/arch の issue をすべて見る

似ている issue

Python の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。