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. …

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…

Lessons Learned From Scraping Over Hundreds of Websites.

Photo by Emile Perron on Unsplash

In the past few years, I had participated hundreds of web scraping projects. In the meantime, I had encountered a lot of scraping challenges.

In this post, I will list some scraping challenges and hope they will give you some help for the next interview.

1. Changing Structure

Recently, I needed to install the Catalina Mac System on my MacBooks. So I decide to make a bootable USB disk myself.

Let’s get started!


  • USB flash drive: It has at least 16GB of storage and make sure the data inside is backed up.
  • Download the macOS Catalina installer file Catalina.dmg
  • Install Disk Creator

Install Steps

  1. Open LaunchPad→ Disk Utility

Here’s a quick guide to creating an Automatic service (quick action) so that you can convert PNG image files to JPG with a right-click.

Converting the PNG file to JPG doesn’t need any fancy software. There is a function baked into macOS and accessible to Automator.

You can set it up as a Quick Action so that you can right-click on the file and convert it to JPG with a single click.

Step 1: Open “Automator” Application

A deep look at the algorithm and some takeaways for your next tech interview

Photo by Susan Q Yin on Unsplash

Suppose you are in a library and want to find a book on a certain bookshelf. Book arranges in alphabetical order or by some integer code.

Generally speaking, the naive way to find it is to go book by book, but this will take a lot of time. You think there must be a better solution.

Ta Ta!

Binary Search Algorithm!

Binary Search

In computer science, binary search, also known as half-interval search, is a search algorithm that finds the position of a target value within a sorted array.

The binary search algorithm is used to search an item from an sorted/sorted…

Learn keyboard shortcuts and become a pro

Image: Darrell Etherington / Darrell Etherington

Last week, I bought a mechanical keyboard and started to think it’s time to reduce my dependence on the mouse and to increase working productivity and efficiency.

A study says if your job requires you to be working on a computer throughout each standard 8-hour workday, then using keyboard shortcuts can save you 8 entire workdays every year. This is equal to 3.3% of your total productivity!

So in this post, I will list my most commonly used keyboard shortcuts and hope they will help everyone work efficiently.


  • Introduction of Mac Special keys
  • Chrome Keyboard Shortcuts
  • System Keyboard Shortcuts
  • Text-input…

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