Posts

Showing posts with the label machine learning

Missing Values in Data Science Interview

If an interviewer shows you a sample dataset and asks you to tell what comes to your mind, he likely wants to ask you about MISSING VALUES in the dataset. So, check if the dataset has any missing values and answer him accordingly. The next thing the interviewer will ask you will likely be about strategies for dealing with those missing values. So, be prepared. 4 Strategies to Deal with Missing Values in a Dataset: Drop all columns with missing values (wastes a lot of valuable data, so NOT recommended) Drop all rows with missing values (if there are only a few no of rows with missing values, then you can do this) Imputation: You basically fill the missing value with some default value (like -1) or some calculated value (like mean). This is the most used strategy. Imputation with tracking: Basically, you use imputation on a column, and then you create a new column to keep track of the rows where you have applied imputation. The new column will be either TRUE or FALSE based on whether you...

ML vs. DL : What exactly is deep learning?

Image
 To settle the debate once and for all, in this article I will talk about deep learning and how it is different and/or similar to machine learning. I will start off with machine learning and then connect it to deep learning, eventually establishing how deep learning is a subset of machine learning.  Machine learning : where it all starts As you might know already, machine learning or ML is giving machines ability to learn like human beings and for this it uses multiple types of algorithms which are mentioned as follows: Linear based (regression etc.) Tree based (decision tree, random forest, xgboost, catboost, etc.) Neural Network based (ANN, CNN, perceptron, etc) kNN, etc. Diagrammatically, it can be shown as follows:  Machine learning: various algorithms Machine learning via Neural Network Now, out of all these various types of algorithms, consider the one using neural networks. This one can further be divided into 2 categories:  Simple neural networks: meaning the...

Types of learning in machine learning explained

Image
 Learning in the domain of machine learning is predominantly seen as in 4 buckets or types. Yes, there are 4 types of learning and in this article I will go through each one in a brief manner. For starters, the types of learning are: Supervised Learning Unsupervised Learning Semi supervised Learning Reinforcement Learning Supervised Learning Explanation Supervised learning basically deals with labelled data. For example, let us say you have a flower species dataset in which you have flower characteristics (or features) like length of petal, length of sepal, width of petal and width of sepal and then you have an associated label (or target) which is the species of the flower. (This dataset can be found here .)  The main point here is that the data is in the form of (X,y) where X is the set of input features (petal length, sepal length, petal width and sepal width) and y is the target which is flower species in this case.  In supervised learning, the target is known for the...

Learning systems : basic algorithm in Machine Learning design

  Aspects of developing a learning system In the previous blog posts, I have already talked about the meaning of the term "learning" in machine learning. Go check out that blog ( here! ) if you have not read it already as it is a prerequisite for this one. This post will talk about how that "learning" is learned by machine learning systems and I will try to explain the basic algorithm that is followed in this process and the various aspects involved in the learning process. Algorithm to design a learning system in ML workflow The basic algorithm followed by an explanation is as follows: Choosing the training experience. Choosing the target function. Choosing the target function's representation. Choosing the learning or function approximation algorithm to infer the target function. Explanation Choosing the training experience The training experience can be thought of as the training data. Basically, you need to have training data which the learning system will l...

Modern day applications of machine learning

 Following are some of the the applications of machine learning in various domains that I have come across : Advertising Advertising or advertisement forms one of the major business models in the world presently. Most of the modern day businesses, be it social media sites or writing apps, all earn and sustain themselves through advertising content to their users based on relevancy (or maybe not! ha-ha). As such, it is obvious that machine learning finds its use in this domain in multiple forms: Predicting click rate ML is used in predicting the number or percentage of viewers who will actually click on an ad displayed to them. Recommending appropriate ads  ML is used in recommending appropriate ads to users based on their interests and activity. Read recommendation engines to understand how it is actually done. Medicine and healthcare Medicine and healthcare forms one of the most important sectors of any place. As such whatever improves its quality needs to be invested in as s...

ML technical definition : Learning in AI defined

Image
Now that you have dived deep into the waters of machine learning, you might be interested in knowing how to define it. But before you can define machine learning, you need to learn what "learning" is. So, what is "learning" in Machine Learning? Learning in ML and AI  How do human beings learn? They improve with their experiences. Right!. This is exactly what learning is. But how would you define it, then? Learning can be defined as the ability to improve with experience. In terms of AI and ML, it means making computer programs and systems which automatically improve with experience like human beings do. Experience can be thought of as "data". In ML, we try to build models which learn from data to perform some task like decision-making, prediction, etc. But this seems like an informal definition of ML. Right! How would you define it formally? Definition of ML The present standard definition of machine learning is given by Tom Mitchell, as follows:  A comput...

ML benefits

Image
ML and AI: Benefits The first question that comes to mind whenever starting to learn something new is " Why ?". It is no different for Machine Learning (ML) and Artificial Intelligence (AI). Why should you learn ML and AI? What are the benefits of learning ML and AI ? Is there any use to learning ML and AI? What do ML and AI offer that make them so special? Here I will try to answer these questions regarding the benefits of machine learning and artificial intelligence. Feel free to skip to the summary at the end if you need direct points. So, why should you learn ML and AI? Is it simply because they are popular and everybody's doing them, so you should also do them?  No.  So, what is the reason? Explanation ML is a subset of AI (Artificial Intelligence) and the whole point is that you are trying to give computers human-like intelligence. Why do you want to do this? One reason could be curiosity and another is reducing human effort. Just think about it. If computers could ...

Conventional Algorithms vs. ML algorithms

Image
 Starting on the journey of Machine Learning and Data Science, one of the most common thoughts that come to the mind is the difference between machine learning algorithms and conventional/traditional algorithms.  Are ML algorithms any different to the traditional ones we use? If so, how are ML algorithms different from the conventional ones? The answer is rather simple. Yes, ML algorithms are indeed different from the traditional algorithms. Traditional algorithms like searching, sorting, etc., follow a similar format. They typically take an input, follow some steps as per the algorithm and then give an output. The output is rather deterministic meaning that for a single unique input you will get the same output every time. For example, if you input a sequence to some sorting algorithm, it will return the same sorted output sequence no matter how many times you run it. On the other hand, ML algorithms don't follow this traditional format. They generally require to be fed both ...

Why is Machine Learning and AI so popular these days?

Machine learning (ML) and Artificial Intelligence (AI) seem to be the latest buzzwords in the market today. Everybody wants to advertise their enterprise as an AI enterprise and everybody gets impressed if it is actually so. So what is it that has made these terms so popular? Following are a few reasons that I believe to be the reasons for this fame: Access to technology:  In modern times, the access to technology and internet is unbelievable. More people have access to computer systems and internet than ever before. As such, it becomes natural for coding related domains (including ML and AI) to flourish. Availability of online resources to learn:  I mean, this comes as an obvious point. Presently, all kinds of courses are available on platforms like YouTube free of cost for anyone willing to learn. Also there are MOOC's offered by various universities online which has democratized education in an unbelievable way. Availability of data (or Big Data):  Data is available ra...

Multicollinearity

 M ulticollinearity simply means that there is high correlation amongst some of the predictor variables in a multiple regression model, meaning that one or more of these predictor variables can be accurately predicted (linearly) from some other predictor variable. How to deal with it? You can use decision tree based models (boosted or simple) as they are by nature immune to multicollinearity (as out of let's say 2 highly correlated features, it will use only one at any split). However, it is still good to remove any redundant features during the preprocessing phase. How to remove redundant features? One possible way could be to use the correlation value between the predictor variables and the target to flush out the less contributing features. You can easily find a function that will compute these correlation values for you for each feature and then you can set a threshold to accept the features for training your final model. Is it necessary to deal with it? Most people use tree b...

Hyperparameter Tuning

 Hyperparameter tuning is a process to find the optimal hyperparameters for an ML algorithm. The simplest manual strategy is as follows: Divide the training set into 2 parts: train_set and val_set. Set initial hyperparameters. Train your model with the train_set and evaluate on the val_set with some metric ( accuracy, AUC, etc). Change your hyperparameter values and repeat step 3. Do this for a couple of times Choose those hyperparameter values which gave the best metric value and retrain the model on the entire training set with these chosen values. Hyperparameter tuning is a very important step. You can have the best algorithms and the best data, but to get to the point of best output, you inevitable need to tune your hyperparameters. These days there are a lot of automated libraries for hyperparameter tuning as well where you don't have to lay a finger and the library will get you the optimal values. However for starters, it is best to try this manually. Later, you can switch to...

Batch Gradient Descent vs Stochastic Gradient Descent (SGD) vs Mini-Batch Gradient Descent

Image
 In this article, we will explore the basic difference between Batch Gradient Descent, Stochastic Gradient Descent (SGD) and Mini-Batch Gradient Descent.  But first let us understand what an epoch means. Meaning of the word "epoch" In Deep Learning, an epoch is one iteration over the entire sample space (training set). In other words, everytime you go over each sample of the training set, it is considered one epoch. Basic Deep Learning training process Initialize model parameters: weights and biases with some random value. Go over objects of training set. Adjust your model parameters : weights and biases w.r.t some cost/loss fuction. Repeat from step 2 till desired threshold is reached. Batch Gradient Descent or simple Gradient Descent In Batch Gradient Descent, in each epoch we go throught entire training set and then adjust parameters. In every epoch, parameters are adjusted once which makes it unsuitable for large datasets. Stochastic Gradient Descent (SGD) In Stochast...