python/methylnet/interpretation_classes.py
def build_explainer(self, train_methyl_array, method='kernel', batch_size=100): # can interpret latent dimensions
        """Builds SHAP explainer using background samples.

        Parameters
        ----------
        train_methyl_array : type
            Train Methylation Array from which to populate background samples to make estimated explanations.
        method : type
            SHAP explanation method?
        batch_size : type
            Break up prediction explanation creation into smaller batch sizes for lower memory consumption.
        """
        self.method = method
        if self.method =='kernel':
            self.explainer=shap.KernelExplainer(self.prediction_function, train_methyl_array.return_raw_beta_array(), link="identity")
        elif self.method == 'deep':
            self.explainer=shap.DeepExplainer(self.prediction_function, to_tensor(train_methyl_array.return_raw_beta_array()) if not self.cuda else to_tensor(train_methyl_array.return_raw_beta_array()).cuda())
        elif self.method == 'gradient':
            self.explainer=shap.GradientExplainer(self.prediction_function, to_tensor(train_methyl_array.return_raw_beta_array()) if not self.cuda else to_tensor(train_methyl_array.return_raw_beta_array()).cuda(), batch_size=batch_size)
        else:
            print('Not Implemented, default to kernel explainer.')
            self.method = 'kernel'
            self.explainer=shap.KernelExplainer(self.prediction_function, train_methyl_array.return_raw_beta_array(), link="identity")
Builds SHAP explainer using background samples.

        Parameters
        ----------
        train_methyl_array : type
            Train Methylation Array from which to populate background samples to make estimated explanations.
        method : type
            SHAP explanation method?
        batch_size : type
            Break up prediction explanation creation into smaller batch sizes for lower memory consumption.
        
Builds SHAP explainer using background samples.
Parameters

train_methyl_array : type
Train Methylation Array from which to populate background samples to make estimated explanations.
method : type
SHAP explanation method.
batch_size : type
Break up prediction explanation creation into smaller batch sizes for lower memory consumption.
Builds SHAP explainer using background samples . Parameters train_methyl_array : type Train Methylation Array from which to populate background samples to make estimated explanations . method : type SHAP explanation method . batch_size : type Break up prediction explanation creation into smaller batch sizes for lower memory consumption .
def build_explainer(self, train_methyl_array, method='kernel', batch_size=100): 
        self.method = method
        if self.method =='kernel':
            self.explainer=shap.KernelExplainer(self.prediction_function, train_methyl_array.return_raw_beta_array(), link="identity")
        elif self.method == 'deep':
            self.explainer=shap.DeepExplainer(self.prediction_function, to_tensor(train_methyl_array.return_raw_beta_array()) if not self.cuda else to_tensor(train_methyl_array.return_raw_beta_array()).cuda())
        elif self.method == 'gradient':
            self.explainer=shap.GradientExplainer(self.prediction_function, to_tensor(train_methyl_array.return_raw_beta_array()) if not self.cuda else to_tensor(train_methyl_array.return_raw_beta_array()).cuda(), batch_size=batch_size)
        else:
            print('Not Implemented, default to kernel explainer.')
            self.method = 'kernel'
            self.explainer=shap.KernelExplainer(self.prediction_function, train_methyl_array.return_raw_beta_array(), link="identity")
def build_explainer ( self , train_methyl_array , method = 'kernel' , batch_size = 100 ) : self . method = method if self . method == 'kernel' : self . explainer = shap . KernelExplainer ( self . prediction_function , train_methyl_array . return_raw_beta_array ( ) , link = "identity" ) elif self . method == 'deep' : self . explainer = shap . DeepExplainer ( self . prediction_function , to_tensor ( train_methyl_array . return_raw_beta_array ( ) ) if not self . cuda else to_tensor ( train_methyl_array . return_raw_beta_array ( ) ) . cuda ( ) ) elif self . method == 'gradient' : self . explainer = shap . GradientExplainer ( self . prediction_function , to_tensor ( train_methyl_array . return_raw_beta_array ( ) ) if not self . cuda else to_tensor ( train_methyl_array . return_raw_beta_array ( ) ) . cuda ( ) , batch_size = batch_size ) else : print ( 'Not Implemented, default to kernel explainer.' ) self . method = 'kernel' self . explainer = shap . KernelExplainer ( self . prediction_function , train_methyl_array . return_raw_beta_array ( ) , link = "identity" )
Builds SHAP explainer using background samples.
Builds SHAP explainer using background samples .
# can interpret latent dimensions """Builds SHAP explainer using background samples.

        Parameters
        ----------
        train_methyl_array : type
            Train Methylation Array from which to populate background samples to make estimated explanations.
        method : type
            SHAP explanation method?
        batch_size : type
            Break up prediction explanation creation into smaller batch sizes for lower memory consumption.
        """
self
train_methyl_array
method
batch_size