Hi everyone,
I am trying import lib
from decomposition.base_class import BaseDecompositionClass
I 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
I don't know any module/package named decomposition. It is very general. May be sklearn.decomposition
?
This module/subpackage is a part of the package you are using. Look at the content of the
decomposition folder.
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
.
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 VarClus
Do you know how I show python where the decomposition folder is?
(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')
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