Python AttributeError: can't set attribute
0
0
Entering edit mode
2.2 years ago
Muhammad • 0

Closed. This question needs details or clarity. It is not currently accepting answers. Add details and clarify the problem you're solving. This will help others answer the question. You can edit the question or post a new one.

Closed yesterday.

(Private feedback for you)

I am trying to replicate this code from link mentioned below. When running this code I get an error= AttributeError: can't set attribute https://cimcb.github.io/MetabWorkflowTutorial/Tutorial1.html and getting this error when running

# initalise cross_val kfold (stratified) 
cv = cb.cross_val.kfold(model=cb.model.PLS_SIMPLS,                   # model; we are using the PLS_SIMPLS model
                        X=XTknn,                                 
                        Y=Ytrain,                               
                        param_dict={'n_components': [1,2,3,4,5,6]},  # The numbers of latent variables to search                
                        folds=5,                                     # folds; for the number of splits (k-fold)
                        bootnum=100)                                 # num bootstraps for the Confidence Intervals

# run the cross validation
cv.run()

Error

It pops me the following error

AttributeError                            Traceback (most recent call last)
~\AppData\Local\Temp/ipykernel_8980/4123352238.py in <module>
      8 
      9 # run the cross validation
---> 10 cv.run()

~\Anaconda3\lib\site-packages\cimcb_lite\cross_val\kfold.py in run(self)
     82     def run(self):
     83         """Runs all functions prior to plot."""
---> 84         self.calc_ypred()
     85         self.calc_stats()
     86         if self.bootnum > 1:

~\Anaconda3\lib\site-packages\cimcb_lite\cross_val\kfold.py in calc_ypred(self)
     55             model_i = self.model(**params_i)
     56             # Full
---> 57             model_i.train(self.X, self.Y)
     58             ypred_full_i = model_i.test(self.X)
     59             self.ypred_full.append(ypred_full_i)

~\Anaconda3\lib\site-packages\cimcb_lite\model\PLS_SIMPLS.py in train(self, X, Y)
     77         # Calculates and store attributes of PLS SIMPLS
     78         Xscores, Yscores, Xloadings, Yloadings, Weights, Beta = self.pls_simpls(X, Y, ncomp=self.n_component)
---> 79         self.model.x_scores_ = Xscores
     80         self.model.y_scores_ = Yscores
     81         self.model.x_loadings_ = Xloadings

AttributeError: can't set attribute
Python • 1.2k views
ADD COMMENT

Login before adding your answer.

Traffic: 2503 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6