Closed OmarRafique closed 2 years ago
Hi! You can pass an instance of scikit-learn's PCA class (https://scikit-learn.org/stable/modules/generated/sklearn.decomposition.PCA.html) as the filter function. If you have not already consulted our official documentation website, please do so as there are several resources there to get you started.
from sklearn.decomposition import PCA
filter_func = PCA(n_components=2)
That worked. Thanks!!!
Will TSNE work the same way???
Yes. You can pass arbitrary objects with a fit_transform
method, so arbitrary scikit-learn transfomers. You can even pass arbitrary functions which act on 1D vectors. See https://giotto-ai.github.io/gtda-docs/0.5.1/modules/generated/mapper/pipeline/gtda.mapper.make_mapper_pipeline.html.
Could you please give a code example to use tSNE as a filter function?
This is as simple as importing the tSNE class from scikit-learn
from sklearn.manifold import TSNE
and using an instance of this class as a filter function in make_mapper_pipeline
. Please read the tutorial https://giotto-ai.github.io/gtda-docs/0.5.1/notebooks/mapper_quickstart.html for more details.
Could you please help me with the code that uses PCA as a filter function for the Mapper.