'Achieving the equivalent of Google CoLab @param markup in Jupyter without CoLab
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?
Solution 1:[1]
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).
Works with VS-Code but not PyCharm
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | Tatookie |