:py:mod:`squid.predictor` ========================= .. py:module:: squid.predictor Module Contents --------------- Classes ~~~~~~~ .. autoapisummary:: squid.predictor.BasePredictor squid.predictor.ScalarPredictor squid.predictor.ProfilePredictor squid.predictor.BPNetPredictor Functions ~~~~~~~~~ .. autoapisummary:: squid.predictor.predict_in_batches squid.predictor.profile_sum squid.predictor.profile_pca .. py:class:: BasePredictor Base class for running inference on in silico mutated sequences. .. !! processed by numpydoc !! .. py:attribute:: save_dir .. py:method:: __call__(x, x_ref=None, save_window=None) :abstractmethod: .. py:class:: ScalarPredictor(pred_fun, task_idx=0, batch_size=64, save_window=None, **kwargs) Bases: :py:obj:`BasePredictor` Module for handling scalar-based model predictions. :param pred_fun: Function for returning model predictions. :type pred_fun: built-in function :param task_idx: Task index corresponding to a specific output head. :type task_idx: int :param batch_size: The number of predictions per batch. :type batch_size: int :returns: Batch of scalar predictions corresponding to inputs. :rtype: torch.Tensor .. !! processed by numpydoc !! .. py:method:: __call__(x, x_ref=None, save_window=None) .. py:class:: ProfilePredictor(pred_fun, task_idx=0, batch_size=64, reduce_fun=np.sum, save_dir=None, save_window=None, **kwargs) Bases: :py:obj:`BasePredictor` Module for handling profile-based model predictions. :param pred_fun: Function for returning model predictions. :type pred_fun: function :param task_idx: Task index corresponding to a specific output head. :type task_idx: int :param batch_size: The number of predictions per batch. :type batch_size: int :param reduce_fun: Function for reducing profile prediction to scalar. :type reduce_fun: function :returns: Batch of scalar predictions corresponding to inputs. :rtype: torch.Tensor .. !! processed by numpydoc !! .. py:method:: __call__(x, x_ref=None, save_window=None) .. py:class:: BPNetPredictor(pred_fun, task_idx=0, batch_size=64, reduce_fun='wn', axis=1, save_dir=None, save_window=None, **kwargs) Bases: :py:obj:`BasePredictor` Module for handling BPNet (Kipoi) model predictions. :param pred_fun: Function for returning model predictions. :type pred_fun: function :param task_idx: Task index corresponding to a specific output head. :type task_idx: int :param batch_size: The number of predictions per batch. :type batch_size: int :param reduce_fun: Function for reducing profile prediction to scalar. :type reduce_fun: function :returns: Batch of scalar predictions corresponding to inputs. :rtype: torch.Tensor .. !! processed by numpydoc !! .. py:method:: __call__(x, x_ref=None, save_window=None) .. py:function:: predict_in_batches(x, x_ref=None, model_pred_fun=None, batch_size=None, task_idx=None, save_window=None, **kwargs) Function to compute model predictions in batch mode. :param x: One-hot sequences (shape: (N, L, A)). :type x: numpy.ndarray :param x_ref: One-hot reference sequence (shape: (L, A)). Required if save_window is not None. :type x_ref: numpy.ndarray, optional :param model_pred_fun: Built-in function for accessing model inference on inputs. :type model_pred_fun: function :param batch_size: The number of predictions per batch of model inference. :type batch_size: int :param save_window: Window used for delimiting sequences that are exported in 'x_mut' array :type save_window: [int, int], optional :returns: Model predictions. :rtype: numpy.ndarray .. !! processed by numpydoc !! .. py:function:: profile_sum(pred, save_dir=None) Function to transform predictions to scalars using summation. :param pred: Batch of profile-based predictions. :type pred: np.ndarray :returns: Batch of scalar predictions. :rtype: numpy.ndarray .. !! processed by numpydoc !! .. py:function:: profile_pca(pred, save_dir=None) Function to transform predictions to scalars using principal component analysis (PCA). :param pred: Batch of profile-based predictions. :type pred: np.ndarray :returns: Batch of scalar predictions formed from projection of embedded profiles onto the first principal component. :rtype: numpy.ndarray .. !! processed by numpydoc !!