0
$\begingroup$

I'm trying to making predictions with a simple model.

model=LogisticRegression()
model.fit(X_train,y_train)

After fitting, i try to make predictions. A sample X_test value and the code is below.

X_train[41626]

array([-0.53668182,  0.57287544, -1.48834257, -0.6080626 , -0.86691148,
    0.24336571,  0.        ,  0.53303864, -0.05081621,  0.17409271,
   -0.21513622, -1.15424615,  0.74731522,  1.47161341])

The model fits in like 5 seconds. After below code is executed, when it gets to %5 or %6 it stops for a long time (the last stop point was 39938/326232). Sometimes kernel dies, sometimes it just stops. It stops at random row btw.

test['Predicted'] = test.progress_apply(lambda x: model.predict(X_train) ,axis=1)

I have updated all python libraries and try this code on both a windows and mac m1 machine. The result is the same.

What is the problem? I cant figure it out.

$\endgroup$
1
  • $\begingroup$ Full traceback, full model please $\endgroup$
    – Peter
    Nov 11, 2021 at 12:23

1 Answer 1

0
$\begingroup$

Try this:

test['Predicted'] = test.apply(lambda x: model.predict(x.values.reshape(-1, len(test.columns))), axis=1)
$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.