Click here to Skip to main content
15,892,537 members
Please Sign up or sign in to vote.
1.11/5 (2 votes)
See more:
#Using train test split
# Although I have already split the data still I will use this function to show that my calculation was correct and to generate that extra y_test variable

x_train,x_test,y_train,y_test=train_test_split[train_df,test_df,test_size=0.33,random_state=17]
split_check=DecisionTreeClassifier(max_leaf_nodes=10,random_state=0)
split_check.fit(x_train,y_train)
y_predict=split_check.predict(x_test)
accuracy_score((y_test,y_predictions)*100)



Output:
File "<ipython-input-55-5d8c72e50bfb>", line 3
    x_train,x_test,y_train,y_test=train_test_split[train_df,test_df,test_size=0.33,random_state=17]
                                                                             ^
SyntaxError: invalid syntax


What I have tried:

I tried changing the test size but it is of no use.
Posted
Updated 21-Aug-19 19:46pm
Comments
[no name] 22-Aug-19 1:47am    
Instead of changing the test size, Just replace the square brackets with parenthesis,That'll solve the error.

1 solution

Try using this instead of the above code.
Changing the square brackets to parenthesis would solve your problem, if you are query is about the syntactical error.

Python
x_train,x_test,y_train,y_test=train_test_split(train_df,test_df,test_size=0.33,random_state=17)


Thanks and Hope this helped you out.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900