This is a test version of Biostars. For the public version, visit https://www.biostars.org.
Python error solve

Hii, I ran a script called defrag.py (https://github.com/VUmcCGP/wisecondor/blob/legacy/defrag.py) and found this error:

Traceback (most recent call last):
  File "defrag.py", line 265, in <module>
    prediction = gnb.predict[(getYPerc[testSamplesPickle[testSample]])]
TypeError: 'function' object has no attribute '__getitem__'

I changed this line numerous times but it didnt work out. I have changed the brackets because the error is due to brackets only (I guess), but I dont know how to fix it. I have already searched in google and tried but didnt get the right answer. Please help me regarding this.

python

Hi, the script seems old (circa 2014) and probably requires Python v2.x, whereas you may be using Python v3.x. Can you confirm your Python version?

Indeed, please see Requirements: https://github.com/VUmcCGP/wisecondor/tree/legacy#requirements

If needed, you could create a new miniconda environment using Python 2.7 and try the script there.

my python version is 2.7 only. I created new conda environment for running this in older version.

This is the first error before changing the parantheses:

Traceback (most recent call last):
  File "defrag.py", line 265, in <module>
    prediction = gnb.predict(getYPerc(testSamplesPickle[testSample]))
  File "/home/mdrcubuntu/anaconda3/envs/wisecondor/lib/python2.7/site-packages/sklearn/neighbors/classification.py", line 147, in predict
    X = check_array(X, accept_sparse='csr')
  File "/home/mdrcubuntu/anaconda3/envs/wisecondor/lib/python2.7/site-packages/sklearn/utils/validation.py", line 545, in check_array
    "if it contains a single sample.".format(array))
ValueError: Expected 2D array, got scalar array instead:
array=0.000588992650289.
Reshape your data either using array.reshape(-1, 1) if your data has a single feature or array.reshape(1, -1) if it contains a single sample.

I dont know how to fix it. Do you have any idea about this?

Hi, please do not add comments and information via the answer field. That messes up the logic of the thread. You can use ADD REPLY/COMMENT or the edit button to add details to your toplevel question. Thank you.

0 answers

No answers yet.

Log in to answer this question.