tlawrence3 / amPEPpy

GNU General Public License v3.0
20 stars 2 forks source link

X has 630 features, but RandomForestClassifier is expecting 105 features as input #3

Open ofleitas opened 9 months ago

ofleitas commented 9 months ago

Hello

I am trying to run amPEPpy but I get an error message.

ofm@osmel-dell:~/Work/src/amPEPpy$ ampep predict -m amPEP.model -i training_data/XXXX.fasta -o XXXX.tsv --seed 2012 /home/ofm/.local/lib/python3.10/site-packages/sklearn/base.py:464: UserWarning: X does not have valid feature names, but RandomForestClassifier was fitted with feature names warnings.warn( Traceback (most recent call last): File "/home/ofm/.local/bin/ampep", line 8, in sys.exit(main()) File "/home/ofm/.local/lib/python3.10/site-packages/amPEPpy/amPEP.py", line 53, in main args.func(args) File "/home/ofm/.local/lib/python3.10/site-packages/amPEPpy/amPEP.py", line 168, in predict if clf.predict(classify_df.loc[id_info[i], :].to_numpy().reshape(1, -1))[0] == 1: File "/home/ofm/.local/lib/python3.10/site-packages/sklearn/ensemble/_forest.py", line 823, in predict proba = self.predict_proba(X) File "/home/ofm/.local/lib/python3.10/site-packages/sklearn/ensemble/_forest.py", line 865, in predict_proba X = self._validate_X_predict(X) File "/home/ofm/.local/lib/python3.10/site-packages/sklearn/ensemble/_forest.py", line 599, in _validate_X_predict X = self._validate_data(X, dtype=DTYPE, accept_sparse="csr", reset=False) File "/home/ofm/.local/lib/python3.10/site-packages/sklearn/base.py", line 625, in _validate_data self._check_n_features(X, reset=reset) File "/home/ofm/.local/lib/python3.10/site-packages/sklearn/base.py", line 414, in _check_n_features raise ValueError( ValueError: X has 630 features, but RandomForestClassifier is expecting 105 features as input.

tlawrence3 commented 9 months ago

@ofleitas I have updated the code to work with newer versions (>=1.0.0) of scikit-learn. Please download and install the newest release of amPEPpy and see if this resolves your error.

ofleitas commented 9 months ago

It worked. Thank you very much!!!