week 39, 2019

Introduction to Principal Component Analysis (PCA)

In Machine Learning, we need features for the algorithm to figure out patterns that help differentiate classes of data. More the number of features, more the variance (variation in data) and hence model finds it easy to make ‘splits’ or ‘boundaries’. But not all features provide useful information. They can have noise too. If our model starts fitting to this random noise, it would lose its robustness. So here’s the deal — We want to compose m features from the available feature space that give us maximum variance. Note that we want to compose and not just select m features as it is.

Source: Introduction to Principal Component Analysis (PCA) — with Python code, an article by Dhruvil Karani.

Finding the version of lxml installed

In the evening, when working on RSS support for the Python version of tumblelog, I wanted to know which version of lxml I had installed via apt-get earlier on. It turned out that the easiest way was to use dpkg -l python-lxml which reported version 4.3.3-1.

Learn Git Branching

Interested in learning Git? Well you've come to the right place! "Learn Git Branching" is the most visual and interactive way to learn Git on the web; you'll be challenged with exciting levels, given step-by-step demonstrations of powerful features, and maybe even have a bit of fun along the way.

In the evening I checked out Learn Git Branching. It looks very well made.

Serving JSON

Today, after working on improving the JSON feed for this blog I tried to validate it using the JSON Feed Validator expecting no errors. Instead I got:

Error: Content-Type was application/octet-stream. It should be application/json.

JSON Feed Validator showing Content-Type issue
JSON Feed Validator showing the Content-Type issue.

Since I use NGINX to host this site on a virtual private server (VPS) I SSHed into the VPS and added the following line to mime.types:

    application/json       json;
JSON Feed Validator success
JSON Feed Validator successfully validated the JSON feed.

After restarting the web server the feed could be validated without any issues.

The Last Astronaut

Sally Jansen was NASA's leading astronaut, until a mission to Mars ended in disaster. Haunted by her failure, she lives in quiet anonymity, convinced her days in space are over.

She's wrong.

In the evening I started in The Last Astronaut by David Wellington.

Tmux Tutorial

In this short tutorial, I am going through some of the basic concepts and commands for Tmux, and how to use a Tmux plugin, which is called Tmux Resurrect, to restore Tmux environment after reboot or Tmux server restart.

Source: Tmux Tutorial, by Lei Mao.

See also Hacker News for a discussion of this short tutorial and additional tips.

How to use the journalctl Linux command

If you've used any modern Linux distribution, chances are good you have become familiar with systemd. You might have also happened upon a systemd issue when an app or service refuses to start. When that's the case, you might have found yourself in a situation where you're not quite sure how to begin troubleshooting.

Fortunately for every Linux admin, there's a built-in tool to help you with that. Said tool is journalctl. Journalctl is the utility used for querying the systemd logging utility, journald. With the help of journald and journalctl, you can begin the process of troubleshooting why a service is refusing to start. Journald also tracks logs to a specific boot. With this mechanism, you can compare system boots to see when a service was working properly versus when it wasn't.

Source: How to use the journalctl Linux command, an article by Jack Wallen.

An advanced look at Python interfaces using zope.interface

In order to make those things explicit, you need a way to express expected interfaces. One of the first big systems written in Python was the Zope web framework, and it needed those things desperately to make it obvious what rendering code, for example, expected from a "user-like object."

Enter zope.interface, which is developed by Zope but published as a separate Python package. Zope.interface helps declare what interfaces exist, which objects provide them, and how to query for that information.

An advanced look at Python interfaces using zope.interface, an article by Moshe Zadka.

Better Box Shadows

Box shadow on HTML elements has been widely supported across most browsers for a while now, but I find the default options don’t allow for much visual manipulation of the shadows in general.

Source: Better Box Shadows