Machine Learning From Scratch

  • SQL | The LIKE Operator

    SQL | The LIKE Operator

    SELECT column_name(s) FROM table_name WHERE column_name LIKE pattern LIKE Operator Example The “Persons” table: Now we want to select the persons living in a city that starts with “s” from the table above. We use the following SELECT statement: SELECT * FROM Persons WHERE City LIKE ‘s%’ The “%” sign can be used to define… Read more

  • Understanding DBSCAN Clustering Algorithm: Implementation in Python

    Before we move on to Gaussian mixture models, let’s take a look at DBSCAN, another popular clustering algorithm that illustrates a very different approach based on local density estimation. This approach allows the algorithm to identify clusters of arbitrary shapes. Understanding DBSCAN Clustering Algorithm DBSCAN (Density-Based Spatial Clustering of Applications with Noise) is a popular… Read more

  • Using Clustering for Semi-Supervised Learning

    Another use case for clustering is in semi-supervised learning, when we have plenty of unlabeled instances and very few labeled instances. Let’s train a logistic regression model on a sample of 50 labeled instances from the digits dataset: n_labeled = 50 log_reg = LogisticRegression() log_reg.fit(X_train[:n_labeled], y_train[:n_labeled]) What is the performance of this model on the… Read more

  • Using clustering for image segmentation

    Image segmentation is the task of partitioning an image into multiple segments. In semantic segmentation, all pixels that are part of the same object type get assigned to the same segment. For example, in a self-driving car’s vision system, all pixels that are part of a pedestrian’s image might be assigned to the “pedestrian” segment… Read more

  • Accelerated K-Means and Mini-batch K-Means

    Introduction Another important improvement to the K-Means algorithm was proposed in a 2003 paper by Charles Elkan. It considerably accelerates the algorithm by avoiding many unnecessary distance calculations: this is achieved by exploiting the triangle inequality (i.e., the straight line is always the shortest) and by keeping track of lower and upper bounds for distances… Read more

  • Implementation of K-Means Clustering in Machine Learning

    Consider the unlabeled dataset represented in Figure below: you can clearly see 5 blobs of instances. The K-Means algorithm is a simple algorithm capable of clustering this kind of dataset very quickly and efficiently, often in just a few iterations. It was proposed by Stuart Lloyd at the Bell Labs in 1957 as a technique… Read more