What is Machine Learning?
Machine LearningĀ involves the use of Artificial Intelligence to enable machines to learn a task from experience without programming them specifically about that task. (In short, Machines learn automatically without human hand holding!!!) This process starts with feeding them good quality data and then training the machines by building various machine learning models using the data and different algorithms. The choice of algorithms depends on what type of data do we have and what kind of task we are trying to automate.
How to start learning ML?
This is a rough roadmap you can follow on your way to becoming an insanely talented Machine Learning Engineer. Of course, you can always modify the steps according to your needs to reach your desired end-goal!
Step 1 ā Understand the Prerequisites
In case you are a genius, you could start ML directly but normally, there are some prerequisites that you need to know which include Linear Algebra, Multivariate Calculus, Statistics, and Python. And if you donāt know these, never fear! You donāt need a Ph.D. degree in these topics to get started but you do need a basic understanding.
(a) Learn Linear Algebra and Multivariate Calculus
Both Linear Algebra and Multivariate Calculus are important in Machine Learning. However, the extent to which you need them depends on your role as a data scientist. If you are more focused on application heavy machine learning, then you will not be that heavily focused on maths as there are many common libraries available. But if you want to focus on R&D in Machine Learning, then mastery of Linear Algebra and Multivariate Calculus is very important as you will have to implement many ML algorithms from scratch.
(b) Learn Statistics
Data plays a huge role in Machine Learning. In fact, around 80% of your time as an ML expert will be spent collecting and cleaning data. And statistics is a field that handles the collection, analysis, and presentation of data. So it is no surprise that you need to learn it!!!
Some of the key concepts in statistics that are important are Statistical Significance, Probability Distributions, Hypothesis Testing, Regression, etc. Also, Bayesian Thinking is also a very important part of ML which deals with various concepts like Conditional Probability, Priors, and Posteriors, Maximum Likelihood, etc.
(c) Learn Python
Some people prefer to skip Linear Algebra, Multivariate Calculus and Statistics and learn them as they go along with trial and error. But the one thing that you absolutely cannot skip isĀ Python! While there are other languages you can use for Machine Learning like R, Scala, etc. Python is currently the most popular language for ML. In fact, there are many Python libraries that are specifically useful for Artificial Intelligence and Machine Learning such asĀ Keras,Ā TensorFlow,Ā Scikit-learn, etc.
So if you want to learn ML, itās best if you learn Python! You can do that using various online resources and courses such asĀ Fork PythonĀ available Free on GeeksforGeeks.
Step 2 ā Learn Various ML Concepts
Now that you are done with the prerequisites, you can move on to actually learning ML (Which is the fun part!!!) Itās best to start with the basics and then move on to the more complicated stuff. Some of the basic concepts in ML are:
(a) Terminologies of Machine Learning
- Model āĀ A model is a specific representation learned from data by applying some machine learning algorithm. A model is also called a hypothesis.
- Feature āĀ A feature is an individual measurable property of the data. A set of numeric features can be conveniently described by a feature vector. Feature vectors are fed as input to the model. For example, in order to predict a fruit, there may be features like color, smell, taste, etc.
- Target (Label) āĀ A target variable or label is the value to be predicted by our model. For the fruit example discussed in the feature section, the label with each set of input would be the name of the fruit like apple, orange, banana, etc.
- Training āĀ The idea is to give a set of inputs(features) and itās expected outputs(labels), so after training, we will have a model (hypothesis) that will then map new data to one of the categories trained on.
- Prediction āĀ Once our model is ready, it can be fed a set of inputs to which it will provide a predicted output(label).
(b) Types of Machine Learning
- Supervised Learning āĀ This involves learning from a training dataset with labeled data using classification and regression models. This learning process continues until the required level of performance is achieved.
- Unsupervised Learning āĀ This involves using unlabelled data and then finding the underlying structure in the data in order to learn more and more about the data itself using factor and cluster analysis models.
- Semi-supervised Learning āĀ This involves using unlabelled data like Unsupervised Learning with a small amount of labeled data. Using labeled data vastly increases the learning accuracy and is also more cost-effective than Supervised Learning.
- Reinforcement Learning āĀ This involves learning optimal actions through trial and error. So the next action is decided by learning behaviors that are based on the current state and that will maximize the reward in the future.
(c) How to Practise Machine Learning?
- The most time-consuming part in ML is actuallyĀ data collection, integration, cleaning, and preprocessing.Ā So make sure to practice with this because you need high-quality data but large amounts of data are often dirty. So this is where most of your time will go!!!
- Learn various models and practice on real datasets.Ā This will help you in creating your intuition around which types of models are appropriate in different situations.
- Along with these steps, it is equally important toĀ understand how to interpret the results obtained by using different models.Ā This is easier to do if you understand various tuning parameters and regularization methods applied on different models.
(d) Resources for Learning Machine Learning:
There are various online and offline resources (both free and paid!) that can be used to learn Machine Learning. Some of these are provided here:
- For a broad introduction to Machine Learning, StanfordāsĀ Machine Learning CourseĀ by Andrew Ng is quite popular. It focuses on machine learning, data mining, and statistical pattern recognition with explanation videos are very helpful in clearing up the theory and core concepts behind ML.
- If you want a self-study guide to Machine Learning, thenĀ Machine Learning Crash CourseĀ from Google is good for you as it will provide you an introduction to machine learning with video lectures, real-world case studies, and hands-on practice exercises.
- In case you prefer an offline course, the GeeksforgeeksĀ Machine Learning FoundationĀ course will be ideal for you. This course will teach you about various concepts of Machine Learning and also practical experience in implementing them in a classroom environment.
Step 3 ā Take part in Competitions
After you have understood the basics of Machine Learning, you can move on to the crazy part!!! Competitions! These will basically make you even more proficient in ML by combining your mostly theoretical knowledge with practical implementation. Some of the basic competitions that you can start with onĀ KaggleĀ that will help you build confidence are given here:
- Titanic: Machine Learning from Disaster:Ā TheĀ Titanic: Machine Learning from DisasterĀ challenge is a very popular beginner project for ML as it has multiple tutorials available. So it is a great introduction to ML concepts like data exploration, feature engineering, and model tuning.
- Digit Recognizer:Ā TheĀ Digit RecognizerĀ is a project after you have some knowledge of Python and ML basics. It is a great introduction into the exciting world neural networks using a classic dataset which includes pre-extracted features.
After you have completed these competitions and other such simple challenges ā¦Congratulations!!! You are well on your way to becoming a full-fledged Machine Learning Engineer and you can continue enhancing your skills by working on more and more challenges and eventually creating more and more creative and difficult Machine Learning projects.
ML | What is Machine Learning ?
Arthur Samuel, a pioneer in the field of artificial intelligence and computer gaming, coined the termĀ āMachine Learningā. He defined machine learning as āĀ āField of study that gives computers the capability to learn without being explicitly programmedā.
In a very layman manner, Machine Learning(ML) can be explained as automating and improving the learning process of computers based on their experiences without being actually programmed i.e. without any human assistance. The process starts with feeding good quality data and then training our machines(computers) by building machine learning models using the data and different algorithms. The choice of algorithms depends on what type of data do we have and what kind of task we are trying to automate.
Example: Training of students during exam.
While preparing for the exams students donāt actually cram the subject but try to learn it with complete understanding. Before the examination, they feed their machine(brain) with a good amount of high-quality data (questions and answers from different books or teachers notes or online video lectures). Actually, they are training their brain with input as well as output i.e. what kind of approach or logic do they have to solve a different kind of questions. Each time they solve practice test papers and find the performance (accuracy /score) by comparing answers with answer key given, Gradually, the performance keeps on increasing, gaining more confidence with the adopted approach. Thatās how actually models are built, train machine with data (both inputs and outputs are given to model) and when the time comes test on data (with input only) and achieves our model scores by comparing its answer with the actual output which has not been fed while training. Researchers are working with assiduous efforts to improve algorithms, techniques so that these models perform even much better
.
Basic Difference in ML and Traditional Programming?
- Traditional Programming :Ā We feed in DATA (Input) + PROGRAM (logic), run it on machine and get output.
- Machine Learning :Ā We feed in DATA(Input) + Output, run it on machine during training and the machine creates its own program(logic), which can be evaluated while testing.
What does exactly learning means for a computer?
A computer is said to be learning fromĀ ExperiencesĀ with respect to some class ofĀ Tasks, if its performance in a given Task improves with the Experience.
A computer program is said to learn from experienceĀ EĀ with respect to some class of tasksĀ TĀ and performance measureĀ P, if its performance at tasks inĀ T, as measured byĀ P, improves with experienceĀ E
Example:Ā playing checkers.
EĀ = the experience of playing many games of checkers
TĀ = the task of playing checkers.
PĀ = the probability that the program will win the next game
In general, any machine learning problem can be assigned to one of two broad classifications:
Supervised learning and Unsupervised learning.
How things work in reality:-
-
- Talking about online shopping, there are millions of users with an unlimited range of interests with respect to brands, colors, price range and many more. While online shopping, buyers tend to search for a number of products. Now, searching a product frequently will make buyerās Facebook, web pages, search engine or that online store start recommending or showing offers on that particular product. There is no one sitting over there to code such task for each and every user, all this task is completely automatic. Here, ML plays its role. Researchers, data scientists, machine learners build models on the machine using good quality and a huge amount of data and now their machine is automatically performing and even improving with more and more experience and time.
Traditionally, the advertisement was only done using newspapers, magazines and radio but now technology has made us smart enough to doĀ Targeted advertisementĀ (online ad system) which is a way more efficient method to target most receptive audience.
- Talking about online shopping, there are millions of users with an unlimited range of interests with respect to brands, colors, price range and many more. While online shopping, buyers tend to search for a number of products. Now, searching a product frequently will make buyerās Facebook, web pages, search engine or that online store start recommending or showing offers on that particular product. There is no one sitting over there to code such task for each and every user, all this task is completely automatic. Here, ML plays its role. Researchers, data scientists, machine learners build models on the machine using good quality and a huge amount of data and now their machine is automatically performing and even improving with more and more experience and time.
-
- Even in health care also, ML is doing a fabulous job. Researchers and scientists have prepared models to train machines forĀ detecting cancerĀ just by looking at slide ā cell images. For humans to perform this task it would have taken a lot of time. But now, no more delay, machines predict the chances of having or not having cancer with some accuracy and doctors just have to give an assurance call, thatās it. The answer to ā how is this possible is very simple -all that is required, is, high computation machine, a large amount of good quality image data, ML model with good algorithms to achieve state-of-the-art results.
Doctors are using ML even toĀ diagnose patientsĀ based on different parameters under consideration.
- Even in health care also, ML is doing a fabulous job. Researchers and scientists have prepared models to train machines forĀ detecting cancerĀ just by looking at slide ā cell images. For humans to perform this task it would have taken a lot of time. But now, no more delay, machines predict the chances of having or not having cancer with some accuracy and doctors just have to give an assurance call, thatās it. The answer to ā how is this possible is very simple -all that is required, is, high computation machine, a large amount of good quality image data, ML model with good algorithms to achieve state-of-the-art results.
- You all might have useĀ IMDB ratings,Ā Google PhotosĀ where it recognizes faces,Ā Google LensĀ where the ML image-text recognition model can extract text from the images you feed in,Ā GmailĀ which categories E-mail as social, promotion, updates or forum using text classification,which is a part of ML.
How ML works?
-
- Gathering past data in any form suitable for processing.The better the quality of data, the more suitable it will be for modeling
- Data Processing ā Sometimes, the data collected is in the raw form and it needs to be pre-processed.
Example: Some tuples may have missing values for certain attributes, an, in this case, it has to be filled with suitable values in order to perform machine learning or any form of data mining.
Missing values for numerical attributes such as the price of the house may be replaced with the mean value of the attribute whereas missing values for categorical attributes may be replaced with the attribute with the highest mode. This invariably depends on the types of filters we use. If data is in the form of text or images then converting it to numerical form will be required, be it a list or array or matrix. Simply, Data is to be made relevant and consistent. It is to be converted into a format understandable by the machine - Divide the input data into training,cross-validation and test sets. The ratio between the respective sets must be 6:2:2
- Building models with suitable algorithms and techniques on the training set.
- Testing our conceptualized model with data which was not fed to the model at the time of training and evaluating its performance using metrics such as F1 score, precision and recall.
Pre-requisites to learn ML:
-
- Linear Algebra
- Statistics and Probability
- Calculus
- Graph theory
- Programming Skills ā Language such as Python, R, MATLAB, C++ or Octave
Artificial intelligence vs Machine Learning vs Deep Learning
Nowadays many misconceptions are there related to the wordsĀ machine learning,Ā deep learningĀ andĀ artificial intelligence(AI), most of the people think all these things are same whenever they hear the word AI, they directly relate that word to machine learning or vice versa, well yes, these things are related to each other but not the same. Letās see how.
Machine Learning:
Before talking about machine learning lets talk about another concept that is called data mining. Data mining is a technique of examining a large pre-existing database and extracting new information from that database, itās easy to understand, right, machine learning does the same, in fact, machine learning is a type of data mining technique.
Hereās is a basic definition of machine learning ā
āMachine Learning is a technique of parsing data, learn from that data and then apply what they have learned to make an informed decisionā
Now a days many of big companies use machine learning to give there users a better experience, some of the examples are, Amazon using machine learning to give better product choice recommendations to there costumers based on their preferences, Netflix uses machine learning to give better suggestions to their users of the Tv series or movie or shows that they would like to watch.
Deep Learning:
Deep learning is actually a subset of machine learning. It technically is machine learning and functions in the same way but it has different capabilities.
The main difference between deep and machine learning is, machine learning models become better progressively but the model still needs some guidance. If a machine learning model returns an inaccurate prediction then the programmer needs to fix that problem explicitly but in the case of deep learning, the model does it by himself. Automatic car driving system is a good example of deep learning.
Letās take an example to understand both machine learning and deep learning ā
Suppose we have a flashlight and we teach a machine learning model that whenever someone says ādarkā the flashlight should be on, now the machine learning model will analyse different phrases said by people and it will search for the word ādarkā and as the word comes the flashlight will be on but what if someone said āI am not able to see anything the light is very dimā, here the user wants the flashlight to be on but the sentence does not the consist the word ādarkā so the flashlight will not be on. Thatās where deep learning is different from machine learning. If it were a deep learning model it would on the flashlight, a deep learning model is able to learn from its own method of computing.
Artificial intelligence:
Now if we talk about AI, it is completely a different thing from Machine learning and deep learning, actually deep learning and machine learning both are the subsets of AI. There is no fixed definition for AI, you will find a different definition everywhere, but here is a definition that will give you idea of what exactly AI is.
āAI is a ability of computer program to function like a human brainĀ ā
AI means to actually replicate a human brain, the way a human brain thinks, works and functions. The truth is we are not able to establish a proper AI till now but we are very close to establish it, one of the examples of AI isĀ Sophia, the most advanced AI model present today. The reason we are not able to establish proper AI till now is, we donāt know the many aspects of the human brain till now likeĀ why do we dream ?Ā etc.
Why people relate machine learning and deep learning with artificial intelligence?
Machine learning and deep learning is a way of achieving AI, which means by the use of machine learning and deep learning we may able to achieve AI in future but it is not AI.
Creating a simple machine learning model
Create a Linear Regression Model in Python using a randomly created data set.
Linear Regression Model
Linear regression geeks for geeks
Generating the Training Set
play_arrow
brightness_4
# python library to generate random numbers from random import randint Ā # the limit within which random numbers are generated TRAIN_SET_LIMIT = 1000 Ā # to create exactly 100 data items TRAIN_SET_COUNT = 100 Ā # list that contains input and corresponding output TRAIN_INPUT = list () TRAIN_OUTPUT = list () Ā # loop to create 100 dataĀ items with three columns each for i in range (TRAIN_SET_COUNT): Ā Ā Ā Ā a = randint( 0 , TRAIN_SET_LIMIT) Ā Ā Ā Ā b = randint( 0 , TRAIN_SET_LIMIT) Ā Ā Ā Ā c = randint( 0 , TRAIN_SET_LIMIT) Ā # creating the output for each data item Ā Ā Ā Ā op = a + ( 2 * b) + ( 3 * c) Ā Ā Ā Ā TRAIN_INPUT.append([a, b, c]) Ā # adding each output to output list Ā Ā Ā Ā TRAIN_OUTPUT.append(op) |
Machine Learning Model ā Linear Regression
The Model can be created in two steps:-
1.Ā TrainingĀ the model with Training Data
2.Ā TestingĀ the model with Test Data
Training the Model
The data that was created using the above code is used to train the model
play_arrow
brightness_4
# Sk-Learn contains the linear regression model from sklearn.linear_model import LinearRegression Ā # Initialize the linear regression model predictor = LinearRegression(n_jobs = - 1 ) Ā # Fill the Model with the Data predictor.fit(X = TRAIN_INPUT, y = TRAIN_OUTPUT) |
Testing the Data
The testing is done Manually. Testing can be done using some random data and testing if the model gives the correct result for the input data.
play_arrow
brightness_4
# Random Test data X_TEST = [[ 10, 20, 30 ]] Ā # Predict the result of X_TEST which holds testing data outcome = predictor.predict(X = X_TEST) Ā # Predict the coefficients coefficients = predictor.coef_ Ā # Print the result obtained for the test data print( 'Outcome : {}\nCoefficients : {}' .format(outcome, coefficients)) |
The Outcome of the above provided test-data should be,Ā 10 + 20*2 + 30*3 = 140.
Output
Outcome : [ 140.] Coefficients : [ 1. 2. 3.]