decomposition library - Printable Version +- Python Forum (https://python-forum.io) +-- Forum: Python Coding (https://python-forum.io/forum-7.html) +--- Forum: Data Science (https://python-forum.io/forum-44.html) +--- Thread: decomposition library (/thread-19820.html) |
decomposition library - Scott - Jul-16-2019 Hi everyone, I am trying import lib from decomposition.base_class import BaseDecompositionClassI am getting the following error ModuleNotFoundError: No module named 'decomposition' I have tried googling this lib but nothing comes up, is anyone familiar with it or knows how i can Import it? Thanks RE: decomposition library - scidam - Jul-16-2019 I don't know any module/package named decomposition. It is very general. May be sklearn.decomposition ?
RE: decomposition library - Scott - Jul-16-2019 I am getting it from this link below: https://github.com/jingmin1987/variable-clustering/blob/master/decomposition/var_clus.py Do you think he is creating the module himself? Thanks RE: decomposition library - scidam - Jul-16-2019 This module/subpackage is a part of the package you are using. Look at the content of the decomposition folder. RE: decomposition library - Scott - Jul-17-2019 Is he defining the module in the step in the link below? if so I have ran the code below first then tried the import code and I still get the same error. Sorry not too sure what mean by the above. https://github.com/jingmin1987/variable-clustering/blob/master/decomposition/base_class.py RE: decomposition library - scidam - Jul-18-2019 Your current working directory should contain decomposition folder and all its content (Python doens't know where the decomposition folder is located). Or you can just copy content of base_class.py (it is very small) file to your script and remove the line from decomposition ... etc .
RE: decomposition library - Scott - Jul-18-2019 the problem is the next line in the data is: import pandas as pd import numpy as np from sklearn.datasets import make_classification from decomposition.var_clus import VarClusDo you know how I show python where the decomposition folder is? RE: decomposition library - scidam - Jul-18-2019 (Jul-18-2019, 06:27 AM)Scott Wrote: Do you know how I show python where the decomposition folder is? Put the following just before from decomposition :import sys sys.path.insert(0,'/path/to/folder/where/decomposition/exists') RE: decomposition library - snippsat - Jul-18-2019 If look at Repo base there is a demo.ipynb click on it,it's a Notebook an GitHub will render it.It's build as package,then can be it's used this way. (base) G:\Anaconda3 λ git clone https://github.com/jingmin1987/variable-clustering.git Cloning into 'variable-clustering'... remote: Enumerating objects: 258, done. Receiving objects: 76% (197/258) Receiving objects: 100% (258/258), 89.70 KiB | 0 bytes/s, done. Resolving deltas: 100% (144/144), done. Checking connectivity... done. (base) G:\Anaconda3 λ cd variable-clustering\ (base) G:\Anaconda3\variable-clustering (master) λ ls README.md decomposition/ demo.ipynb (base) G:\Anaconda3\variable-clustering (master) λ python >>> from decomposition.var_clus import VarClus >>> demo1 = VarClus() >>> print(demo1.__doc__) A class that does oblique hierarchical decomposition of a feature space based on PCA. The general algorithm is 1. Conducts PCA on current feature space. If the max eigenvalue is smaller than threshold, stop decomposition 2. Calculates the first N PCA components and assign features to these components based on absolute correlation from high to low. These components are the initial centroids of these child clusters. 3. After initial assignment, the algorithm conducts an iterative assignment called Nearest Component Sorting (NCS). Basically, the centroid vectors are re-computed as the first components of the child clusters and the algorithm will re-assign each of the feature based on the same correlation rule. 4. After NCS, the algorithm tries to increase the total variance explained by the first PCA component of each child cluster by re-assigning features across clusters |