How to Get Epup to Read Mode
Writing Math Equations in Jupyter Notebook: A Naive Introduction
Without a doubt, documentation is an essential part of working in Information Science projects. If your work involves reading up latest research or coming up with new algorithms to solve issues, and so it is especially important and useful.
However, the latter kind of work often involves writing Math equations in digital form. Except for people familiar with LaTeX, this is frequently an unfamiliar territory.
In this post I'll evidence you, with examples, how to write equations in Jupyter notebook's markdown. I accept selected these equations such that they cover the most recurring types of symbols and notations which yous might run into (at least I do). I also give links to useful resources I refer to. And then, there are many bonuses along the fashion :)
Markdown Mode in Jupyter
Very very quickly, this is how you can switch to markdown mode in Jupyter.
- Select a cell in command style. If you come across a cursor in the cell and tin can write, and then it'due south in edit mode. Press escape primal to go to command way. Usually, the colour of the thick edge on the left of selected jail cell is green when in edit mode and blue/grey in command mode.
- Switch to markdown mode:
- Pick i: Become to Prison cell => Cell Type => Markdown
- Option two: Change manner from driblet down as shown in the images beneath. On the right prototype, you lot can run across I am currently in Code style (checked) and Markdown mode is highlighted, which you can click for switching to Markdown mode.
- Option three: Select a cell in command fashion and press M for markdown. BONUS 1 : press Y for switching dorsum to code mode.
After switching to Markdown mode, nosotros will edit the jail cell to write equations.
Writing Your Outset Equation in Jupyter Notebook
Now, you will be writing equation of a linear model. What is a linear model you inquire? This,
BONUS two : A model is linear, if the relationship between dependent variable (Y) and independent variables (Ten) is linear in parameters (betas). The hat on betas simply mean that they are values estimated from data (and we hope that they are close to true values).
What are the symbols we demand to write?
- Chapeau: \lid
- Subscript: _{}
- Sum: \sum
- Limits of sum: \limits _{} ^{}
- Beta: \beta
The weird looking thing confronting each name is the markdown syntax to write hat, subscript, sum, limits and beta in the equation of linear model. Note that remainder of the things are only alphabets and numbers viz. Y, 0, j, 1, p, and X, which need no special syntax apart from, at times, being enclosed within {}.
Using these building blocks, the consummate syntax for linear model can be written as,
When you run the cell with markdown syntax, shown the paradigm in a higher place, you will go the equation of the linear model. Y'all can double click on the cell to edit the markdown syntax. Remember that the prison cell has to be in markdown mode.
Explanation of the syntax
$ : All the Math you desire to write in the markdown should be within opening and closing $ symbol in lodge to be processed as Math. \beta : Creates the symbol beta \hat{} : A hat is covered over anything inside the curly braces of \hat{}. E.g. in \hat{Y} chapeau is created over Y and in \hat{\beta}_{0}, hat is shown over beta _{} : Creates as subscript, anything inside the curly braces after _. E.m. \lid{\beta}_{0} volition create beta with a hat and give information technology a subscript of 0. ^{} : (Similar to subscript) Creates as superscript, annihilation inside the curly braces after ^. \sum : Creates the summation symbol \limits _{} ^{} : Creates lower and upper limit for the \sum using the subscript and superscript notation.
BONUS 3 : You tin enclose the Math within ii $$ likewise. The difference is inline mode vs display style. "Inline style is for math that is included within a line or paragraph of text, and display style is for math that is fix apart from the chief text." — https://tex.stackexchange.com/questions/410863/what-are-the-differences-betwixt-and
Congratulations, if you have followed the mail and reached this far. You take successfully written your first non-petty Math equation on Jupyter's markdown.
And then far, and then skilful. Merely this is no time to stop. Lets notch up the stride a fleck.
Gradient Tree Boosting Algorithm
Let's write all the Math for Gradient Tree Boosting Algorithm!
Accept a deep jiff but you need not worry! But take a glance at the Gradient Tree Boosting Algorithm higher up and you will find you lot already know how to write subscript, sum with its limits, Math in brandish mode (BONUS 3 above) and hat. These symbols along with plain text is literally about of the algorithm!
So what's new?
*** : Creates horizontal line   : Creates infinite. (Ref: Space in 'markdown' cell of Jupyter Notebook) \gamma : Creates gamma symbol \displaystyle : Forces display mode (BONUS 3 in a higher place). (Ref: Brandish style in Math mode) \frac{}{} : Creates fraction with ii curly braces from numerator and denominator. <br> : Creates line breaks \Bigg : Helps create parenthesis of big sizes. (Ref: Brackets and Parentheses) \fractional : Creates partial derivatives symbol \underset() : To write under a text. E.1000. gamma under arg min, instead of a subscript. In the algorithm y'all'll see both types. \in : Creates belongs to symbol which is heavily used in set theory.
Some text formatting options like \text — to write plainly text with spaces, \mathbf — to write Math in boldface, \textrm — to write text in roman font. These formatting options are things you will figure out with searches over Google when you want to make things look a certain mode. So no need to bother too much about them.
Plenty talk, lets see the entire syntax at present!
Gradient Tree Boosting Markdown Syntax for Jupyter
But instead of writing all of that yourself, you may prefer to…
Won't you?
Here is the Markdown syntax in plain text:
***
$\mathbf{\text{Slope Tree Boosting Algorithm}}$<br>
***
i. Initialize model with a constant value $$f_{0}(x) = \textrm{arg min}_{\gamma} \sum \limits _{i=ane} ^{N} 50(y_{i}, \gamma)$$
two. For m = one to M:<br>
  (a) For $i = 1,2,...,N$ compute<br>
$$r_{im} = - \displaystyle \Bigg[\frac{\partial Fifty(y_{i}, f(x_{i}))}{\partial f(x_{i})}\Bigg]_{f=f_{m−i}}$$
  (b) Fit a regression tree to the targets $r_{im}$ giving terminal regions<br>
    $R_{jm}, j = 1, ii, . . . , J_{k}.$<br><br>
  (c) For $j = i, ii, . . . , J_{m}$ compute<br>
$$\gamma_{jm} = \underset{\gamma}{\textrm{arg min}} \sum \limits _{x_{i} \in R_{jm}} L(y_{i}, f_{one thousand−1}(x_{i}) + \gamma)$$
<br>
  (d) Update $f_{g}(x) = f_{m−ane}(x) + \sum _{j=1} ^{J_{1000}} \gamma_{jm} I(ten \in R_{jm})$<br><br>
3. Output $\hat{f}(x) = f_{M}(10)$
***
WOW! That was a lot of stuff y'all went through! Claps claps claps …
BONUS 4: Quick and Criminally Short Explanation of Slope Tree Boosting Algorithm
Gradient Tree Boosting Algorithm combines Decision Copse in an additive and sequential manner to incrementally make improve predictions on grooming data.
It starts with an initial abiding value of prediction for all data points (which is mean value in case of regression).
In every subsequent iteration, information technology fits a tree to negative of gradient of loss with respect to predictions of model learned so far (which in regression case turns out to be error i.e. actual-predicted value).
This new tree is then combined with the previous copse to get updated predictions for each data betoken.
You end the algorithm at a preset number of iterations.
PS: This is a very very generic caption diluting a lot of of import details.
BONUS 5: Variance Covariance Matrix in Markdown
You lot've got to write this down yourself :D
References
- Using Markdown in Jupyter Notebook
- LaTeX Symbols
- The Comprehensive LaTeX Symbol List (it'due south a PDF file)
- Overleaf: Integrals, Sums and Limits
- Overleaf: Line Breaks and Bare Spaces
- Overleaf: Brackets and Parentheses
- Spacing in Math Mode (\; — a thick infinite, \: — a medium infinite, \, — a thin space, \! — a negative sparse space)
- https://www.math.ubc.ca/~pwalls/math-python/jupyter/latex/
- List of Mathematical Symbols by Subject
- Is at that place a fashion to command the font size of MathJax equations?
- Gradient Boosting
- GIPHY
- tenor
- How to Get Started with Data Scientific discipline (plug)
- Personalizing Swiggy Pop Recommendations (plug — my work at Swiggy)
Source: https://medium.com/analytics-vidhya/writing-math-equations-in-jupyter-notebook-a-naive-introduction-a5ce87b9a214
0 Response to "How to Get Epup to Read Mode"
Post a Comment