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

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…

Photo by Alvaro Reyes on Unsplash

Jira is a proprietary issue tracking product developed by Atlassian that allows bug tracking and agile project management.

This post shows you how to deploy it in a Docker Container on Ubuntu.

Step 1: Install Docker

Step 2: Install Docker-Compose

Step 3: Download the Jira docker image

git clone \
&& cd jira
&& docker-compose pull

Step 4: Start Jira Service

docker-compose up -d

Step 5: Configure and Restart Nginx Service

# /etc/nginx/conf.d/jira.confserver {
listen 80;
access_log off;
location / {

proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-Proto https;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;

draw a house

Coding for kids not only helps them to improve mathematics and problem-solving skills but also encourages them to be more confident in life and eventually in the workforce.

Doing and making positive programming for young people is so important to me, and I will keep doing it.

Among all the programming languages, Python is the most suitable one for kids to learn. It is used in college courses and by many tech companies like Google and IBM. However, without graphics, it is not intuitive to understand for a young kid. Fortunately, the Turtle Library is the rescue.

The Turtle Library

Django is a great high-level framework for Python Web development that encourages rapid development and clean, pragmatic design. There are many websites such as Instagram, Pinterest, Youtube, Spotify, and Bitbucket that use this framework.

This post assumes a basic familiarity with Django REST Framework. We would discuss 10 useful tips to increase your Django REST coding efficiency.

Now, let’s get started.

  1. Set current user field
class ArticleSerializer(serializers.ModelSerializer):

owner = serializers.HiddenField(

To realize the same result, we can also pass parameters from the view function.

class ArticleView(generics.ListCreateAPIView):  def perform_create(self, serializer):

2. Composite Index and Composite Unique key…

Problem Statement

A company is planning to interview 2N people. Given the array costs, the cost of flying the i-th person to city A is costs[i][0], and the cost of flying the i-th person to city B is costs[i][1].

Return the minimum cost to fly every person to a city such that exactly n people arrive in each city.

Example 1:

Input: costs = [[10,20],[30,200],[400,50],[30,20]] Output: 110 Explanation: The first person goes to city A for a cost of 10. The second person goes to city A for a cost of 30. The third person goes to city B for a cost…

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