stanfordmlgroup / ngboost

Natural Gradient Boosting for Probabilistic Prediction
Apache License 2.0
1.62k stars 214 forks source link

ValueError: could not broadcast input array from shape (0,15) into shape (1,15) #307

Closed yuenshingyan closed 1 year ago

yuenshingyan commented 1 year ago

ValueError: could not broadcast input array from shape (0,15) into shape (1,15) occurred when I tried to train a NGBClassifier.

Code

ngb = NGBClassifier(verbose=False)
ngb.fit(X_train, y_train)

Traceback

Complete error traceback ```python --------------------------------------------------------------------------- ValueError Traceback (most recent call last) Input In [177], in () 16 # NGBoost 17 ngb = NGBClassifier(verbose=False) ---> 18 ngb.fit(X_train, y_train) 20 for r, s in zip(races, sub_backtest): 21 r = r[1].drop(['race_date', 'race_index'], axis=1) File ~/anaconda3/lib/python3.9/site-packages/ngboost/ngboost.py:308, in NGBoost.fit(self, X, Y, X_val, Y_val, sample_weight, val_sample_weight, train_loss_monitor, val_loss_monitor, early_stopping_rounds) 303 _, col_idx, X_batch, Y_batch, weight_batch, P_batch = self.sample( 304 X, Y, sample_weight, params 305 ) 306 self.col_idxs.append(col_idx) --> 308 D = self.Manifold(P_batch.T) 310 loss_list += [train_loss_monitor(D, Y_batch, weight_batch)] 311 loss = loss_list[-1] File ~/anaconda3/lib/python3.9/site-packages/ngboost/distns/categorical.py:62, in k_categorical..Categorical.__init__(self, params) 60 _, N = params.shape 61 self.logits = np.zeros((K, N)) ---> 62 self.logits[1:K, :] = params # default the 0th class logits to 0 63 self.probs = sp.special.softmax(self.logits, axis=0) ValueError: could not broadcast input array from shape (0,15) into shape (1,15) ```

Specs OS: Ubuntu 22.04.1 LTS x86_64 Host: G7 MD Kernel: 5.15.0-53-generic Uptime: 4 hours, 38 mins Packages: 2102 (dpkg), 19 (snap) Shell: bash 5.1.16 Resolution: 1920x1080 DE: GNOME 42.5 WM: Mutter Terminal: gnome-terminal CPU: 11th Gen Intel i7-11800H (16) @ GPU: NVIDIA GeForce RTX 3050 Ti Mobi GPU: Intel TigerLake-H GT1 [UHD Grap Memory: 10436MiB / 15780MiB

Dataset y_train.csv X_train.csv

alejandroschuler commented 1 year ago

your y values are all 0s.