emanuel-metzenthin / Lime-For-Time

Application of the LIME algorithm by Marco Tulio Ribeiro, Sameer Singh, Carlos Guestrin to the domain of time series classification
95 stars 21 forks source link

Negative dimensions Error #14

Open lnthach opened 11 months ago

lnthach commented 11 months ago

Dataset: http://www.timeseriesclassification.com/description.php?Dataset=Chinatown num_slices=10 num_features=10 replacement_method='noise'

Trying to explain this dataset (with any model) will throw the following error: ValueError: negative dimensions are not allowed

Probably because in some cases start_idx > end_idx so np.random.uniform is fed with a negative number as a consequence:

def perturb_noise(m, start_idx, end_idx, channels):
    # univariate
    if len(m.shape) == 1:
        m[start_idx:end_idx] = np.random.uniform(m.min(), m.max(),
                                                 end_idx - start_idx)
        return

    for chan in channels:
        m[chan][start_idx:end_idx] = np.random.uniform(m[chan].min(),
                                                       m[chan].max(),
                                                       end_idx - start_idx)