# Category Archives: Data Science

## Beta Distribution Example for Cricket Score Analysis

This post represents a real-world example of Binomial and Beta probability distribution from the sports field. In this post, you will learn about how the run scored by a Cricket player could be modeled using Binomial and Beta distribution. Ever wanted to predict the probability of Virat Kohli scoring a half-century in a particular match. This post will present a perspective on the same by using beta distribution to model the probability of runs that can be scored in a match. If you are a data scientist trying to understand beta and binomial distribution with a real-world example, this post will turn out to be helpful. First and foremost, let’s identify the random variable that we would like …

## 25 Types of Probability Distributions Defined with Examples

In this post, you will learn the definition of 25 different types of probability distributions. Before we get into understanding different types of probability distributions, let’s understand some fundamentals. If you are a data scientist, you would like to go through these distributions. This page could also be seen as a cheatsheet for probability distributions. What is Probability Distributions? A probability distribution is a mathematical function that can be thought of as providing the probabilities of occurrence of different possible outcomes in an experiment. Probability distributions are divided into two classes: Discrete Probability Distribution: The probabilities defined on a discrete random variable, one which can only take a discrete set of values, is …

## How to Print Unique Values in Pandas Dataframe Columns

A quick post representing code sample on how to print unique values in Dataframe columns in Pandas. Here is a data frame comprising of oil prices on different dates which column such as year comprising of repeated/duplicate value of years. In the above data frame, the requirement is to print the unique value of year column. Here is the code for same. Note the method unique()

## Pandas – How to Extract Month & Year from Datetime

This is a quick post representing code sample related to how to extract month & year from datetime column of DataFrame in Pandas. The code sample is shown using the sample data, BrentOilPrices downloaded from this Kaggle data page. Here is the code to load the data frame. Check the data type of the data using the following code: The output looks like the following: Date object Price float64 dtype: object Use the following command to change the date data type from object to datetime and extract the month and year. Printing data using head command would print the following:

## How to Read CSV Files in Google Colab

This post represents a quick code sample in relation to uploading a CSV file from local drive to Google Colab Notebook. Executing the code below will prompt to select a file from the local drive and upload. Once done with the above, all you need to do is execute the following code: In order to test if the file is loaded appropriately, execute the following command:

## Pandas – How to Concatenate Dataframe Columns

Quick code sample on how to concatenate the data frames columns. We will work with example of Boston dataset found with sklearn.datasets. One should note that data frames could be concatenated by rows and columns. In this post, you will learn about how to concatenate data frames by columns. Here is the code for working with Boston datasets. First and foremost, the Boston dataset will be loaded. Once loaded, let’s create different different data frames comprising of data and target variable. This above creates two data frames comprising of data (features) and the values of target variable. Here are the snapshots. Use the following command to concatenate the data frames. …

## Difference between Machine Learning & Traditional Software

In this post, we will understand what are some of the key differences between machine learning models and traditional/conventional software. S.No Traditional Software Machine Learning 1 In traditional software, the primary objective is to meet functional and non-functional requirements. In machine learning models, the primary goal is to optimize the metric (accuracy, precision/recall, RMSE, etc) of the models. Every 0.1 % improvement in the model metrics could result in significant business value creation. 2 The quality of the software primary depends on the quality of the code. The quality of the model depends upon various parameters which are mainly related to the input data and hyperparameters tuning. 3 Traditional software …

## Neural Network Architecture for Text-to-Speech Synthesis

In this post, you would learn about a neural network reference solution architecture which could be used to convert the text to speech. The neural network solution architecture given in this post is based on deep learning (autoencoder network (encoder-decoder) with attention). Neural Network Reference Architecture for Text-to-Speech Synthesis In the solution architecture diagram (figure 1) depicted below, the following is described: Sentences are first converted into character embeddings. Character embeddings are numeric representations of words. Numeric representations of each of the words could be used to create numeric representations of higher-level representations like sentences/paragraphs/documents/etc. Character embeddings are next fed into recurrent sequence-to-sequence feature prediction network with attention. The sequence-to-sequence …

## Reverse Image Search using Deep Learning (CNN)

In this post, you will learn about a solution approach for searching similar images out of numerous images matching an input image (query) using machine learning / deep learning technology. This is also called a reverse image search. The image search is generally searching for images based on keywords. Here are the key components of the solution for reverse image search: A database of storing images with associated numerical vector also called embeddings. A deep learning model based on convolutional neural network (CNN) for creating numerical feature vectors (aka embeddings) for images A module which searches embeddings of an input image (query) from the image database based on the nearest neighbor …

## Why Data Scientists Must Learn Statistics?

In order to understand the need for data scientists to be very good at the statistical concepts, one needs to clearly understand some of the following: Who are data scientists? What is the need for statistics in data scientists’ day-to-day work? Who are Data Scientists? Data Scientists are the primarily Scientists who do experiments to find some of the following: Whether there exists a relationship between data Whether the function approximated (machine learning or statistical learning model) from a given sample of data could be generalized for the entire population In case there are multiple function approximations for predicting outcomes given a set of input, which one of the function approximation …

## When not to use F-Statistics for Multi-linear Regression

In this post, you will learn about the scenario in which you may NOT want to use F-Statistics for doing the hypothesis testing on whether there is a relationship between response and predictor variables in the multilinear regression model. Multilinear regression is a machine learning / statistical learning method which is used to predict the quantitative response variable and also understand/infer the relationship between the response and multiple predictor variables. We will look into the following topics: Background When not to use F-Statistics for Multilinear Regression Model Background F-statistics is used in hypothesis testing for determining whether there is a relationship between response and predictor variables in multilinear regression models. Let’s consider …

## R-Squared Explained for Indian Grandma

In this post, you will learn about the concept of R-Squared in relation to assessing the performance of multilinear regression machine learning model with the help of some real-world examples explained in a simple manner. Background Once we have built a multilinear regression model, the next thing is to find out the model performance. The model performance can be found out by calculating the value of the Residual Standard Error (RSE) or the value of R-Squared. Residual Standard Error can be defined as the difference between the mean value of the prediction made by the model and the population mean value. In this article, we will learn the technique of evaluating …

## Machine Learning – Cloud-native Model Deployments

In this post, we are going to learn about the cloud-native machine learning model deployments. Cloud-native Deployments First and foremost, let’s understand the meaning of cloud-native deployments? If we are building an application or a service and we can deploy this application or the service on any cloud platform without much ado, it could be said as cloud-native deployment. And the way it is made possible is through the container technologies such as Dockers. What basically is required to be done is to wrap the applications or the services within the containers and move the containers images onto the cloud services such as AWS ECS, AWS EKS or Google Kubernetes …

## What, When & Why of Regularization in Machine Learning?

In this post, we will try and understand some of the following in relation to regularizing the regression machine learning models to achieve higher accuracy and stable models: Background What is regularization? Why & when does one need to adopt/apply the regularization technique? Background At times, when one is building a multi-linear regression model, one uses the least squares method for estimating the coefficients of determination or parameters for features. As a result, some of the following happens: Often, the regression model fails to generalize on unseen data. This could happen when the model tries to accommodate for all kind of changes in the data including those belonging to both …

## Unit Tests & Data Coverage for Machine Learning Models

This post represents thoughts on what would it look like planning unit tests for machine learning models. The idea is to perform automated testing of ML models as part of regular builds to check for regression related errors in terms of whether the predictions made by certain set of input data vectors does not match with expected outcomes. This brings up some of the following topics for discussion: Why unit testing for machine learning models? What would unit tests for machine learning models mean? Data coverage or code coverage? Why unit testing for Machine Learning models? Once a model is built, the challenge is to monitor the performance metrics of the models …

## Confusion Matrix Explained with Python Code Examples

In this post, you will learn about the confusion matrix with examples and how it could be used as performance metrics for classification models in machine learning. Let’s take an example of a classification model which is used to predict whether a person would default on a bank loan. To build this classification model, let’s say, a historical data set of 10000 records got chosen for building the model. As part of building the model, all of the 10,000 records got labeled where each record represented a person and got labeled as “Yes” or “No” based on whether they defaulted (Yes) or not defaulted (No). Out of 10,000 labeled records, …