How do you measure how well your machine learning model is doing? There are four main metrics for measuring the accuracy of a machine learning model. These metrics are accuracy, precision, recall, and F-Score (or F Score). In this post, we’ll be covering how to calculate each of these metrics and what they’re used for.Continue reading “Accuracy, Precision, Recall, and F Score”

# Author Archives: Yujian Tang

## How to Make a 4×4 Magic Square in Python

Magic Squares is one of the oldest recreational mathematics games. The smallest magic squares are three by three, but they can be made up to any size with the right formulas. Odd and even ordered magic squares have different formulas, but can be easily generated. Programming has made it even easier to make magic squares,Continue reading “How to Make a 4×4 Magic Square in Python”

## Graph Algorithms: Prim’s Algorithm in Python

Minimum Spanning Tree (MST) algorithms find the shortest path that connects all the points in a graph. Tree algorithms that find minimum spanning trees are useful in network design, taxonomies, or cluster analysis. On PythonAlgos, we’ve already covered one MST algorithm, Kruskal’s algorithm. Prim’s algorithm is similar to Kruskal’s algorithm. Whereas Kruskal’s adds to theContinue reading “Graph Algorithms: Prim’s Algorithm in Python”

## Slicing Python Strings: A Complete Guide

Python comes with a string slicing system that is a Swiss army knife of functionality. Bracket notation allows us to slice Python strings to get one or more characters in order or in reverse. In this complete guide on slicing Python strings we’ll cover: Slicing a Single Character from a Python String Using a NegativeContinue reading “Slicing Python Strings: A Complete Guide”

## Graph Algorithms: Kruskal’s Algorithm in Python

Data structures and algorithms are a cornerstone of computer science. In our journey so far, we’ve looked at basic data structures like stacks, queues, and dequeues, linked lists and binary trees, and algorithms like sorting algorithms, tree algorithms, and Dijsktra’s algorithm. Now, let’s take a look at another important graph algorithm – Kruskal’s. Kruskal’s algorithmContinue reading “Graph Algorithms: Kruskal’s Algorithm in Python”

## Graph Algorithms: Floyd Warshall in Python

Data structures and algorithms are a cornerstone of computer science. In our journey so far, we’ve looked at basic data structures like stacks, queues, and dequeues, linked lists and binary trees, and algorithms like sorting algorithms, tree algorithms, and Dijsktra’s algorithm. Now, let’s take a look at another important graph algorithm – Floyd Warshall. InContinue reading “Graph Algorithms: Floyd Warshall in Python”

## Nested Lists in Python

Nested lists are Python representations of two dimensional arrays. They are used to represent lists of lists. For example, a list of grocery lists for the month or matrices we can multiply. In this post we’re going to go over how to use Python to create and manipulate nested lists. We’ll go over: Python NestedContinue reading “Nested Lists in Python”

## Level 1 Python: Pure Python Matrix Multiplication

Level 1 Python projects are projects that are more logically complex or require more libraries than the ones in the Super Simple Python series. Pure Python matrix multiplication is one of the projects that is more logically complex, we won’t be using any external libraries here. Most of these projects should take you between 30Continue reading “Level 1 Python: Pure Python Matrix Multiplication”

## Super Simple Python: Madlibs

Super Simple Python is a series of Python projects you can do in under 15 minutes. In this episode, we’ll be covering how to build a simple Madlibs-like game in under 15 lines of Python. We don’t need to import any libraries for this program, we’re just going to create a simple script. Much likeContinue reading “Super Simple Python: Madlibs”

## Python Single Responsibility Principle

You’ve probably heard about programming principles. A piece of advice that always gets thrown around is “have the smallest classes/functions/modules possible”. What does that mean though? How do you make a function as small as possible? The single responsibility principle. This programming principle dictates how small a function could possibly be. In this post, we’llContinue reading “Python Single Responsibility Principle”