EBjerrum / Deep-Chemometrics

Using deep learning approaches and convolutional neural networks (CNN) for spectroscopical data (deep chemometrics)
71 stars 18 forks source link

Unable to read the dataset #1

Closed bappa10085 closed 2 years ago

bappa10085 commented 4 years ago

When I am trying to read the dataset I am getting the following error


AttributeError Traceback (most recent call last)

in () 29 30 filename = 'nir_shootout_2002.mat' ---> 31 dataset = get_xY(filename) in get_xY(filename, maxx) 11 for key in list(keys): 12 if key[0] == '_': ---> 13 keys.remove(key) 14 15 keys.sort() AttributeError: 'dict_keys' object has no attribute 'remove' Please help how to get rid of this error.
EBjerrum commented 3 years ago

Sorry, didn't see the comment before now. Did you manage to solve the issue?

kandpal123 commented 2 years ago

Still, this problem is getting while running the above code. Please can you solve it,

EBjerrum commented 2 years ago

Cast the keys 'dict_keys' object into a list like this: keys = list(matcontents.keys()), then it should work I think. Let me know the results.

kandpal123 commented 2 years ago

Now, while I am importing this module "from ChemUtils import GlobalStandardScaler"

I am getting the error "ModuleNotFoundError: No module named 'ChemUtils''.

kandpal123 commented 2 years ago

Thank you very much, now all code section has been running.

bappa10085 commented 2 years ago

I was out of station so could not check the codes. When I was trying to run Deep_Chemometrics_EMSC_only.py, it returns me

AttributeError Traceback (most recent call last) ~\AppData\Local\Temp/ipykernel_13928/2335297676.py in 6 emsc.fit(X_train) 7 ----> 8 X_train_emsc = emsc.transform(Xtrain) 9 = plt.plot(dataset['axisscale'],X_train_emsc.T) F:\Python\Deep-Chemometrics-master\ChemUtils.py in transform(self, X, y, copy) 154 corr = scipy.zeros(X.shape) 155 for i in range(len(X)): --> 156 b,f,r = self.mlr(self._mx, X[i,:][:,nA]) 157 corr[i,:] = scipy.reshape((r/b[0,0]) + self._mx, (corr.shape[1],)) 158 return corr F:\Python\Deep-Chemometrics-master\ChemUtils.py in mlr(self, x, y) 132 133 #calc fit b=fit coefficients --> 134 b = scipy.dot(scipy.dot(scipy.linalg.pinv(scipy.dot(scipy.transpose(X),X)),scipy.transpose(X)),y) 135 f = scipy.dot(X,b) 136 r = y - f AttributeError: module 'scipy' has no attribute 'linalg'

How can I solve this issue? I think it is better to replace/correct the old codes in this repository.

EBjerrum commented 2 years ago

The problems come from your installation of the dependencies. They have evolved and there has been API changes and new ways of doing things in e.g. Python 3, e.g. dict.keys() returning a special object rather than a simple list, and possible now that scipy has a new organization so that linalg module may be another place? You'll need to figure out where in scipy the pinv function now is, and update the code to fix the changed dependencies. Alternatively run it in python 2 with old versions of the dependencies, but as I didn't specify the versions, that would be hard to track down. I unfortunately don't have time to update the code which was provided 5 years ago as an example, but pull requests are welcome if you get it sorted out.