In this tutorial we will explore the Davies-Bouldin index and its application to K-Means clustering evaluation in Python.

Table of Contents

  • Introduction
  • Davies-Bouldin Index
  • Step 1: Calculate intra-cluster dispersion
  • Step 2: Calculate separation measure
  • Step 3: Calculate similarity between clusters
  • Step 4: Find most similar cluster for each cluster i
  • Step 5: Calculate Davies-Bouldin Index
  • Davies-Bouldin Index example in Python
  • Conclusion

Introduction

The Davies-Bouldin index (DBI) is one of the clustering algorithms evaluation measures. It is most commonly used to evaluate the goodness of split by a K-Means clustering algorithm for a given number of clusters.

In a few words, the score (DBI) is calculated as the average similarity of each cluster with a cluster most similar to it…


In this article, we will discuss how to calculate factorial in Python.

Photo by Chris Liverani on Unsplash

Table of Contents

  • Introduction
  • Factorial formula
  • Calculating factorial in Python
  • Factorial functions in Python
  • Conclusion

Introduction

Most often you would see factorials in combinatorics algebra and probability theory.

Factorials are used in permutations (calculating the number of ways to arrange some objects) and combinations (calculating the number of ways a subset of objects can be selected from a set of objects).

Factorial formula

Basically, for any integer n, that is greater than or equal to 1 (n ≥ 1), the factorial is the product of all integers in range (1:n)and is…


In this article we will discuss how to solve a quadratic equation using Python.

Table of Contents

  • Introduction
  • Quadratic formula
  • Solving quadratic equation using Python
  • Complete code
  • Conclusion

Introduction

In algebra, quadratic equations are widely used in a lot of tasks. A quadratic equation (second-degree polynomial) always has a squared term which differentiates it from our usual linear equations.

In this tutorial we will use the math library (prebuilt in Python) for solving quadratic equations using Python.

Quadratic formula

We begin with understanding the standard form of quadratic equation:

So how do we know if the equation has a solution? …


In this article we will discuss how to solve linear programming problems with Gurobipy in Python.

Table of Contents

  • Introduction
  • Linear programming example
  • Solving linear programming problem with Python
  • Conclusion

Introduction

Linear programming (LP) is a tool to solve optimization problems. It is widely used to solve optimization problems in many industries.

In this tutorial we will be working with gurobipy library, which is a Gurobi Python interface. Gurobi is one of the most powerful and fastest optimization solvers and the company constantly releases new features. You can learn more about their licenses here.

To continue following this tutorial we will need the following…


In this article we will discuss how to make a simple keylogger using Python.

Table of Contents

  • Introduction
  • Press and release keys
  • Create a sample log file
  • Create a simple keylogger
  • Conclusion

Introduction

Keyloggers are a type of monitoring software used to record keystrokes made by the user with their keyboard.

They are often used for monitoring the network usage as well as troubleshoot the technical problems. On the other hand, a lot of malicious software uses keyloggers to attempt to get usernames and passwords for different websites.

To continue following this tutorial we will need the following Python library: pynput.


In this article we will discuss how to get system and hardware information of your computer using Python.

Table of Contents

  • Introduction
  • System information
  • CPU usage
  • Memory usage
  • Conclusion

Introduction

We often look at our system information and open the task manager to see the utilization of our CPU and RAM and look through the processes running.

There is a convenient way of retrieving such information using Python in a few lines of code.

To continue following this tutorial we will need the following two Python libraries: platform and psutil.

The platform module is already installed by default.

If you…


In this article we will discuss cosine similarity with examples of its application to product matching in Python.

Table of Contents:

  • Introduction
  • Cosine Similarity (Overview)
  • Product Similarity using Python (Example)
  • Conclusion

Introduction

A lot of interesting cases and projects in the recommendation engines field heavily relies on correctly identifying similarity between pairs of items and/or users.

There are several approaches to quantifying similarity which have the same goal yet differ in the approach and mathematical formulation.

In this article we will explore one of these quantification methods which is cosine similarity. …


In this article, we will discuss how to extract links from a URL using Python.

Table of Contents

  • Introduction
  • Get HTML content from URL
  • Finding and extracting links from HTML
  • Conclusion

Introduction

URL extractors are a very popular tool for everyone involved in the digital space, from marketers to SEO professionals. It is also a big part for web scrapers in the programming community. These scripts range from very simple ones (like the one in this tutorial) to very advanced web crawlers used by the industry leaders.

Let’s see how we can quickly build our own URL scraper using Python.


In this article we will discuss how to encrypt and decrypt files using Python.

Table of Contents

  • Introduction
  • Creating a key
  • Loading a key
  • Encrypting a file
  • Decrypting a file
  • Complete Object-Oriented Programming Example
  • Conclusion

Introduction

In the evolving world of data and information transfer, security of the file contents remain to be one of the greatest concerns for companies. Some information can be password protected (emails, logins) while other information being transferred via emails or FTP lacks efficiency if protected by some keyword. …


In this article we will discuss how to access and edit Google Sheets using Python.

Table of Contents

  • Introduction
  • Creating a sample Google Sheets document
  • Creating Google API credentials
  • Opening a Google sheet using Python
  • Selecting/creating/deleting a worksheet using Python
  • Editing data in a Google sheet using Python
  • Conclusion

Introduction

Accessing data from multiple sources using Python becomes a standard requirement for nearly any position in data science and analytics. Working with Excel spreadsheets and internal CSV files happens everywhere.

But what if your data is now stored on Google Drive as a Google Sheet? Of course you can download it…

Misha Sv

Data Scientist

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