In the last article we took a look at a simple k-means implementation using Python. In this article we will sophisticate our previous work by doing away with hard coded data, replacing the Vec class with Numpy arrays and visualizing results using matplotlib. The source code for this iteration can be found here. We will not go through it line by line, but we will look at the most significant improvements.
In this article we will build a k-means clustering algorithm. We will use plain old Python and no other third party code. The goal of this article is to convey the basic structure of the k-means algorithm by developing a minimal working example capable of clustering a 2D dataset. It is expected that you understand basic programming, simple vector math and that you have at least some idea about how k-means works. Let’s get started.
In my last article I wrote about how to create an Icosahedron using Swift and SceneKit. The example used hard-coded values for the vertices and indices that define the shape. In this article, I’ll show how we can create a sphere using that same data for initial values combined with an iterative algorithm. The algorithm takes each face of the Icosahedron and sub-divides it into four new triangles. The vertices of which are turned into new faces to be once again sub-divided in the next iteration.
In this article I’ll demonstrate an of example of creating custom 3D geometry for SceneKit using the Swift programming language. We’ll look at how to create the simple yet very interesting polyhedron known as the Icosahedron.
SCNVector3 class for SceneKit is a bit under-featured. Here is an extension that adds many useful operators and a few nice to have methods to it. A feature in Swift that is particularly helpful here is the ability to declare a function parameter as an
inout variable. This allows you to reassign a value to the variable itself. This is especially useful for defining
*= and the like.
Below is a list of software libraries that I am going to dig into over the next few months. The plan is to create a small project using each tool and then do a write up about it.
A list of machine learning and data science resources
If you run into this error when attempting to create a user on Linux or OSX: