0
$\begingroup$

I'm trying to create a decision tree, and everything appeared to be going smoothly until I encountered this syntax error. I don't see what the issue is?

print ("start fitting the data")
import warnings
warnings.filterwarnings("ignore")

for cv in tqdm(range(3, 6)):
    create_grid = GridSearchCV(pipeline, param_grid=check_params, cv=cv)
    create_grid.fit(X_train.fillna(X_train.mean(), y_train.fillna(y_train.mean()))
    print("score for %d fold CV := %3.2f" %(cv, create_grid.score(X_test, y_test)))
    print ("!!!! best fit parameters from GridSearchCV !!!!")
    print (create_grid.best_params_)

print ("loop has exited")

jupyter throws the error:

  File "<ipython-input-38-6b9dca710e77>", line 8
    print("score for %d fold CV := %3.2f" %(cv, create_grid.score(X_test, y_test)))
        ^
SyntaxError: invalid syntax
$\endgroup$
0
$\begingroup$

In the second line of the for loop

create_grid.fit(X_train.fillna(X_train.mean(), y_train.fillna(y_train.mean()))

You need an extra closing parenthesis like so

create_grid.fit(X_train.fillna(X_train.mean(), y_train.fillna(y_train.mean())))

$\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.