# Practical Machine Learning

Guides in Machine Learning and Linux

I recently needed to download a folder from a shared Box drive programmatically. I also wanted some basic sync ability (only download the file from Box if the file has changed). Box has created a cli that seems to work in Windows and Mac, but guess what OS I’m using…. ;-) Anyway, even if the CLI did work, I’d still need some script to call it. So I wrote my own script to do this.

• # HDCP HDMI Capture

Introduction I’m working on integrating a Chromecast with Kodi. Basically I want Kodi and my HTPC to work as a receiver, and handle all the input switching and video sources. Everything runs through Kodi and my TV is only ever on one input. Why? Because it gives me more control. I can put Kodi menus over a Chromecast video in the background. I can turn off the TV when it’s not in use, regardless of what input it is on.

• # Installing Windows 10 in KVM + libvirt

There’s a few “tricks” that are good to know when installing Windows 10 on kvm/libvirt. This is the way I install a Windows 10 VM and I’ll try to explain each step of the process. I’ll say right away that this may look like a very long post and therefore a long process, but the length is just images and this probably takes about 30 minutes if you chug through it!

• # Windows VM Launcher

Create ~/.local/share/applications/windows.desktop with the following content: [Desktop Entry] Version=1.0 Name=Windows 10 Comment=Starts the Windows 10 VM Exec=bash -c 'virsh start Windows10 && virt-viewer --wait -c qemu:///system Windows10 && virsh shutdown Windows10' Icon=windows Type=Application Under Exec change Windows10 to whatever you’ve named your VM. After logging out and back in, you will now have Windows 10 as an “application” that you can run from your launcher (Unity or Gnome Shell or whatever it is).

• # Drawing Regular n-gons with Horizontal Bottom

We start with the unit circle centered at (0,0). The coordinates of any point on the circle are given by: \begin{align*} x &= \cos (t) \\ y &= \sin (t) \end{align*} Therefore we can find the coordinates of the regular n-gon at: \begin{align*} x &= \cos \left(k \frac{2 \pi}{n}\right) \\ y &= \sin \left(k \frac{2 \pi}{n}\right) \quad \text{where } k = 0, 1, \ldots n \end{align*}

• # Convert Mathematica Equation to Python

I recently used Mathematica to solve a Lagrangian differential equation. I wish I could have used Sage but I was unable to find a simple way to program the Euler-Lagrange equation into a function. See this bug report. Mathematica on the other hand, came with a reference notebook with the Lagrangian and E-L equations built-in. I solved the equations in Mathematica, but needed to use the resulting equations in Python code.

• # Native Looking matplotlib Plots in LaTeX

I write most of my math/numerical analysis scripts in Python, and I tend to use matplotlib for plotting. When including a matplotlib plot in LaTeX I got the highest quality results by saving the plot as a PDF and using \includegraphics{plot.pdf} in LaTeX. However, it bothered me that the plot had different fonts and font sizes than the rest of the document. Here’s how I fixed that. Figure Width I always choose the size of my plots as a percentage of the text width.

The goal of this project was to “randomly” select numbers from a predefined set, with replacement, in a way that the mean of the selected numbers would equal (or come close to) a specified number. For example, and the original motivation, was to select 100 numbers from the set: $$X = \left\{0, 0.1, 0.25, 0.5, 0.75, 0.8, 1.0\right\}$$ so that the mean of the selected numbers was \$ \approx 0.