Confusion matrix, Accuracy, Precision, Sensitivity, Specificity, F1 score, and Roc curve, let’s remember them once for all

Despite having seen all these concepts more than a thousand times, I’m still getting confused sometimes. Is there a good way to think about all these concepts so that they start making sense?

In this post, I will focus on how to remember them. If you’re not familiar with them, please read the following posts first.

Table of content

  1. Confusion Matrix
  2. Accuracy
  3. Precision
  4. Recall
  5. Specificity
  6. Tradeoff
  7. Roc Curve

1. Confusion Matrix

A confusion matrix is a table used to evaluate the performance of a classification model. It summarizes the count combinations of every predicted and actual class.

Let’s understand this concept in a simple example. Below…

Redis is an open source (BSD licensed), in-memory data structure store, used as a database, cache and message broker. It supports data structures such as strings, hashes, lists, sets, sorted sets with range queries, bitmaps, hyperloglogs and geospatial indexes with radius queries.

Redis is the world’s most popular in-memory data structure server. In order to make good use of it, we need to understand its basic data structures first.


The Redis String type is the simplest type of value you can associate with a Redis key. …

Photo by Sigmund on Unsplash

When talking about string, bytes, and runes, many entry-level Golang developers feel confused. In this post, I’d like to give some explanations from an application developer standpoint.

If you prefer thorough explanations from Rob Pike, who is the partner invertor of Go language. Please be free to have a pause here and read the following post.


A byte in Go is an unsigned 8-bit integer. That means it has a limit of 0–255 in the numerical range.

type byte = uint8

According to Go documentation, Byte is an alias for uint8 and is the same as uint8 in all ways…


Have you struggled to decide which programming language is worth learning in the next 10 years?

In this post, I will list 5 reasons to tell why you should start to learn Go Programming Language.

1. Created by masters at Google

Go is designed by Robert Griesemer, Rob Pike, and Ken Thompson.

Go supports composite types such as an array, slice, maps, and structures. We will discuss the four composite types one by one

Golang Data Types

In Go, the data types divide into four categories which are as follows:

  1. Basic type: Numbers, strings, and booleans come under this category.
  2. Aggregate type: Array and structs come under this category. Their values are concatenations of other values in memory.
  3. Reference type: Pointers, slices, maps, functions, and channels come under this category.
  4. Interface type

In this post, we will discuss four composite types: arrays, slices, and maps, structs.

Table of Content


  • Array stores collection of items with the same type (homogeneous)
  • The elements in the array store in continuous memory locations
  • Array has Fixed-size
  • Declaration styles
// Given…

As we start to scale an application horizontally, we may run into a problem that requires distributed locking.

In this post, I will show you how to implement a distributed lock step by step based on Redis and python.

Simplest Lock

Building a mostly correct lock in Redis is easy. It consisted of three steps:

  • Acquire the lock,
  • Run some block of code
  • Release the lock

The acquire_lock() function

def acquire_lock(conn, lock_name, acquire_timeout=10):    identifier = str(uuid.uuid4())

end = time.time() + acquire_timeout
while time.time() < end:
if conn.setnx("lock:"+lock_name, identifier)
return identifier


return False
  • We’ll set a 128-bit randomly generated UUID into the…

Photo by Georg Bommeli on Unsplash

Most database systems use Read Committed is the default isolation level (MySQL using Repeatable Read instead).

Choosing the isolation level is about finding the right balance of consistency and scalability for our current application requirements.

In this post, we will deep into the MySQL Transaction Isolation Levels.


Let’s first create a fake user table

CREATE TABLE `users` (
`username` varchar(25) COLLATE utf8mb4_unicode_ci NOT NULL,
`password` varchar(25) COLLATE utf8mb4_unicode_ci DEFAULT 'password01',

Then, add some data records.

INSERT INTO `users` (`id`, `username`, `password`)
(2, 'tom', 'wysiwyg77'),

The Hamming distance between two integers is the number of positions at which the corresponding bits are different.

In this post, we are gonna discuss how to calculate the total Hamming distance

Problem Statement

Given an integer array nums, return the sum of Hamming distances between all the pairs of the integers in nums.

Input: nums = [4,14,2]
Output: 6

In binary representation, the 4 is 0100, 14 is 1110, and 2 is 0010 (just
showing the four bits relevant in this case). …

Some important concepts behind indexing


Indexes are used to find rows with specific values quickly.

If a table has an index for the column in question, MySQL can quickly determine the position to seek in the middle of the data file without having to look at all the data. It is much faster than reading every row sequentially.

In this post, we’ll look at some of the important concepts behind indexing.


Let’s first create a MySQL table.

`custId` INT,
`name` VARCHAR(50),
`mobileNo` VARCHAR(11)

Assume we have a…

Three approaches to solving the sliding window maximum problem

Sliding Window Maximum Problem

In this post, we are gonna discuss multiple solutions for sliding window maximum problem.

If you prefer to learn through videos, please have a look at the following video.

Problem Statement

You are given an array of integers, there is a sliding window of size k which is moving from the very left of the array to the very right. You can only see the k numbers in the window. Each time the sliding window moves right by one position.

Return the max sliding window.


Input: nums = [1,3,-1,-3,5,3,6,7], k = 3
Output: [3,3,5,5,6,7]
Window position…

Jerry An

Developer in China, AI and machine learning enthusiast

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store