[docs]classKernelPCA(DimRedMethod):""" Kernel principal component analysis which wraps scikit-learn's KernelPCA, allowing for non-linear dimensionality reduction. Input arguments for the method are the same as supported by scikit-learn (see `KernelPCA scikit-learn documentation <https://scikit-learn.org/stable/modules/generated/sklearn.decomposition.KernelPCA.html>`_ for details), plus two additional immuneML arguments: - components (list): which two components (1-indexed) to use for visualization in the :ref:`DimensionalityReduction` report. Default: [1, 2]. - compute_total_variance (bool): if True, computes the total variance in kernel feature space during fit by building the full n_samples × n_samples kernel matrix, so that explained variance ratios are expressed as a fraction of total kernel-space variance rather than relative to the retained components only. This roughly doubles the fit computation time. Default: false. **YAML specification:** .. indent with spaces .. code-block:: yaml definitions: ml_methods: my_kernel_pca: KernelPCA: n_components: 5 kernel: rbf components: [3, 4] compute_total_variance: false """def__init__(self,name:str=None,**kwargs):super().__init__(name)self.components=kwargs.pop('components',None)self._compute_total_variance=kwargs.pop('compute_total_variance',False)self._total_kernel_variance=Noneself.method_kwargs=kwargsself.method=SklearnKernelPCA(**self.method_kwargs)self._validate_components(self.method.n_components)