LaTeX Horizontal Flowchart (Workflow)

Source: https://tex.stackexchange.com/questions/368482/one-horizontal-line-flow-chart?rq=1

Just found an excellent source on how to draw a simple (slightly fanciful) horizontal flowchart using LaTeX (TikZ).

The output is very neat:

The code is reproduced here (in case the original source gets deleted):

\documentclass[tikz, margin=3mm]{standalone}
\usetikzlibrary{arrows.meta,
                chains,
                positioning,
                shapes.geometric
                }
% for fancy looks of data storages
\begin{document}
    \begin{tikzpicture}[
    node distance = 5mm and 7mm,
      start chain = going right,
 disc/.style = {shape=cylinder, draw, shape aspect=0.3,
                shape border rotate=90,
                text width=17mm, align=center, font=\linespread{0.8}\selectfont},
  mdl/.style = {shape=ellipse, aspect=2.2, draw},
  alg/.style = {draw, align=center, font=\linespread{0.8}\selectfont}
                    ]
    \begin{scope}[every node/.append style={on chain, join=by -Stealth}]
\node (n1) [disc] {Training\\ data};
\node (n2) [alg]  {Learning\\ algorithm};
\node (n3) [mdl]  {Model};
\node (n4) [disc] {Test\\ data};
\node (n3) [mdl]  {Accuracy};
    \end{scope}
\node[below=of n2]  {Step 1: Training};
\node[below=of n4]  {Step 2: Tresting};
    \end{tikzpicture}
\end{document}

Multiline Flow Chart

For flowcharts that exceed one line (and hence require a line break), the following Tikz code is very helpful! (Source: https://tex.stackexchange.com/questions/149602/drawing-flow-diagram-in-latex-using-tikz)

\documentclass[border=10pt]{standalone}
\usepackage{tikz}
\usetikzlibrary{arrows,positioning,shapes.geometric}
\begin{document}
    \begin{tikzpicture}[>=latex']
        \tikzset{block/.style= {draw, rectangle, align=center,minimum width=2cm,minimum height=1cm},
        rblock/.style={draw, shape=rectangle,rounded corners=1.5em,align=center,minimum width=2cm,minimum height=1cm},
        input/.style={ % requires library shapes.geometric
        draw,
        trapezium,
        trapezium left angle=60,
        trapezium right angle=120,
        minimum width=2cm,
        align=center,
        minimum height=1cm
    },
        }
        \node [rblock]  (start) {Start};
        \node [block, right =2cm of start] (acquire) {Acquire Image};
        \node [block, right =2cm of acquire] (rgb2gray) {RGB to Gray};
        \node [block, right =2cm of rgb2gray] (otsu) {Localized OTSU \\ Thresholding};
        \node [block, below right =2cm and -0.5cm of start] (gchannel) {Subtract the \\ Green Channel};
        \node [block, right =2cm of gchannel] (closing) {Morphological \\ Closing};
        \node [block, right =2cm of closing] (NN) {Sign Detection \\ Using NN};
        \node [input, right =2cm of NN] (limit) {Speed \\ Limit};
        \node [coordinate, below right =1cm and 1cm of otsu] (right) {};  %% Coordinate on right and middle
        \node [coordinate,above left =1cm and 1cm of gchannel] (left) {};  %% Coordinate on left and middle

%% paths
        \path[draw,->] (start) edge (acquire)
                    (acquire) edge (rgb2gray)
                    (rgb2gray) edge (otsu)
                    (otsu.east) -| (right) -- (left) |- (gchannel)
                    (gchannel) edge (closing)
                    (closing) edge (NN)
                    (NN) edge (limit)
                    ;
    \end{tikzpicture}
\end{document}

Output:

Amazing method to unblock stuffy nose

Out of all the methods I checked on YouTube, this method seems to be the most effective in terms of instantly unblocking your nose.

Basically pinch your nose and sway, until you are almost out of breath, then breath in through your nose. I find it very effective.

This method is very good also: Nasal Septum Mobilization invented by Dr Alan Mandell. It is quite a novel method, so far I have only seen it on his YouTube channel and not anywhere else. I think it may work for people with Deviated Septum as a natural remedy. Basically, the way it works is by moving the septum so as to create a “motion” to unblock the nose.

Cai Yun Zhui Yue Piano Sheet Music (PDF)

This is a classical piano tune that is masterfully transcribed (by arranger Wang Jianzhong 王建中). In English, it is also called “Colourful Clouds Chasing the Moon”. In Chinese, it is called 彩云追月.

The transcription is really very nice, the harmony and the melody of the original tune is preserved and even enhanced. Few piano scores for Chinese music can achieve this effect.

The sheet music (or piano score) is originally from http://www.everyonepiano.com, we simply convert to PDF for the convenience of those who are seeking it:

PDF Sheet Music Score for Cai Yun Zhui Yue: Cai Yun Zhui Yue PDF

I checked that this version is the same as the one performed by Li Yundi:

Taiwan Aquarium Fish Tour

There are many blogs focusing on Taiwan tourism, this blog focuses on the aspect of fish you can see/eat in Taiwan.

Koi at Chiang Kai-Shek Memorial Hall

If you visit the Chiang Kai-Shek memorial hall in Taipei, do check out the pond just nearby. There are many koi in the pond, and also a vending machine with fish food for sale (around NT$10 for a tube of fish food). There are various colors of koi, ranging from dull gray to colorful red, white or gold colors.

Marimo Moss Ball Exhibition at National Taiwan Museum

The National Taiwan Museum is not as famous as the other museum, National Palace Museum (aka Gu Gong), but nonetheless it holds some interesting specimens related to Taiwan. When I went there, there was a small Marimo Moss ball exhibition. The Marimo Moss ball were of exceptional high quality (better than any moss ball I saw in Singapore). They were dark green, dense, and almost perfectly spherical.

Water Lettuce Bowl with Guppy

Very healthy looking Water Lettuce specimens in a large porcelain bowl. The leaves were almost perfect, with no holes. There is also a female guppy (camouflaged in the second picture), together with guppy fry living in the bowl. This was seen on Shifen Old Street towards the waterfall.

Koi Pond en route to Shifen Waterfall

On the way to the famous waterfall at Shifen, there is yet another Koi pond with the option to purchase fish food (this time at NT$20). Interestingly, I did spot fishes in the river adjoining the waterfall, but it is quite hard to photograph them due to their color (dull black) and the distance. I wonder what happens if they fall down the waterfall.

Aquarium Shops in Taipei

The most famous aquarium street in Taipei is the one at Section 5, Minquan East Road. Unfortunately, it is not very accessible via train. Despite sounding similar, the Minquan West Road Metro station is very far from Minquan East Road.

I went to a nearby aquarium in Shilin district instead. To my surprise, there was an alligator snapping turtle in the aquarium (together with various interesting species of aquatic tortoises). Just beside the aquarium was a local Taiwanese restaurant popular with locals, with free flow rice and ice-cream. In the restaurant, there are a few live fish and crabs for eating, and there was a moray eel inside!

One thing to note is that Cod Fish (Snow Fish or Xue Yu) is quite cheap in Taiwan, in the restaurant one slab of Cod Fish the size of my hand is just NT$180 or SGD$8. In Singapore, the price is at least double or triple that.

pip install keeps installing old/outdated packages

This article is suitable for solving the following few problems:

  1. module ‘sklearn.tree’ has no attribute ‘plot_tree’
  2. pip install (on Spyder, Anaconda Prompt, etc.) does not install the latest package.

The leading reason for “module ‘sklearn.tree’ has no attribute ‘plot_tree” is because the sklearn package is outdated.

Sometimes “pip install scikit-learn” simply does not update the sklearn package to the latest version. Type “print(sklearn.__version__)” to get the version of sklearn on your machine, it should be at least 0.21.

The solution is to force pip to install the latest package:

pip install --no-cache-dir --upgrade <package>

In this case, we would replace <package>  by “scikit-learn”.


Sometimes, pip install does not work in the Spyder IPython console, it displays an error to the effect that you should install “outside the IPython console”. This is not normal (i.e. it should not happen), but as a quick fix you can try “pip install” in Anaconda Prompt instead. It is likely that something wrong went on during the installation of Anaconda, Python, and the long-term solution is to reinstall Anaconda.

caret package in R: known issue when converting factor variables

In the R language, often you have to convert variables to “factor” or “categorical”. There is a known issue in the ‘caret’ library that may cause errors when you do that in a certain way.

The correct way to convert variables to ‘factor’ is:

trainset$Churn = as.factor(trainset$Churn)

In particular, “the train() function in caret does not handle factor variables well” when you convert to factors using other methods.
(See https://rpubs.com/SulmanKhan/444033)

Basically, if you use other ways to convert to ‘factor’, the code may still run, but there may be some ‘weird’ issues that leads to inaccurate predictions (for instance if you are doing logistic regression, decision trees, etc.)

Saving Rasbora from Dropsy

Recently, my mosquito rasbora (Boraras merah) was acting weirdly by hiding in a corner and sleeping more than usual.

Upon closer examination, I found “specks” on it. At first I thought it was velvet. However, this was an old tank and there has not been any introduced fish for more than 2 months. Then I realized it was probably dropsy and the specks were actually pineconing of the scales, which looks like specks of dust because of the smallness of the scales (this mosquito rasbora is one of the smallest fish in the freshwater aquarium, measuring less than 2 cm when fully grown). In conclusion, I think dropsy in tiny fish can probably look like velvet.

I think the reason is that the dwarf hairgrass (and Japanese hairgrass) planted in the sand substrate has failed to grow, and in fact has started to die and rot, releasing ammonia, nitrites and/or nitrates into the water. I do have a Seachem Ammonia Alert badge that did not show any readings.

Hence, I suspect it is probably nitrates. I added Methylene blue (full dose) after 50% water change, and then continued 50% water change on the second day, topping up the Methylene blue (half dose). On the third day, another 50% water change. (For all days during the water change, I removed the rotting hairgrass as well as any pond snails pests that I find, and wiped off algae).

After the third day, the mosquito rasbora began to behave normally again, swimming around and schooling together with the lambchop rasbora. I hope it will survive.

The lambchop rasbora seem unaffected and seem more hardy than the mosquito rasbora. I think the mosquito rasbora may be more sensitive to water parameters.

Mosquito Rasbora in (diluted) Methylene Blue water.

Philips Stainless Steel Pressure Cooker

The keyword here is “stainless steel”, because if you look at many pressure cookers, the inner pot is made of aluminum alloy. The bad thing about aluminum is that it is linked to Alzheimer’s disease. For instance, this medical paper states that “Immediate steps should be taken to lessen human exposure to Al (aluminum), which may be the single most aggravating and avoidable factor related to AD (Alzheimer’s disease).”

Philips makes one of the best brands of pressure cookers, including the famous HD2137 model which is sold in Singapore. It can be bought almost anywhere, including the Philips Qoo10 official store:

[S$147.00](▼64%)[PHILIPS]PHILIPS HD2137/62 Viva Collection All-in-One Cooker | HD2139/62 Pressure Cooker

WWW.QOO10.SG

The default Philips pressure cooker, however, comes with aluminum inner pot, no matter which model. Fortunately, there is a solution, which is to buy the Stainless Steel Inner Pot from the official Philips website.

Highly recommended to upgrade to this stainless steel inner pot.

The stainless steel inner pot is suitable for the following models: HD2137, HD2237, HD2178, HD2145. It is quite pricey at $59 (Singapore dollars), but I think it is worth it considering that it should last for a lifetime or at least a long time.

Interestingly, Philips sells these pressure cooker models mainly to Asian market. I don’t find them in the American Amazon.com website. Perhaps the American diet (steak, burgers, fries) don’t really require the pressure cooker? I am not sure.


Do check out some of the amazing recipes possible using the Philips Pressure Cooker with Stainless Steel Inner pot:

How to save sklearn tree plot as file (Vector Graphics)

The Scikit-Learn (sklearn) Python package has a nice function sklearn.tree.plot_tree to plot (decision) trees. The documentation is found here.

However, the default plot just by using the command

tree.plot_tree(clf)

could be low resolution if you try to save it from a IDE like Spyder.

The solution is to first import matplotlib.pyplot:

import matplotlib.pyplot as plt

Then, the following code will allow you to save the sklearn tree as .eps (or you could change the format accordingly):

plt.figure()
tree.plot_tree(clf,filled=True)  
plt.savefig('tree.eps',format='eps',bbox_inches = "tight")

To elaborate, clf is your Decision Tree classifier (to be defined before plotting the tree):

# Example from https://scikit-learn.org/stable/modules/generated/sklearn.tree.plot_tree.html
clf = tree.DecisionTreeClassifier(random_state=0)
clf = clf.fit(iris.data, iris.target)

The outcome is a Vector Graphics format (.eps) tree that will retain its full resolution when zoomed in. The bbox_inches=”tight” command prevents truncating of the image. Without that command, sometimes the sklearn tree will just be cropped off and be incomplete.

In the northern darkness there is a fish and his name is K’un.

Just realized that there is some parallel between the Chinese Giant Fish Kun (鲲) and the Jewish Giant Fish Leviathan.

Similarly, Chinese Giant Bird Peng (鹏) = Jewish Giant Bird Ziz.

In the northern darkness there is a fish and his name is K’un. The K’un is so huge I don’t know how many thousand li he measures. He changes and becomes a bird whose name is P’eng. The back of the P’eng measures I don’t know how many thousand li across and, when he rises up and flies off, his wings are like clouds all over the sky. When the sea begins to move, this bird sets off for the southern darkness, which is the Lake of Heaven.

Source: https://en.wikipedia.org/wiki/Peng_(mythology)

As Leviathan is the king of fishes, so the Ziz is appointed to rule over the birds. His name comes from the variety of tastes his flesh has; it tastes like this, zeh, and like that, zeh. The Ziz is as monstrous of size as Leviathan himself. His ankles rest on the earth, and his head reaches to the very sky.

Source: https://en.wikipedia.org/wiki/Ziz

Clockwise from left: Behemoth (on earth), Ziz (in sky), and Leviathan (under sea). From Wikipedia.
Cool picture of Giant Fish Kun from Baidu.