+3 votes
in Programming Languages by (75.9k points)

I have trained a Logistic Regression model, but when I test it on the test data using "predict_proba" function, it gives the following error:

Traceback (most recent call last):

  File "/usr/lib/python3.8/multiprocessing/pool.py", line 125, in worker

    result = (True, func(*args, **kwds))

  File "/usr/lib/python3.8/multiprocessing/pool.py", line 51, in starmapstar

    return list(itertools.starmap(args[0], args[1]))

  File "multiprocesing_predict.py", line 9, in f

    return bst.predict_proba[test_data]

TypeError: 'method' object is not subscriptable

What is wrong in the following code?

print("Split data into train test sets")

X_train, X_test, y_train, y_test = train_test_split(encoded_X, encoded_Y, test_size=0.20, random_state=42)

print("Train the model")

bst = LogisticRegression(n_jobs=nprocess, max_iter=5000).fit(X_train, y_train)

return bst.predict_proba[X_test]

1 Answer

+1 vote
by (353k points)
selected by
Best answer

You are using the predict_proba() function wrongly. You need to use () instead of []. When you use [], the function thinks you are trying to access elements at indexes 'X_test'. Hence it throws error.





Related questions