(self, X: pd.DataFrame)
return test_energy
Using the learned mixture probability, mean and covariance for each component k, compute the energy on the
        given data.
Using the learned mixture probability, mean and covariance for each component k, compute the energy on the
        given data.
Using the learned mixture probability mean and covariance for each component k compute the energy on the given data .
def predict(self, X: pd.DataFrame):
        """Using the learned mixture probability, mean and covariance for each component k, compute the energy on the
        given data."""
        self.dagmm.eval()
        X.interpolate(inplace=True)
        X.bfill(inplace=True)
        data = X.values
        sequences = [data[i:i + self.sequence_length] for i in range(len(data) - self.sequence_length + 1)]
        data_loader = DataLoader(dataset=sequences, batch_size=1, shuffle=False)
        test_energy = np.full((self.sequence_length, X.shape[0]), np.nan)

        encodings = np.full((self.sequence_length, X.shape[0], self.hidden_size), np.nan)
        decodings = np.full((self.sequence_length, X.shape[0], X.shape[1]), np.nan)
        euc_errors = np.full((self.sequence_length, X.shape[0]), np.nan)
        csn_errors = np.full((self.sequence_length, X.shape[0]), np.nan)

        for i, sequence in enumerate(data_loader):
            enc, dec, z, gamma = self.dagmm(self.to_var(sequence).float())
            sample_energy, _ = self.dagmm.compute_energy(z, size_average=False)
            idx = (i % self.sequence_length, np.arange(i, i + self.sequence_length))
            test_energy[idx] = sample_energy.data.numpy()

            if self.details:
                encodings[idx] = enc.data.numpy()
                decodings[idx] = dec.data.numpy()
                euc_errors[idx] = z[:, 1].data.numpy()
                csn_errors[idx] = z[:, 2].data.numpy()

        test_energy = np.nanmean(test_energy, axis=0)

        if self.details:
            self.prediction_details.update({'latent_representations': np.nanmean(encodings, axis=0).T})
            self.prediction_details.update({'reconstructions_mean': np.nanmean(decodings, axis=0).T})
            self.prediction_details.update({'euclidean_errors_mean': np.nanmean(euc_errors, axis=0)})
            self.prediction_details.update({'cosine_errors_mean': np.nanmean(csn_errors, axis=0)})

        return test_energy
def predict ( self , X : pd . DataFrame ) : self . dagmm . eval ( ) X . interpolate ( inplace = True ) X . bfill ( inplace = True ) data = X . values sequences = [ data [ i : i + self . sequence_length ] for i in range ( len ( data ) - self . sequence_length + 1 ) ] data_loader = DataLoader ( dataset = sequences , batch_size = 1 , shuffle = False ) test_energy = np . full ( ( self . sequence_length , X . shape [ 0 ] ) , np . nan ) encodings = np . full ( ( self . sequence_length , X . shape [ 0 ] , self . hidden_size ) , np . nan ) decodings = np . full ( ( self . sequence_length , X . shape [ 0 ] , X . shape [ 1 ] ) , np . nan ) euc_errors = np . full ( ( self . sequence_length , X . shape [ 0 ] ) , np . nan ) csn_errors = np . full ( ( self . sequence_length , X . shape [ 0 ] ) , np . nan ) for i , sequence in enumerate ( data_loader ) : enc , dec , z , gamma = self . dagmm ( self . to_var ( sequence ) . float ( ) ) sample_energy , _ = self . dagmm . compute_energy ( z , size_average = False ) idx = ( i % self . sequence_length , np . arange ( i , i + self . sequence_length ) ) test_energy [ idx ] = sample_energy . data . numpy ( ) if self . details : encodings [ idx ] = enc . data . numpy ( ) decodings [ idx ] = dec . data . numpy ( ) euc_errors [ idx ] = z [ : , 1 ] . data . numpy ( ) csn_errors [ idx ] = z [ : , 2 ] . data . numpy ( ) test_energy = np . nanmean ( test_energy , axis = 0 ) if self . details : self . prediction_details . update ( { 'latent_representations' : np . nanmean ( encodings , axis = 0 ) . T } ) self . prediction_details . update ( { 'reconstructions_mean' : np . nanmean ( decodings , axis = 0 ) . T } ) self . prediction_details . update ( { 'euclidean_errors_mean' : np . nanmean ( euc_errors , axis = 0 ) } ) self . prediction_details . update ( { 'cosine_errors_mean' : np . nanmean ( csn_errors , axis = 0 ) } ) return test_energy