<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>tech on Tom Roth</title><link>https://tomroth.dev/categories/tech/</link><description>Recent content in tech on Tom Roth</description><generator>Hugo -- gohugo.io</generator><language>en</language><lastBuildDate>Thu, 16 Feb 2023 00:00:00 +0000</lastBuildDate><atom:link href="https://tomroth.dev/categories/tech/index.xml" rel="self" type="application/rss+xml"/><item><title>Building a computational graph: part 3</title><link>https://tomroth.dev/compgraph3/</link><pubDate>Thu, 16 Feb 2023 00:00:00 +0000</pubDate><guid>https://tomroth.dev/compgraph3/</guid><description>This is the third part of a series on creating a computational graph in Python. You can go back to part one and part two.
There&amp;rsquo;s a bit of code in this post. Here is the final code in np_wrapping.py. The module for numpy_autograd is here.
In the last post we created computational graphs for a function, but it was a bit hard to use. We also had these problems:</description></item><item><title>Building a computational graph: part 2</title><link>https://tomroth.dev/compgraph2/</link><pubDate>Wed, 15 Feb 2023 00:00:00 +0000</pubDate><guid>https://tomroth.dev/compgraph2/</guid><description>This is the second post in a series on computational graphs. You can go back to the previous post or ahead to the next post.
If you&amp;rsquo;d like to see what we are working towards in these posts, here is the Github link:
Last time we
looked at computational graphs and their use in autodiff packages. looked at the autodiff problem and the structure of the grad function in autograd showed how Python breaks down expressions to create computational graphs created a simple graph manually using a simplified Node class How do we automatically create a computational graph for a function?</description></item><item><title>Building a computational graph: part 1</title><link>https://tomroth.dev/compgraph1/</link><pubDate>Tue, 14 Feb 2023 00:00:00 +0000</pubDate><guid>https://tomroth.dev/compgraph1/</guid><description>This is the first post in a series on computational graphs. You can go to the next post or skip ahead to the third post.
If you&amp;rsquo;d like to see what we are working towards in these posts, here is the Github link:
Computation graphs have many uses. Here I&amp;rsquo;ll be presenting it as they used for autodifferentiation.
For this post, I&amp;rsquo;ll assume you have some familiarity with backpropagation and autodifferentiation (also known as autodiff).</description></item><item><title>How does weight-tying work in a RNN?</title><link>https://tomroth.dev/weight_tying/</link><pubDate>Fri, 07 Oct 2022 00:00:00 +0000</pubDate><guid>https://tomroth.dev/weight_tying/</guid><description>Weight-tying is where you have a language model and use the same weight matrix for the input-to-embedding layer (the input embedding) and the hidden-to-softmax layer (the output embedding). The idea is that these two matrices contain essentially the same information, each having a row per word in the vocabulary. The concept seems to be first mentioned by Press and Wolf in 2016.
Below we illustrate this with a RNN. This post assumes that you are somewhat familiar already with how a RNN works.</description></item><item><title>A simple CNN with Pytorch</title><link>https://tomroth.dev/pytorch-cnn/</link><pubDate>Wed, 14 Apr 2021 00:00:00 +0000</pubDate><guid>https://tomroth.dev/pytorch-cnn/</guid><description>Find the code for this blog post here: https://github.com/puzzler10/simple_pytorch_cnn
We will build a classifier on CIFAR10 to predict the class of each image, using PyTorch along the way.
This is basically following along with the official Pytorch tutorial except I add rough notes to explain things as I go. There were a lot of things I didn&amp;rsquo;t find straightforward, so hopefully this piece can help someone else out there. If you&amp;rsquo;re reading this, I recommend having both this article and the Pytorch tutorial open.</description></item><item><title>On invariance adversarial attacks</title><link>https://tomroth.dev/invariance/</link><pubDate>Fri, 06 Mar 2020 00:00:00 +0000</pubDate><guid>https://tomroth.dev/invariance/</guid><description>Sensitivity-based adversarial attacks Link to heading Neural networks are vulnerable to adversarial attack, and there&amp;rsquo;s a lot of talk about this. There are many definitions of an adversarial attack, but let&amp;rsquo;s go with this one: an input to a model designed to produce an incorrect output. Models can run on many different types of data (text, audio, tabular) but let’s use images as a working example.
The most well-known kind of adversarial attack is to add some kind of perturbation to an image to make a classifier mislabel it.</description></item><item><title>Notes on DeepFool</title><link>https://tomroth.dev/deepfool/</link><pubDate>Thu, 27 Feb 2020 00:00:00 +0000</pubDate><guid>https://tomroth.dev/deepfool/</guid><description>Paper: Deepfool: a simple and accurate method to fool deep neural networks. (Moosavi-Dezfooli et al, 2016).
Idea: If you want to find an adversarial example to an image, look for the closest decision boundary, and then move the image towards a linear approximation of the decision boundary by orthogonally projecting it onto the boundary. Once it crosses the boundary it will be an adversarial image.
Background Link to heading Affine functions.</description></item><item><title>Exploding and vanishing gradients</title><link>https://tomroth.dev/exploding_vanishing_gradients/</link><pubDate>Wed, 19 Feb 2020 00:00:00 +0000</pubDate><guid>https://tomroth.dev/exploding_vanishing_gradients/</guid><description>The following code explores how gradients explode or vanish when backpropagating through a neural network. It depends on the type of activation function you are using and how many layers you have in the network.
Observations for some activation functions:
sigmoid tends to lead to vanishing gradient sometimes with relu you get a lot of zeros in the gradient. I didn&amp;rsquo;t see any vanishing gradient with relu, but there was exploding gradient.</description></item><item><title>Python decorators and examples</title><link>https://tomroth.dev/decorators/</link><pubDate>Tue, 11 Feb 2020 00:00:00 +0000</pubDate><guid>https://tomroth.dev/decorators/</guid><description>Decorators without arguments Link to heading Decorators modify functions. They can also modify classes, but they&amp;rsquo;re mainly used with functions.
Decorators are just a way to simplify syntax. Here&amp;rsquo;s an example of a decorator at work.
@some_decorator def add(x,y): return x + y This is the same thing as
def add(x,y): return x + y add = some_decorator(add) Without the decorator, we&amp;rsquo;d call some_decorator on add and assign the answer back to add.</description></item><item><title>Bypassing ten adversarial detection methods (Carlini and Wagner, 2017)</title><link>https://tomroth.dev/ten-failed-detectors/</link><pubDate>Mon, 20 Jan 2020 00:00:00 +0000</pubDate><guid>https://tomroth.dev/ten-failed-detectors/</guid><description>Some rough notes of this paper.
Paper link: Adversarial examples are not easily detected: Bypassing ten detection methods. (Carlini and Wagner, 2017)
In brief: Adversarial defences are often flimsy. The authors are able to bypass ten detection methods for adversarial examples. They do so with both black-box and white-box attacks. The C&amp;amp;W attack is the main attack used. The most promising defence evaluated the classification uncertanity of each image through generating randomised models.</description></item><item><title>Measuring the Intrinsic Dimension of Objective Landscapes (2018) - summary</title><link>https://tomroth.dev/intdim/</link><pubDate>Tue, 07 Jan 2020 00:00:00 +0000</pubDate><guid>https://tomroth.dev/intdim/</guid><description>The paper in one sentence. The Pareto principle for neural networks: what’s the least number of parameters needed for to achieve most of the results?
Structure of this article. I give an introduction to objective landscapes and talk about how to define solutions. I use these concepts to describe the subspace training method. Finally, I summarise the key results of the paper.
Objective landscapes Link to heading For every combination of neural network architecture and dataset, the shape of the objective/loss function is fixed.</description></item><item><title>Backprop and topological sorting</title><link>https://tomroth.dev/backprop-toposort/</link><pubDate>Sun, 01 Dec 2019 00:00:00 +0000</pubDate><guid>https://tomroth.dev/backprop-toposort/</guid><description>Neural networks need to update their weights with respect to a loss function. Rather than compute these weight updates manually, today we usually use automatic differentiation packages and tools. We call these autodiff systems.
To do their job, autodiff systems construct computational graphs of the function they’re trying to find the gradient of. These computational graphs are key to backpropagation. I won’t go into how these graphs are constructed here.</description></item><item><title>Some things about responsive images</title><link>https://tomroth.dev/responsive-images/</link><pubDate>Fri, 22 Nov 2019 00:00:00 +0000</pubDate><guid>https://tomroth.dev/responsive-images/</guid><description>Let’s start by introducing some of the HTML/CSS you’ll find when dealing with images.
The &amp;lt;img&amp;gt; tag: The most common and probably easiest option for displaying an image. It’s a tag you’ve probably seen before.
Use the src attribute to link to the image you’d like to show. But you can also use srcset and sizes to specify responsive images. More on that later.
&amp;lt;img srcset=&amp;#34;elva-fairy-320w.jpg 320w, elva-fairy-480w.jpg 480w, elva-fairy-800w.jpg 800w&amp;#34; sizes=&amp;#34;(max-width: 320px) 280px, (max-width: 480px) 440px, 800px&amp;#34; src=&amp;#34;elva-fairy-800w.</description></item><item><title>A primer on progressive enhancement</title><link>https://tomroth.dev/progressive-enhancement/</link><pubDate>Sat, 16 Nov 2019 00:00:00 +0000</pubDate><guid>https://tomroth.dev/progressive-enhancement/</guid><description>When you build a website, it should work everywhere.
Websites should work with new browsers, but also with old browsers. They should work for users using speech-navigation software, and for those with slow mobile connections. Websites should also work for agents who don’t use them visually, like a web crawler.
You&amp;rsquo;d love to show your awesome website properly to every user. Unfortunately, in real life that&amp;rsquo;s often not possible. So go for second best: provide some core functionality to everyone, and then give the enhancements to the browsers that can handle it.</description></item><item><title>Playing a sound file with React and Webpack</title><link>https://tomroth.dev/react-sound/</link><pubDate>Mon, 04 Nov 2019 00:00:00 +0000</pubDate><guid>https://tomroth.dev/react-sound/</guid><description>One Link to heading Get the sound file you want (e.g. sound.mp3) and put it somewhere in your src directory.
Two Link to heading Add this to your webpack.config.js file. Make sure you have file-loader installed (run npm install --save-dev file-loader if you don’t.)
{ test: /\.mp3$/, loader: &amp;#39;file-loader&amp;#39;, query: { name: &amp;#39;static/media/[name].[hash:8].[ext]&amp;#39; } } Three Link to heading Import the file at the top of your JavaScript file. Put the path relative to the JavaScript file you are loading the sound from.</description></item><item><title>Data Valuation using Reinforcement Learning (dvrl)</title><link>https://tomroth.dev/dvrl/</link><pubDate>Thu, 17 Oct 2019 00:00:00 +0000</pubDate><guid>https://tomroth.dev/dvrl/</guid><description>Data Valuation using Reinforcement Learning Link to heading Paper link: https://arxiv.org/pdf/1909.11671.pdf
At a glance Link to heading Machine learning models use data for training. But not all data points are equally valuable.
A data point can be low-quality for a variety of reasons, such as incorrect labelling, noisy input, being too common, or it’s not from the same distribution as the test set. Whatever the case, removing bad datapoints tends to increase model performance.</description></item><item><title>Understanding the Device Pixel Ratio</title><link>https://tomroth.dev/dpr/</link><pubDate>Fri, 27 Sep 2019 00:00:00 +0000</pubDate><guid>https://tomroth.dev/dpr/</guid><description>From the fundamentals Link to heading The viewport of a device is the size of the screen area. This doesn’t include the space the browser window takes up with its menu, bookmarks etc.
Different devices have different viewport sizes. Laptops and monitors have larger viewports than smartphones do.
A website will display on the viewport of the device. This is where HTML and CSS code is displayed.
Web developers use CSS to style and position elements.</description></item><item><title>How do CSS pixels work?</title><link>https://tomroth.dev/css-pixels/</link><pubDate>Tue, 17 Sep 2019 00:00:00 +0000</pubDate><guid>https://tomroth.dev/css-pixels/</guid><description>Let’s start off with px and pt Link to heading You’ve probably seen the units px and pt before in CSS. If you didn’t know, px stands for pixel unit and pt stands for point.
The units px and pt are related. 1px is always equal to 0.75pt, just like how 1 inch is always equal to 2.54 cm.
Also, 1pt is equal to 1/72nd of 1 inch, meaning that 1px ends up about 0.</description></item><item><title>AlphaD3M now has grammar, baby</title><link>https://tomroth.dev/alphad3m-grammar/</link><pubDate>Thu, 27 Jun 2019 00:00:00 +0000</pubDate><guid>https://tomroth.dev/alphad3m-grammar/</guid><description>There&amp;rsquo;s this lovely little paper called Automatic Machine Learning by Pipeline Synthesis using Model-Based Reinforcement Learning and a Grammar. It&amp;rsquo;s by Drori et al (ICML workshop 2019), and here&amp;rsquo;s the paper link: https://arxiv.org/pdf/1905.10345.pdf
But, what is AlphaD3M? Don&amp;rsquo;t know? Read this summary before continuing, brave adventurer.
I won&amp;rsquo;t give you an overview of this paper here (but the title kind of already does).
So, what&amp;rsquo;s interesting about it? The takeaways? Give it to me nice and straight, you cry, and don&amp;rsquo;t you dare waste words on frivolous sentences.</description></item><item><title>What even is AlphaD3M</title><link>https://tomroth.dev/alphad3m/</link><pubDate>Sun, 23 Jun 2019 00:00:00 +0000</pubDate><guid>https://tomroth.dev/alphad3m/</guid><description>Heard about AlphaD3M? Want to know what it is?
You&amp;rsquo;re in luck!
Overview Link to heading What is AlphaD3M? It&amp;rsquo;s an AutoML system. It was first shown at the ICML 2018 AutoML Workshop.
For a given dataset, and a given task, AlphaD3M builds a machine learning pipeline. Confused? Here&amp;rsquo;s an example of how this could work.
Dataset: Iris
Task: Multiclass classification of the species column
Metric: Log loss
Pipeline:
Create new column: | e.</description></item><item><title>Seq2Sql: paper notes</title><link>https://tomroth.dev/seq2sql/</link><pubDate>Thu, 20 Jun 2019 00:00:00 +0000</pubDate><guid>https://tomroth.dev/seq2sql/</guid><description>Seq2SQL: Generating structured queries from Natural Language using Reinforcement Learning (2017) Link to heading Paper link: https://arxiv.org/pdf/1709.00103.pdf Authors: Victor Zhong, Caiming Xiong, Richard Socher
Here&amp;rsquo;s my notes from this paper.
Seq2SQL uses the Seq2Seq model as a starting point
The output of the seq2seq model is unnecessarily wide for SQL queries. In other words, the paper is only interested in a small subset of the seq2seq output space. As a result, the output of Seq2SQL is limited to the union of words in the question, SQL commands and table headers The paper created its own datasets.</description></item><item><title>How to enable Beta features for Google Speech-to-Text with Python</title><link>https://tomroth.dev/speech-beta/</link><pubDate>Sun, 26 May 2019 00:00:00 +0000</pubDate><guid>https://tomroth.dev/speech-beta/</guid><description>It&amp;rsquo;s a straightforward two-step process.
One: make sure you have version 1.0.0 or later of google-cloud-speech (use !pip freeze | grep google-cloud-speech)
Two: Instead of importing the client libraries like
from google.cloud import speech from google.cloud.speech import enums, types import them like
from google.cloud import speech_v1p1beta1 as speech, storage from google.cloud.speech_v1p1beta1 import enums, types The beta features should now be available for you to use.</description></item><item><title>Change your plot theme for plotly or plotly_express</title><link>https://tomroth.dev/plotly-theme/</link><pubDate>Thu, 18 Apr 2019 00:00:00 +0000</pubDate><guid>https://tomroth.dev/plotly-theme/</guid><description>I made a scatter plot with plotly_express.
It didn&amp;rsquo;t look good. So I wondered how to change the theme.
It took me way too long to figure out.
First I looked through the documentation here. I didn&amp;rsquo;t seem to see any relevant source code. Instead was a bunch of stuff about creating a new theme. Not useful.
Finally I found code like fig.layout.template = 'plotly_dark' buried in an image. Turns out that&amp;rsquo;s how you do it.</description></item><item><title>Aginity tip: using code snippets</title><link>https://tomroth.dev/aginity-snippets/</link><pubDate>Sat, 23 Mar 2019 00:00:00 +0000</pubDate><guid>https://tomroth.dev/aginity-snippets/</guid><description>The Aginity code snippets function is a good time-saver. To use code snippets, type in some combination of letters and hit Alt-C. Those letters then expand into a SQL statement.
By default you have
sf (select * from &amp;lt;blank&amp;gt; limit 1000), and sfw (select * from &amp;lt;blank&amp;gt; where &amp;lt;blank&amp;gt; limit = 1000). But you can add your own, which is where they really shine. Use them for things you type again and again.</description></item><item><title>Somehow extracting summary statistics of tables quickly using SQL</title><link>https://tomroth.dev/sql-stats/</link><pubDate>Sat, 26 Jan 2019 00:00:00 +0000</pubDate><guid>https://tomroth.dev/sql-stats/</guid><description>I worked with a large table, with a thousand numeric columns, and some of them were dodgy and I wanted to know which. It would help to find basic summary statistics, like the min, max and mean of each column, so let&amp;rsquo;s do that now.
What to do? Link to heading I really didn&amp;rsquo;t want to do this:
select min(c1), max(c1), mean(c1), min(c2), max(c2), mean(c2), min(c3) -- and so on for 1000 columns from xyz The alternate idea: write SQL, that generates SQL!</description></item><item><title>Install Docker on a Google Cloud virtual machine</title><link>https://tomroth.dev/gcp-docker/</link><pubDate>Tue, 27 Nov 2018 00:00:00 +0000</pubDate><guid>https://tomroth.dev/gcp-docker/</guid><description>I set up a new virtual machine using the Google Cloud Platform and wanted to install Docker. Although I couldn&amp;rsquo;t get the official instructions to work, I found this tutorial for installing Docker using Debian 9, which worked since GCP virtual machines use Debian as their Linux distribution.
Here&amp;rsquo;s how to do it.
Start up a new virtual machine using GCP. Then ssh into the box (with gcloud compute ssh xxxx or something similar) and copy paste this into the terminal prompt</description></item><item><title>Let's build a DQN: neural network architectures</title><link>https://tomroth.dev/dqn-nnet/</link><pubDate>Thu, 01 Nov 2018 00:00:00 +0000</pubDate><guid>https://tomroth.dev/dqn-nnet/</guid><description>After building the basic DQN, I started trying some different neural network architectures. I found vastly different results between them.
Spoiler: more complex doesn&amp;rsquo;t equal better. Almost the opposite.
Here are some results for the rewards obtained in each episode. I trained these models on cartpole-v1. Each was trained for 1000 episodes.
Disclaimer: I did only one run with each architectures. I kept other hyperparameters the same as the previous post, but there are likely some interaction effects unaccounted for.</description></item><item><title>Let's build a DQN: simple implementation</title><link>https://tomroth.dev/dqn-simple/</link><pubDate>Wed, 31 Oct 2018 00:00:00 +0000</pubDate><guid>https://tomroth.dev/dqn-simple/</guid><description>Click the image above to see the source code.
Last time, we established some theory for our DQN. Now it’s time to implement it.
We won’t build a full DQN from the DeepMind paper, not yet. Instead we’ll build a simplified version. I call it the basic DQN.
The basic DQN is the same as the full DQN, but missing a target network and reward clipping. We’ll get to that in the next post.</description></item><item><title>Let's build a DQN: basics</title><link>https://tomroth.dev/dqn-basics/</link><pubDate>Tue, 23 Oct 2018 00:00:00 +0000</pubDate><guid>https://tomroth.dev/dqn-basics/</guid><description>In February 2015, Google Brain published a paper combining deep neural networks and reinforcement learning for the first time - called DQN (deep q-network). It was a landmark moment.
DQN was the first algorithm that could successfully play a wide range of Atari games. Other algorithms at the time could perform well at a single game but couldn’t generalise across games. Impressively, DQN was able to perform above human level at a range of Atari games using only the screen pixels as input.</description></item><item><title>How to play the OpenAI Gym environments yourself</title><link>https://tomroth.dev/gym-play/</link><pubDate>Sat, 13 Oct 2018 00:00:00 +0000</pubDate><guid>https://tomroth.dev/gym-play/</guid><description>Ever wanted to play the games that your reinforcement agents are learning?
OpenAI have a keyboard agent to let you try out the gym environments yourself. Here&amp;rsquo;s how to set it up.
First, if you haven&amp;rsquo;t already, install the gym package with pip install gym, or by following the instructions here.
Then:
Go to this link. Click &amp;ldquo;raw&amp;rdquo;. Copy the text and save it to a file called keyboard_agent.py Open up a shell prompt and navigate to where you saved the file.</description></item><item><title>Sarsa, expected sarsa and Q-learning on the OpenAI taxi environment</title><link>https://tomroth.dev/sarsa-qlearning/</link><pubDate>Mon, 08 Oct 2018 00:00:00 +0000</pubDate><guid>https://tomroth.dev/sarsa-qlearning/</guid><description>In this post, we&amp;rsquo;ll see how three commonly-used reinforcement algorithms - sarsa, expected sarsa and q-learning - stack up on the OpenAI Gym Taxi (v2) environment.
Note: this post assumes that the reader is familiar with basic RL concepts. A good resource for learning these is the textbook by Sutton and Barto (2018), which is freely available online.
Sarsa, Expected Sarsa and Q-Learning Link to heading So, what are these algorithms?</description></item><item><title>Six tips for effective learning</title><link>https://tomroth.dev/effective-learning/</link><pubDate>Sun, 22 Jul 2018 00:00:00 +0000</pubDate><guid>https://tomroth.dev/effective-learning/</guid><description>Want to squeeze the most out of each hour studying? Want to make your learning time as efficient as possible?
The first thing is to use good study methods. They will give you the biggest opportunities for improvement.
The second thing is to read this article. Here are six ways to get the most from your learning time.
1.Alternate between focused and diffuse thinking Link to heading Trying to solve a problem?</description></item><item><title>Exploring policy evaluation in reinforcement learning</title><link>https://tomroth.dev/policy-eval/</link><pubDate>Sun, 27 May 2018 00:00:00 +0000</pubDate><guid>https://tomroth.dev/policy-eval/</guid><description>Today, we explore policy evaluation. We&amp;rsquo;ll explain it by example.
Given a policy, policy evaluation aims to find the value of each state $ v_\pi (s) $. That&amp;rsquo;s what we&amp;rsquo;ll be doing with the equiprobable random policy.
The scenario Link to heading Taken from the textbook &amp;ldquo;An Introduction to Reinforcement Learning&amp;rdquo; (Sutton and Barto), Gridworld is the following scenario.
There is a grid with sixteen squares. The top left and the bottom right square are terminal squares.</description></item><item><title>The Keras functional API: five simple examples</title><link>https://tomroth.dev/keras/</link><pubDate>Mon, 06 Nov 2017 00:00:00 +0000</pubDate><guid>https://tomroth.dev/keras/</guid><description>Building models in Keras is straightforward and easy. If you&amp;rsquo;re reading this, you&amp;rsquo;re likely familiar with the Sequential model and stacking layers together to form simple models. But what if you want to do something more complicated?
Enter the functional API. For complex models the functional API is really the only way to go - it can do all sorts of things that just aren&amp;rsquo;t possible with the Sequential model. Models with multiple inputs and outputs, models with shared layers - once you start designing architectures that need these things, you will have to use the functional API to build your model.</description></item><item><title>Building a nearest neighbour classifier in Python</title><link>https://tomroth.dev/nearest-neighbour/</link><pubDate>Sat, 26 Aug 2017 00:00:00 +0000</pubDate><guid>https://tomroth.dev/nearest-neighbour/</guid><description>The nearest neighbour classifier is a very simple algorithm for image classification. While not used much in practice, it is simple to implement and it helps to gain a deeper understanding of the problems in image classification.
Just like other classifiers, if we give the nearest neighbour classifier an image, it&amp;rsquo;ll try and find its closest match. We &amp;ldquo;train&amp;rdquo; the classifier by giving it a large collection of images that it allowed to search through to find matches.</description></item><item><title>A quick overview of Seaborn</title><link>https://tomroth.dev/seaborn/</link><pubDate>Mon, 17 Jul 2017 00:00:00 +0000</pubDate><guid>https://tomroth.dev/seaborn/</guid><description>Seaborn. A wrapper on top of matplotlib. Used to make plots, and to make them quicker, easier, and more beautiful.
Thank you for your service, matplotlib. Despite your flaws, you&amp;rsquo;ve guided us this far.
But it&amp;rsquo;s time to step aside.
Types of Seaborn plots Link to heading sns.boxplot() | generic boxplot sns.distplot() | histogram and kernel density estimate (KDE) plotted together sns.distplot(rug=True) | rugplot sns.kdeplot() | kernel density estimate plot sns.</description></item><item><title>How to install packages through Pip into a Conda environment</title><link>https://tomroth.dev/pip-conda/</link><pubDate>Fri, 14 Jul 2017 00:00:00 +0000</pubDate><guid>https://tomroth.dev/pip-conda/</guid><description>Seemingly ubiquitous in the Python world, the distribution Anaconda comes with over 200 Python packages installed. Anaconda also comes with a package manager called conda.
Besides its utility for installing and managing packages, conda also possesses the ability to create virtual environments which make sharing and reproducing analyses much easier. These virtual environments are created without any Python packages preloaded into them.
Installing Python packages into the virtual environment is often straightforward.</description></item><item><title>Pandas functions. Lots of them.</title><link>https://tomroth.dev/pandas/</link><pubDate>Fri, 14 Jul 2017 00:00:00 +0000</pubDate><guid>https://tomroth.dev/pandas/</guid><description>Pandas is your best friend for your data needs. It is the king of data manipulation in the Python empire.
Any data scientist intending to use Python as their tool of choice must master Pandas. It is compulsory, like learning to walk before you run.
So here is a quick reference list of functions, just for you.
But reading written material is no substitute for repeated practice. And hence, you should not expect to remember the functions below.</description></item><item><title>44 Numpy Functions</title><link>https://tomroth.dev/numpy/</link><pubDate>Sun, 25 Jun 2017 00:00:00 +0000</pubDate><guid>https://tomroth.dev/numpy/</guid><description>Have you heard about the Python package numpy? Probably.
But maybe you&amp;rsquo;re looking for an easy reference of useful numpy functions. Maybe that&amp;rsquo;s why you&amp;rsquo;re here. Well, you&amp;rsquo;re in luck!
Get started by opening up a editor. First, we&amp;rsquo;ll import the numpy package: import numpy as np.
Now cast your eye over these functions. In no particular order:
np.__version__ | Return the version of numpy you have loaded. np.shape(x) | return the shape of an array x.</description></item><item><title>Simulating the multi-armed bandit problem</title><link>https://tomroth.dev/bandit/</link><pubDate>Wed, 24 May 2017 00:00:00 +0000</pubDate><guid>https://tomroth.dev/bandit/</guid><description>Machine learning can be split up into many subfields. One of these subfields growing in relevance is reinforcement learning.
One of the core problems in reinforcement learning is the multi-armed bandit problem. This problem has been well studied and is commonly used to explore the tradeoff between exploration and exploitation integral to reinforcement learning.
To illustrate this tradeoff and to visualise different ways of solving the multi-armed bandit problem, I created a simulation using the JavaScript library d3.</description></item><item><title>Force directed graphs: testing ground</title><link>https://tomroth.dev/fdg-testing/</link><pubDate>Mon, 22 May 2017 00:00:00 +0000</pubDate><guid>https://tomroth.dev/fdg-testing/</guid><description>I&amp;rsquo;ve written a decent amount of material about force directed graphs. This included posts for each of the forces that the d3-force module comes shipped with.
I found that when I read about these forces, text-based explanations never really solidified the concepts for me. To really get a sense of how the forces worked, I had to build lots of force graphs and tweak the parameters manually to see what each of them did.</description></item><item><title>Understanding Kadane’s solution to the maximum subarray problem</title><link>https://tomroth.dev/kadane/</link><pubDate>Tue, 09 May 2017 00:00:00 +0000</pubDate><guid>https://tomroth.dev/kadane/</guid><description>There is something called the maximum subarray problem, and it goes something like this.
You are given an array of numbers: something like 3,5,-2,-1,5,3,1,-4,-6,5. Your job is to come up with the subarray with the highest sum.
For this example it would be the subarray [3,5,-2,-1,5,3,1], which has a sum of 14. No other subarray gives a higher sum.
Let&amp;rsquo;s look at a few more:
The sequence -3,-3,-2,-4,-2,-5,-4 has the highest sum being -2, given by the subarray [-2].</description></item><item><title>Mean, median, or mode? When to use each of them.</title><link>https://tomroth.dev/median/</link><pubDate>Wed, 03 May 2017 00:00:00 +0000</pubDate><guid>https://tomroth.dev/median/</guid><description>Pretend you wish to get an idea of the average value of your dataset. You&amp;rsquo;ve got a few choices available to you, of which the most common three are the mean, median and mode.
You might argue that the mode is a better choice than the median and the mean, mostly based on the below graphic.
But the mode suffers from other problems. It will fail you on an exponential distribution, or on a log distribution.</description></item><item><title>Force directed graph: zoomable</title><link>https://tomroth.dev/fdg-zoom/</link><pubDate>Thu, 20 Apr 2017 00:00:00 +0000</pubDate><guid>https://tomroth.dev/fdg-zoom/</guid><description>This example builds off the d3-zoom articles to add zoom functionality onto our force directed graph. If you&amp;rsquo;ve got questions on how zoom works or what this code is really doing, check those articles out!
Once you know what&amp;rsquo;s going on, adding zoom to force directed graph is really simple.
Most of the code in the above example (click on the picture to see it) I&amp;rsquo;ve covered in other articles, so I won&amp;rsquo;t go over it again.</description></item><item><title>How to combine drag and zoom in d3 version 4</title><link>https://tomroth.dev/drag-zoom/</link><pubDate>Tue, 18 Apr 2017 00:00:00 +0000</pubDate><guid>https://tomroth.dev/drag-zoom/</guid><description>Combining drag and zoom should be an easy task, and it is. But only if you do it right.
In this article I&amp;rsquo;ll present two ways to apply drag and zoom to your d3 visualisations. One way is easy and simple, and one way is complicated and difficult, and yet both examples hold key insights.
The easy way Link to heading Mike Bostock has written a simple example where he combines drag and zoom.</description></item><item><title>Integrating Javascript and d3 into R notebooks</title><link>https://tomroth.dev/r-d3/</link><pubDate>Thu, 13 Apr 2017 00:00:00 +0000</pubDate><guid>https://tomroth.dev/r-d3/</guid><description>Recently the team over at RStudio released R Notebooks.
R Notebooks are really interesting. Here&amp;rsquo;s why:
You can write code in several different languages in one document (including python, bash, dot, ruby, javascript, sql) You can write in Markdown You can write in HTML You can see your code as it runs Writing reproducible code is easier It&amp;rsquo;s easy to share code results with others It&amp;rsquo;s the intertwining of languages bit that interests me the most.</description></item><item><title>Zoom in d3 version 4: selective zooming</title><link>https://tomroth.dev/zoom-selective/</link><pubDate>Fri, 07 Apr 2017 00:00:00 +0000</pubDate><guid>https://tomroth.dev/zoom-selective/</guid><description>Not everything has to enable zoom. You can selectively pick and choose which objects you&amp;rsquo;d like to enable zoom on.
Consider this tale of two circles.
We create two circles which we call circle1 and circle2. Circle1 is the circle on the left and circle2 is the circle on the right.
Here&amp;rsquo;s the interesting bit. We define our zoom handler and set what happens when a zoom action is detected.</description></item><item><title>Zoom in d3 version 4: minimal example</title><link>https://tomroth.dev/zoom-minimal/</link><pubDate>Mon, 03 Apr 2017 00:00:00 +0000</pubDate><guid>https://tomroth.dev/zoom-minimal/</guid><description>In this post we&amp;rsquo;ll make a minimal example to demonstrate how zoom works.
I&amp;rsquo;ll use a similar setup to this other example that was used to demonstrate drag - create circles on the screen at random and then see if we can zoom in on them.
Nice and simple.
Setup Link to heading First we&amp;rsquo;ll set up a simple scaffold for the example:
&amp;lt;!DOCTYPE html&amp;gt; &amp;lt;meta charset=&amp;#34;utf-8&amp;#34;&amp;gt; &amp;lt;svg width=&amp;#34;960&amp;#34; height=&amp;#34;600&amp;#34;&amp;gt;&amp;lt;/svg&amp;gt; &amp;lt;script src=&amp;#34;https://d3js.</description></item><item><title>Zoom in d3 version 4: understanding SVG transforms</title><link>https://tomroth.dev/zoom-svg/</link><pubDate>Wed, 29 Mar 2017 00:00:00 +0000</pubDate><guid>https://tomroth.dev/zoom-svg/</guid><description>Zooming in d3 version 4 isn&amp;rsquo;t straightforward to pick up. Far from it.
Just like force graphs, zoom in d3 has been separated into its own module. Understanding the API documents can be a little&amp;hellip;confusing.
Things start to make more sense once you realise that zoom is intricately linked to SVG transforms, and that zooming and panning can just be thought of as changing the transforms on SVG elements.
So step one to understand zooming is to understand how the SVG transform works.</description></item><item><title>Force directed graph: popping</title><link>https://tomroth.dev/fdg-popping/</link><pubDate>Sat, 18 Mar 2017 00:00:00 +0000</pubDate><guid>https://tomroth.dev/fdg-popping/</guid><description>This graph exploits the unstable effects of setting the forceCollide strength parameter outside of [0,1].
//High strength value causes unstable effects var collide_force = d3.forceCollide(radius) .strength(10); The result is a kind of &amp;ldquo;popping effect&amp;rdquo; as the nodes violently push each other away.
Here&amp;rsquo;s another example.
This graph takes out the link force, sets the strength parameter for forceCollide to an unstable value, and implements an attractive force between particles.</description></item><item><title>Force directed graph: bounding box</title><link>https://tomroth.dev/fdg-bounding-box/</link><pubDate>Fri, 17 Mar 2017 00:00:00 +0000</pubDate><guid>https://tomroth.dev/fdg-bounding-box/</guid><description>In this example we&amp;rsquo;ll keep the force directed graph constrained inside a box. The nodes won&amp;rsquo;t be able to go outside.
The basic gist of it is that you impose a constraint that takes effect on every tick of the simulation. You can either put this code inside the tick function, or you can define a custom force to do the work for you.
Let&amp;rsquo;s go through both methods.
Method 1: use the tick function Link to heading The first method is to put the constraints inside the tick function.</description></item><item><title>Force directed graph: custom forces</title><link>https://tomroth.dev/fdg-custom/</link><pubDate>Fri, 17 Mar 2017 00:00:00 +0000</pubDate><guid>https://tomroth.dev/fdg-custom/</guid><description>There’s two types of forces in the d3-force module – preshipped forces and custom forces.
Preshipped forces have already been written for you. Custom forces you write yourself.
Here we&amp;rsquo;ll cover custom forces.
What is a custom force? Link to heading A custom force is simply a function that modifies the positions and velocities of nodes. See the d3 API.
You write custom forces to achieve effects that aren&amp;rsquo;t possible by using the preshipped forces.</description></item><item><title>Force directed graph: growing and shrinking nodes</title><link>https://tomroth.dev/fdg-grow/</link><pubDate>Fri, 17 Mar 2017 00:00:00 +0000</pubDate><guid>https://tomroth.dev/fdg-grow/</guid><description>This example was written as a demonstration of custom forces with d3&amp;rsquo;s force directed graph.
The custom forces change the size of the nodes over time. The blue &amp;ldquo;male&amp;rdquo; nodes gradually grow larger and the pink &amp;ldquo;female&amp;rdquo; nodes gradually grow smaller.
Implementing the custom force is simple. On each tick of the simulation, we loop through every node and check to see if its sex attribute is M or F.</description></item><item><title>Force directed graph: splitting nodes</title><link>https://tomroth.dev/fdg-split/</link><pubDate>Fri, 17 Mar 2017 00:00:00 +0000</pubDate><guid>https://tomroth.dev/fdg-split/</guid><description>This is a somewhat silly example of adding custom forces to a forceSimulation. All of the blue male nodes are pulled to the right side and all the pink female nodes are pulled to the left side.
There&amp;rsquo;s also a bounding box effect to stop the nodes receding into the void.
The custom force splitting_force() causes this effect. What&amp;rsquo;s a custom force? Click here for a refresher.
// bring all male nodes to right side, all female nodes to left side function splitting_force() { for (var i = 0, n = nodes_data.</description></item><item><title>Force directed graph: drifting</title><link>https://tomroth.dev/fdg-drifting/</link><pubDate>Thu, 16 Mar 2017 00:00:00 +0000</pubDate><guid>https://tomroth.dev/fdg-drifting/</guid><description>This force graph drifts while the simulation is running.
What happens is that every tick adds 1 to the x and y position of the centering force forceCenter, so the graph slowly drifts off the screen.
Here&amp;rsquo;s the key bit of code:
function tickActions() { //update circle positions each tick of the simulation node .attr(&amp;#34;cx&amp;#34;, function(d) { return d.x; }) .attr(&amp;#34;cy&amp;#34;, function(d) { return d.y; }); //update link positions //simply tells one end of the line to follow one node around //and the other end of the line to follow the other node around link .</description></item><item><title>Force directed graph: squashed</title><link>https://tomroth.dev/fdg-squashed/</link><pubDate>Thu, 16 Mar 2017 00:00:00 +0000</pubDate><guid>https://tomroth.dev/fdg-squashed/</guid><description>This example uses a combination of the positioning forces forceX and forceCenter to create a &amp;ldquo;squashed&amp;rdquo; aesthetic.
The centering force forceCenter keeps the graph in the centre of the svg element, while forceX drags all the nodes towards x-position 400 on the svg element.
var force_X = d3.forceX(400) .strength(0.2); var center_force = d3.forceCenter(width/2, height/2); The result is a tall and thin graph. Doing the same with forceY instead of forceX leads to a short and fat graph instead.</description></item><item><title>Force directed graph: collision forces</title><link>https://tomroth.dev/fdg-collision/</link><pubDate>Wed, 15 Mar 2017 00:00:00 +0000</pubDate><guid>https://tomroth.dev/fdg-collision/</guid><description>There’s two types of forces in the d3-force module – preshipped forces and custom forces.
Preshipped forces have already been written for you. Custom forces you write yourself.
Here we&amp;rsquo;ll cover the preshipped force that handles collisions between nodes - forceCollide.
Using forceCollide will prevent your nodes from rolling right over each other. Its purpose is to stop nodes from overlapping.
forceCollide is designed for those many situations where you crave some order in your nodes.</description></item><item><title>Force directed graph: radially expanding</title><link>https://tomroth.dev/fdg-expand/</link><pubDate>Wed, 15 Mar 2017 00:00:00 +0000</pubDate><guid>https://tomroth.dev/fdg-expand/</guid><description>This is an example of the effect you can generate by playing with the forceLink parameters and the forceManyBody parameters.
This graph radially expands. Try dragging it around - nodes will stay where you put them but the rest will expand outwards.
This effect can be created in two steps:
Set the forceLink strength to 0. This removes the link force while maintaining the lines between nodes. Set the charge to a small negative number.</description></item><item><title>Force directed graph: charge forces</title><link>https://tomroth.dev/fdg-charge/</link><pubDate>Sun, 12 Mar 2017 00:00:00 +0000</pubDate><guid>https://tomroth.dev/fdg-charge/</guid><description>There’s two types of forces in the d3-force module. These are preshipped forces and custom forces.
Preshipped forces have already been written for you. Custom forces you write yourself.
Here we cover a preshipped force - forceManyBody(). This is perhaps the defining force of the force-directed graph.
You use this force to simulate the charged-particles model, where every node repels (or attracts) every other node until we reach a stable state.</description></item><item><title>Force directed graph: link forces</title><link>https://tomroth.dev/fdg-link/</link><pubDate>Sun, 12 Mar 2017 00:00:00 +0000</pubDate><guid>https://tomroth.dev/fdg-link/</guid><description>There’s two types of forces in the d3-force module – preshipped forces and custom forces.
Preshipped forces have already been written for you. Custom forces you write yourself.
In this post we cover the force that links nodes together - forceLink(). This is the force that pushes linked nodes together or pulls them apart.
Parameters Link to heading Like the other forces, there&amp;rsquo;s a number of parameters you can tweak to customise your force directed graph.</description></item><item><title>Force directed graph: positioning forces</title><link>https://tomroth.dev/fdg-position/</link><pubDate>Sun, 12 Mar 2017 00:00:00 +0000</pubDate><guid>https://tomroth.dev/fdg-position/</guid><description>There’s two types of forces in the d3-force module – preshipped forces and custom forces.
Preshipped forces have already been written for you. Custom forces you write yourself.
Here we&amp;rsquo;ll cover the three preshipped positioning forces:
forceCenter forceX forceY Using positioning forces is easy. There&amp;rsquo;s not too many parameters to play with and they&amp;rsquo;re easy to understand!
forceCenter Link to heading forceCenter applies a force to all nodes that’ll bring their centre of mass towards a given point.</description></item><item><title>Force directed graph: using node and link attributes</title><link>https://tomroth.dev/fdg-attributes/</link><pubDate>Wed, 08 Mar 2017 00:00:00 +0000</pubDate><guid>https://tomroth.dev/fdg-attributes/</guid><description>We&amp;rsquo;ve slowly been adding more functionality onto our graph. It&amp;rsquo;s not quite useable yet, but not far off.
Today&amp;rsquo;s topic: incorporating node attributes and link attributes into our graph.
It&amp;rsquo;ll really bring our graph to life!
Attributes Link to heading When you specify data for nodes and links you can put in whatever fields you like.
Let&amp;rsquo;s look at an example.
Here&amp;rsquo;s some data. I&amp;rsquo;ve taken some of the characters from the fantastic online serial Twig and mapped out some relationships between them.</description></item><item><title>Force directed graph: dragable</title><link>https://tomroth.dev/fdg-dragable/</link><pubDate>Mon, 06 Mar 2017 00:00:00 +0000</pubDate><guid>https://tomroth.dev/fdg-dragable/</guid><description>This is the second of two posts explaining the basics of drag and drop. You can find the first post here.
Lets take the minimal working example as a template.
We&amp;rsquo;re going to make the same graph dragable so that we can interact with it. Click on the picture above to see what this looks like!
You also need to know how drag and drop works before diving into this article.</description></item><item><title>Force directed graph: sticky nodes</title><link>https://tomroth.dev/fdg-sticky/</link><pubDate>Mon, 06 Mar 2017 00:00:00 +0000</pubDate><guid>https://tomroth.dev/fdg-sticky/</guid><description>Sticky nodes are where nodes are &amp;ldquo;stuck&amp;rdquo; once you&amp;rsquo;ve finished dragging them. They won&amp;rsquo;t move again once the mouse has been released - unless you drag them again, of course. Click on the image above for spoilers!
It&amp;rsquo;s super easy to make your nodes sticky.
Start with the example here.
Scroll down to the drag_end function. It looks like
function drag_end(d) { if (!d3.event.active) simulation.alphaTarget(0); d.fx = null; d.fy = null; } Currently it is telling the force directed graph to release the nodes when the mouse is released.</description></item><item><title>Get drag and drop working with d3</title><link>https://tomroth.dev/drag-example/</link><pubDate>Tue, 28 Feb 2017 00:00:00 +0000</pubDate><guid>https://tomroth.dev/drag-example/</guid><description>This is the first of two posts explaining the basics of drag and drop.
Want the second post? Here it is!.
In this post we’ll start to become familiar with the module d3-drag.
This module is a useful and flexible one that has many applications. Spending some time understanding the basics of this module can pay large benefits.
The best way to learn is through examples - so we’re going to create a simple example to see what exactly is happening.</description></item><item><title>Force directed graph: minimal working example</title><link>https://tomroth.dev/fdg-minimal/</link><pubDate>Sat, 25 Feb 2017 00:00:00 +0000</pubDate><guid>https://tomroth.dev/fdg-minimal/</guid><description>The goal of this post is to take what we covered earlier and make a simple working example of a force-directed graph.
We&amp;rsquo;ll start with just getting the nodes working, adding the links afterwards to complete the example. Find what we&amp;rsquo;ll be building here.
So open up a text file in your favourite editor. Fire up a local server. Find yourself a cool drink or two.
Ready? Let’s begin.
Nodes Link to heading First thing we’ll do is set up a basic skeleton for our force directed graph.</description></item><item><title>Force directed graph: basics</title><link>https://tomroth.dev/fdg-basics/</link><pubDate>Sat, 18 Feb 2017 00:00:00 +0000</pubDate><guid>https://tomroth.dev/fdg-basics/</guid><description>To create a D3 force directed graph you really only need three things:
Nodes A simulation Forces to act on the simulation There’s also some things that are optional, but real useful:
Links Node attributes Great. Let&amp;rsquo;s learn more.
Nodes Link to heading What are nodes? They&amp;rsquo;re an array of objects.
Nodes can be anything. Here&amp;rsquo;s three examples:
people in a friendship group telegraph poles in a distributed grid articles on a Wikipedia page Nodes are whatever data objects that you want to visualise.</description></item><item><title>Three simple matrix decompositions in R</title><link>https://tomroth.dev/decomp/</link><pubDate>Sun, 11 Dec 2016 00:00:00 +0000</pubDate><guid>https://tomroth.dev/decomp/</guid><description>In the confusing world of matrix decompositions, three of the most useful are $A = LU$, $A = U^T U$ (the Cholesky decomposition) and $A = QR$.
Here&amp;rsquo;s some R code to explore these useful beasts.
1. A = LU Link to heading Present in every textbook in linear algebra, performing LU decompositions in R is quick and painless.
The easiest way to do this is to use the lu function in the Matrix package.</description></item><item><title>Write your own logistic regression function in R</title><link>https://tomroth.dev/logistic/</link><pubDate>Wed, 05 Oct 2016 00:00:00 +0000</pubDate><guid>https://tomroth.dev/logistic/</guid><description>Ever wondered how logistic regression really works?
You&amp;rsquo;re not alone. It&amp;rsquo;s confusing.
This post drills down into the mechanics of logistic regression. We&amp;rsquo;ll go through the mathematical aspects and also construct our own logistic regression function in R. Exciting!
What is logistic regression? Link to heading In linear regression the dependent variable $Y$ takes continuous values, like house prices for an area or the income of a individual.
Logistic regression differs in that it is used for modelling categorical data.</description></item><item><title>Linear Regression in R</title><link>https://tomroth.dev/regression/</link><pubDate>Sun, 07 Aug 2016 00:00:00 +0000</pubDate><guid>https://tomroth.dev/regression/</guid><description>As humans, we&amp;rsquo;re drawn to cause and effect. Even when it&amp;rsquo;s wrong of us to do so.
When it gets hot, it&amp;rsquo;s not necessarily because of global warming. An increase in homeless people will not definitively cause an increase in crime rates. Male drivers crash more than female drivers, but maybe this isn&amp;rsquo;t because of their increased testosterone levels.
We&amp;rsquo;ve all heard the correlation vs causation argument before. Our System 2 conscious mind knows that cause and effect isn&amp;rsquo;t always correct.</description></item><item><title>What is a JavaScript method?</title><link>https://tomroth.dev/js-methods/</link><pubDate>Sat, 09 Jul 2016 00:00:00 +0000</pubDate><guid>https://tomroth.dev/js-methods/</guid><description>Javascript contains objects, which are things like a document, a window or a frame.
Objects can also be something that you define yourself. This is an object:
var cricketer = {firstName:&amp;#34;Ricky&amp;#34;, lastName:&amp;#34;Ponting&amp;#34;, age:41, batAvg: 51.85}; A method is a function that is performed on an object. Methods belong to objects.
Here&amp;rsquo;s the object from earlier, this time with a method called getSummary attached:
var cricketer = {firstName:&amp;#34;Ricky&amp;#34;, lastName:&amp;#34;Ponting&amp;#34;, age:41, batAvg: 51.</description></item><item><title>Simple examples with transition chaining</title><link>https://tomroth.dev/transitions/</link><pubDate>Thu, 02 Jun 2016 00:00:00 +0000</pubDate><guid>https://tomroth.dev/transitions/</guid><description>There are a few explanations and tutorials on the web about how to perform chained transitions on the same element using d3. Also existing are lots of demonstration: see this and this, for example.
I couldn&amp;rsquo;t find any dead-simple tutorial out there, however. This example will be just about as simple as it gets.
Let&amp;rsquo;s create a circle attached to a SVG element and use this as a running example. You can just do this in the console for a browser with d3 activated.</description></item><item><title>The story of d3 and the Start and End event listeners.</title><link>https://tomroth.dev/event-listeners/</link><pubDate>Sun, 29 May 2016 00:00:00 +0000</pubDate><guid>https://tomroth.dev/event-listeners/</guid><description>One of the cool things about d3 is that we can &amp;ldquo;listen&amp;rdquo; for transition events.
These listeners can be very useful things.
I&amp;rsquo;ll go through two of these in this blog post: start, and end. The use of these is best explained through examples.
Let&amp;rsquo;s start with the start listener (ha!).
Start listeners Link to heading One use of a start listener is to trigger a function to run at the start of a transition.</description></item><item><title>Dancing madness: fun with mouse events and d3</title><link>https://tomroth.dev/dancing-madness/</link><pubDate>Sun, 22 May 2016 00:00:00 +0000</pubDate><guid>https://tomroth.dev/dancing-madness/</guid><description>There’s something oddly satisfying about making things appear through a mouse click. It’s like the webpage has recognised your supremacy over it and is bowing to accommodate your wishes. You are its master. You have power.
Are you a person who likes to feel powerful?
Read on. We’re going to create something truly amazing.
Our task: to click inside a rectangle, and have dancing people appear. Why dancing people, you ask?</description></item><item><title>Graphs 'n stuff: simple line chart with d3</title><link>https://tomroth.dev/linechart/</link><pubDate>Sun, 08 May 2016 00:00:00 +0000</pubDate><guid>https://tomroth.dev/linechart/</guid><description>Tennis: a sport almost designed for statistical analysis. You have only two primary variables (players) up against each other - whereas for something like soccer, you have 22 players who can impact the play. Much simpler - yet infinitely more complicated at the same time.
With this in mind (and with the aid of the mountains of tennis data available) I decided to trial a simple betting strategy. Simply put, it compares calculated probabilities for the outcome of tennis matches against the odds done by bookmakers.</description></item><item><title>Graphs 'n stuff: simple bar chart with d3</title><link>https://tomroth.dev/barchart/</link><pubDate>Sun, 01 May 2016 00:00:00 +0000</pubDate><guid>https://tomroth.dev/barchart/</guid><description>This next introductory example is a simple bar chart with a rollover tooltip. This bar chart uses the d3-tip tooltip capabilities to enhance on the tooltip shown in our scatterplot.
It&amp;rsquo;s a graph of the number of internet users over time, also displaying the percentage of the world&amp;rsquo;s population as rollover information. The code is here.
I&amp;rsquo;ll be abandoning the Wp-D3 plugin I&amp;rsquo;ve been using for the moment (it&amp;rsquo;s just too fiddly for my liking) and instead link directly to the code with the graph.</description></item><item><title>Graphs 'n stuff: simple scatterplot with d3</title><link>https://tomroth.dev/scatter/</link><pubDate>Sun, 17 Apr 2016 00:00:00 +0000</pubDate><guid>https://tomroth.dev/scatter/</guid><description>Recently I&amp;rsquo;ve been learning how to use d3.js (D3), often touted as an incredibly powerful cool for creating graphics. I thought it&amp;rsquo;d be helpful to any other novices out there to write up my D3 examples as I do them. I come from a statistical background and while I have plenty of experience coding in R, JavaScript is a whole new challenge.
I&amp;rsquo;ll be writing up short explanations on any particular aspect that confuses me with a particular visualisation.</description></item></channel></rss>