How to install Pi-Hole on my rPi

First, I should configure rPi.

This is done through download from https://www.raspberrypi.com/software/ – the software is called Raspberry Pi Imager. Selecting Raspbian, without GUI is the first step. Then, I should configure it. I should select SSH access and then set a username/pass. After that, just boot up the rPi – it should work.

ssh to the newly running rPi and install the actual Pi-Hole:
https://docs.pi-hole.net/main/basic-install/

Just select curl based install. It should work. Then, obviously, you should configure it. The pi-hole config file is /etc/pihole/pihole-FTL.conf

; Comments should start with #; to avoid issues with PHP and bash reading this file

PRIVACYLEVEL=0
MAXDBDAYS=7
DBFILE=/mnt/ext/pihole-FTL.db

Reboot and check if everything is working. You can delete the password of the web interface:

pihole -a -p

Next thing is setting the static IP. This is done on the modem – please look it up. And of course, finally, setting as DHCP filter – This is done in the app on the phone – Deco app. Cannot be done through web interface

How to do live streaming on Youtube?

Well, there are plenty of tutorials to do it directly, so I am going to focus on a case, where there are “special circumstances” – like, you want to mix external microphone and your phone, on your computer and send it to Youtube. And of course, this will be quick & dirty.

Prerequisites:

(1) YetiX (https://www.bluemic.com/en-us/products/yeti-x/)

(2) Epoccam (Pro) (https://www.elgato.com/en/epoccam)

(3) OBS (https://obsproject.com)

First, you connect your computer with your phone via Epoccam. With pro version, you can choose how to connect (USB/WiFi), otherwise it autoselects WiFi – may not be useful in scenarios, where you have weak internet around.

Then, you add new devices in OBS (your Yeti and your Epoccam) – name them and turn off every other device which can give you input.

Then, go to studio.youtube.com and create a live event, selecting that you will stream via streaming software – somewhere on the right, you will be able to share the link towards this live stream.

Finally, go to OBS, selecting all the inputs you want, and select start streaming – the menus will take you to manage streaming first, where you will select the one, that you just created.

Warning: you may have to wait for 24 hours in order for streaming facilities of Youtube become available.

What is One-Hot encoding? And why do you want to use Embeddings instead of one-hot encoding?

Whenever you have some sort of categorical data (labels), that have no particular order and/or cannot be ordered (you don’t know their order, you cannot assign greater/smaller values), but you need them to be numerical, you can devise a set of new features – basically, you create a binary set of features, that have one only when the original features has the correct value, otherwise it is set to be zero. This means, that you end up with a number of binary vectors that is equal to the number of categorical data.

A good intro is available here: https://www.educative.io/blog/one-hot-encoding

As these encodings may explode in your attribute space (imagine, for each word, for each tense, you get new feature/attribute), a technique used is “embeddings”. This technique in essence takes concepts and puts them on the axis of the n-dimensional space. Then words are put in this space, with the end-goal, that similar words are put together. Note that I used concept and similar words notions – these can be different, but the end-goal is always the same – similar words are always close-by. One can use different encodings on the axis.

An informative source is https://en.wikipedia.org/wiki/Word_embedding, while one of the better known approaches is word2vec.

Garmin & TACX – using Connect Training Plans with Tacx

Let me start with a fact, that I like Zwift – but during the cycling season, it’s kind of expensive to have a subscription. Having a Smart trainer (Tacx Flow), leaves me with a cheaper subscription to Tacx or just a basic ride (slope/power) on a rainy day.

There is also a disconnect, when you want to use Garmin Connect Training plans with your smart trainer. For example, you want to prepare for something special during the winter or, just in general, want to work according to some plan during the week and go by yourself on the weekends.

I currently have Fenix 6 smartwatch, along with Tacx Flow. There was no obvious way to transfer the training plan, which was created in Garmin Connect and transferred to Fenix 6, to Tacx. I searched the options of both apps and both websites, the internet in general, and then finally stumbled upon “the usual suspect”: https://www.dcrainmaker.com/2020/08/garmin-shows-off-smart-trainer-integration-on-fenix-6-forerunner-945.html

The above link shows how it’s done with pictures. For here, I will just say – you have to select bike indoor and then add your smart trainer. THEN you select your workout (the one from garmin connect) and off you go/bob is your uncle/you’re happy camper 😀

Enyoy!

Always forgetting Precision vs. Recall

As a constant reminder, because I keep forgetting them, I revisited this nice blog here: https://shiffdag.medium.com/what-is-accuracy-precision-and-recall-and-why-are-they-important-ebfcb5a10df2

Basically, these sentences are something that should be kept in mind:

PrecisionWhat proportion of positive identifications was actually correct? => Precision = TP/(TP+FP)

RecallWhat proportion of actual positives was identified correctly? => Recall = TP/(TP+FN)

What is accuracy? Accuracy = TP+TN/(TP+TN+FP+FN)

Basically, always construct a confusion matrix, if you can.

Working with Jupyter notebooks in VSCode

Well, there are some nuances, when selecting this way of working. First thing first – www.jupyter.org – the main website of these notebooks. Don’t forget to read what they enable, how they operate. In a nutshell – well documented code, that can be nicely presented etc.

The prerequisites are:

  • Installed VSCode
  • Installed Conda environment with which you run your notebook

First, you will have to install all extensions in VSCode that enable you to view, operate jupyter notebooks. Don’t worry, VSCode will offer you some, select the ones that are trusted, i.e., from Microsoft.

So, you are able to load the notebook. Next step is to select the right conda environment for them to be run in. You can select it on the right (next figure) – I selected dlwp. You can also use the old trick with Cmd+Shift+P.

If something is amiss, you will be notified once each cell is run. For me, I had to install ipykernel in the dlwp environment.

conda install -n dlwp ipykernel --update-deps --force-reinstall

conda install -c conda-forge ipywidgets

How to install huggingface libraries

When you want to play with Natural Language Processing (NLP), you want Transformers – developed by Huggingface. Currently, this is SOTA and is used also outside NLP field (with great success).

So, you have created your conda environment and you installed pytorch libraries in it. Now, it is time to install transformers – a library.

First, the terminal install is described here. For brewity:

conda install -c huggingface transformers

Side note: -c means channel, so this command will install transformers, from the channel huggingface.

And when (not IF, but WHEN) you will get into trouble (like you will be missing datasets:

pip install datasets

How to install Py-torch in your new conda environment

First, change to the environment you want. For me, it is conda activate dlwp

Then, install the basic pytorch:

conda install pytorch torchvision -c pytorch

The recipe is given here: https://pytorch.org/get-started/locally/

Sidenote: if you’re working on ARM (i.e., M1, M2 Mac), you use msp instead of cuda or cpu devices.

Currently (October 2022), mps is supported only in nightly builds of the pytorch.

conda install pytorch torchvision -c pytorch-nightly

Conda environment

You may think of Conda as the venv in Python – coarsely speaking, offers the same functionality. It is useful for creating virtual environments, which can be used with Python – a special set of libraries, etc.

You can get it here: https://docs.conda.io/en/latest/miniconda.html

How to initialize Conda

Assuming you have downloaded Conda and you are in fresh terminal, you can create your first environment. I will call it dlwp, as I am working with this environment.

conda create -n dlwp

conda activate dlwp

conda deactivate

How to make Conda play nice with VS Code

In VSCode (assuming all Python extensions are installed), you install Python Environment Manager, an extension that allows to view and organise virtual environments for Python. How do you access it? CMD+Shift+P then select environment you want. You can set it as default for your workspace too.

Simple 😀

And of course, how to list all the environments

conda env list

not so private notes to self