Machine learning is the science of teaching the computer to do certain tasks, where instead of hardcoding it, we give it the data that contains what we want to achieve, and its job is to learn from such data to find the patterns that map what we want to achieve and provided data.
These patterns or (learned) rules can be used to make predictions on unseen data.
A machine learning model is nothing other than a mathematical function whose coefficient and intercept hold the best (or learned) values representing the provided data & what we want to achieve.
In ML terms, coefficients are weights, intercepts are biases.
Take an example for a simple straight line equation:
y = aX + b
y is the label
X is the input data
a is weight/coefficient
b is bias/intercept
So basically,
If you have a set of values X and y, and you are asked to use those values to find `a` and `b`,
you would crunch numbers until you find them as long as you know you are dealing with a line equation.
Let's say that the below table is X and y.
Would you find the relationship between X and y?
If you can be able to find such a relationship, you can get the corresponding value of 9 easily.
Say you are able to find that y = 2X + 1 from the above table. You can use this equation to find any value of y given X.
Finding the value of 9 would be the very straight thing.
y = 9*2 + 1 = 19
That is fairly easy to calculate and you would not need machine learning.
But let's forget that for a minute, and use machine learning to find a model that we can use to predict y given 9.
About tooling, for problem like that, we can use Scikit-Learn, a classical ML framework that is well designed.
We can also use NumPy to represent our data as an array of values.
And Matplotlib for plotting the line. It's always good to plot the data that you are working with.
The thing called Linear regression above (imported from sklearn) is a type of machine learning model that is used for linear datasets (ideally),
but primarily, it is used when we want to predict a single continuous value.
A linear model is the best fit for our data because our data seems to be linear.
A meaning of linearity: Change in the input data(X) is directly proportional to change in output (y).
P.S there are more complex models suited for non-linear datasets like support vector machines.
So, now it's time to build our model and train or teach it on our input data X and output label y.
The whole goal of training a machine learning model is to find the best values of weight (a) and bias (b).
It's simple as we are not reinventing the wheel.
The nice thing about having good data (technically, good data has a predictive power) and a relevant model, is that you do not need to tweak a lot of things.
In addition to that, Linear Regression doesn't have things to tweaks (hyperparameters)
To remove the confusion of a newly introduced term called hyperparameters, we got to understand parameters first.
Parameters are model values (weight and biases), and hyperparameters are set of values that engineer has to set or change to get good results.
We can change the hyperparameters, but we do not change parameters. As we train, the model learns the best values of parameters (weight & bias).
So, now having a model, the next thing would be to predict the value of y given 9. That's the initial question.
Perfect, you see it's 100% correct. y(9.0) = 19.0
If you wanted to access the model parameters, or weight and bias, you can get them too.
And remember, in equation y = aX + b, a is the weight or coefficient of the equation, and b is the bias or intercept.
Looking at the below image, these values of weight and bias are ☑☑
This was a simple thing to do, but I find it good to start simple when explaining a hard topic.
Plus it can motivate you to do more. I was personally motivated by these simple things in my early days of doing machine learning.
This is the end of the thread.
Initially, I wasn't planning a thread but then thought that extending it would perhaps be helpful to anyone who still wonders what machine learning really is.
Thank you for reading.
You can follow @Jeande_d for more simple posts like this.
P.S. One of my 2021's goals was to do something tangible for the ML community. I found that it would be cool to make well-structured content/curriculum.
It's close and I will share detail soon
• • •
Missing some Tweet in this thread? You can try to
force a refresh
Neural networks are hard to train. The more they go deeper, the more they are likely to suffer from unstable gradients.
Gradients can either explode or vanish, and either of those can cause the network to give poor results.
A short thread on the neuralnets training issues
The vanishing gradients problem results in the network taking too long to train(learning will be very slow), and the exploding gradients cause the gradients to be very large.
Although those problems are nearly inevitable, the choice of activation function can reduce their effects.
Using ReLU activation in the first layers can help avoid vanishing gradients.
Careful weight initialization can also help, but ReLU is by far the good fix.
Getting started with machine learning can be hard.
We are fortunate to have many & freely available learning resources, but most of them won't help because they skip the fundamentals or start with moonshots.
This is a thread on learning machine learning & structured resources.
1. Get excited first
The first step to learning a hard topic is to get excited.
Machine learning is a demanding field and it will take time to start understanding concepts & connecting things.
If you find it hard to understand what ML really is,
@lmoroney I/O 19 talk will get you excited. He introduces what machine learning really is from a programming perspective.