alok-ai-lab / pyDeepInsight

A python implementation of the DeepInsight methodology.
GNU General Public License v3.0
158 stars 47 forks source link

QhullError #12

Closed s1573838 closed 3 years ago

s1573838 commented 3 years ago

Hello,

When running the python version of DeepInsight with my own data ( 2 features), I get the following error :

scipy.spatial.qhull.QhullError: QH6214 qhull input error: not enough points(2) to construct initial simplex (need 3)

My input file has the features as columns and the samples as rows.

Thanks

kaboroevich commented 3 years ago

Can you share the entire error output?

s1573838 commented 3 years ago

Hi, Sure, here it is

chvertices = ConvexHull(x_new).vertices File "qhull.pyx", line 2431, in scipy.spatial.qhull.ConvexHull.init File "qhull.pyx", line 356, in scipy.spatial.qhull._Qhull.init scipy.spatial.qhull.QhullError: QH6214 qhull input error: not enough points(2) to construct initial simplex (need 3)

While executing: | qhull i Qt Options selected for Qhull 2019.1.r 2019/06/21: run-id 1138053338 incidence Qtriangulate _pre-merge _zero-centrum _maxoutside 0

kaboroevich commented 3 years ago

Since there was no issue running the "feature_extractor", I'm not quite sure what is happening.

What is the type() and shape (feature x samples) of the data you are providing the .fit() or .fit_transform() method?

s1573838 commented 3 years ago

My X_train (which I am providing to fit.transform()) looks like this

[[ 80.24 1. ] [ 22.7 0. ] [ 22.97 0. ] ... [143.31 3. ] [ 79.7 1. ] [ 92.36 3. ]]

While the output of the normalisation (X_train_norm) looks like this

[[0.80892741 0.12112166] [0.66479363 0. ] [0.66584126 0. ] ... [0.89276046 0.24224332] [0.80800385 0.12112166] [0.82846727 0.24224332]]

kaboroevich commented 3 years ago

And what does type(X_train) return? And is there a reason you are providing fit_transform with X_train rather than X_train_norm?

s1573838 commented 3 years ago

it returns <class 'numpy.ndarray'>

kaboroevich commented 3 years ago

Can you provide .fit_transform with X_train_norm and see if that corrects the issue? I'm wondering if it's the difference in scaling of the two features that is causing the issue.

s1573838 commented 3 years ago

I get the same error when doing so

kaboroevich commented 3 years ago

There must be something strange coming from the 'feature_extractor' method that returns x_new. What are you setting the 'feature_extractor' parameter when you initialize the ImageTransformer? If it's the default 'tsne', can you run the following code:

from sklearn.manifold import TSNE
tsne = TSNE(n_components=2, metric='cosine')
x_new = tsne.fit_transform(X_train_norm.T)

And let me know x_new looks like? This should be the value causing the issue. Could you then try:

from scipy.spatial import ConvexHull
chvertices = ConvexHull(x_new).vertices

And let me know if you get the same error? I believe you should.

kaboroevich commented 3 years ago

I realized the issue. The problem is you are using only two features, which results in only two data points after the transformation. You cannot construct a hull only from two data points.