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

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] Explanation: Window position Max --------------- …

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…

Understand the differences between direct address table and hash table, implement a Hashmap from Scratch

The graphic shows the mapping of the keys to their bucket by using the hash function.

A hash table is a dynamic set that supports the dictionary operations of INSERT, SEARCH, and DELETE with average O(1) time complexity.

How does a hash table work under the hood? Let’s figure it out in this post.

Direct Address Table

To understand a hash table, the direct address table is the first concept we should understand.

Everything you need to know about LRU, Cache, and its implementation details using a hash table and double-linked-list.

LRU cache using a hash table and double-linked-list

Table of Contents

What is a LRU cache

A cache’s primary purpose is to increase data retrieval performance by reducing the need to access the underlying slower storage layer.

Trading off capacity for speed, a cache typically stores a subset of data transiently, in contrast to databases whose data is usually complete and durable.

An LRU cache stands for Least Recently Used cache. It is an efficient cache data structure that can be used to figure out what we should evict when the cache is full. It has the following features:

  • Fixed-size cache capacity
  • Items…

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