Google Colab has some unique embedded markdown features which are not present in Jupyter markdown.
For example, this produces a slider:
#@title SEIR Model with Social Distancing { run: "auto" }
#@markdown
#@markdown Reproduction number
R0 = 2.4 #@param {type:"slider", min:0.9, max:5, step:0.1}
Attempts to run Colab locally seem to be negative: CoLab notebooks must pass through the Google CoLab website to operate.
What is the best way to produce the equivalent of the @param markup from CoLab in an open-source way that works on Jupyter in a locally run notebook without going through an external website?
I've struggled with the same problem and I solved it by using ipywidgets Jupyter Widgets documentation It is not as elegant, but works.
@interact_manual(R0 = (0.9,5.1,0.1))
def my_function(R0 = 2.4):
print("SEIR Model with Social Distancing")
print("Reproduction number")
print(R0) # do something - enter your code here
What happens is, you will get a slider with your min/max values and a step. I am using _manual - you can set multiple parameters and after you've set them the way you want, you can click on the "Run Interact" button, which calls your function (e.g. my_function).
Image: Widget in VSCode
Works with VS-Code but not PyCharm
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With