Hi, I am new to JupyterNotebook and Tabpy. I am trying to do a ML using the wine dataset. I am following the heart disease prediction example (https://github.com/OrysyaStus/TableauTutorials/blob/c280905df8739c005479b66b23f22a2569cc7940/TabPy_Python_Integration/README.md. I trying to do a scoring function using the random forest classifier (which I have run earlier). However, I got this error. How to solve this so I can deploy the model in Tableau. Any advice for this?
This is a Python issue. In other words, if you were running this in Python on your own machine locally, you’d have the same issue. Jupyter discourse is meant for discussing issues specific to Jupyter. Understandably it is harder for newcomers to decipher how all the pieces fit together. But you can think of Jupyter as a development environment that connects to Python, or whatever underlying kernel you are using. For example, running R in Jupyter is an option.
With that said…
in this case it simply looks like you aren’t defining your function
WinePrediction correctly. It’s hard to be 100% sure because you cut off the right side of the function defining line. However, it shows that line not ending in a colon as it should, and I don’t see indentation in the lines that come after. Jupyter would indent if it had seen the colon when you were writing the code. If you went back and edited it though, Jupyter may not pick it up. In other words, you’d need to indent the lines that are part of the function yourself. In Python, whitespace matters.
Functions should look like, at minimum:
def myfunction (argument_one, argument_two): print("this is all I do")
A docstring is always best to include between the initial defining line and the first actual line of code. Documenting as you go will help yourself six months from now.
About not cutting off code:
For getting help in the appropriate place, those place will also want you to share the code in code form and not a picture. (In some cases the code and a picture of what happens may be needed, but usually just a picture isn’t going to cut it.) The problem with a picture is very much highlighted by your function assignment line.
You can use Github’s gist service or other snippet sharing sites to share the entire notebook like you seemed to have wanted to do here.
If you are just sharing a little code, you can use markdown-fomatted code blocks. I used that to add the
myfunction example. Guidance for Discourse posts is here. Most of those approaches work in other forums that accept markdown-formatted text.
You want to help people help you if you are asking help.