Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
decomposition library
#1
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
Reply
#2
I don't know any module/package named decomposition. It is very general. May be sklearn.decomposition?
Reply
#3
I am getting it from this link below:

https://github.com/jingmin1987/variable-...ar_clus.py

Do you think he is creating the module himself?

Thanks
Reply
#4
This module/subpackage is a part of the package you are using. Look at the content of the decomposition folder.
Reply
#5
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-...e_class.py
Reply
#6
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.
Reply
#7
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?
Reply
#8
(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')
Reply
#9
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
 
Reply


Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020