Posts

Linear algebra

Machine learning became available after being able to store and process large amounts of data. To be able to process we need to convert that data into numerical form. Often times we have tabular structures which is converted into matrices. For higher dimensional problems we could have tensors or 4d tensors. Then, in order to process that information we need to rely on operations on matrices. Thus we will utilize linear algebra. The linear regression formulation we have mentioned uses weighted sum of input features. Let us remind that these features are the rows of the data table converted into numerical form. This weighted sum is inner product of two vectors could be written as : w = [w1, w2, ...] x = [x1, x2, ...] s = w1*x1 + w2*x2 ... The dot product of two vectors is a scalar. If vectors are normalized the result would be cosine similarity. Now, this is model of single neuron in neural networks. It gives single value output for single input vector. If we have multiple dimens...

A small demo to play for least squares regression models

lesson.land/mldeploy

Lets start coding for linear regression

As from previous post, linear regression has analytical solution. For a given dataset the optimization problem reduces to linear algebra psudeo-inverse problem.  ``` W = (XX')^-1XY``` This would be the training step for the algorithm. Python code would be very easy.  np.linalg.inv(X.dot(X.T)).dot(X).dot(Y) Later once the parameters W is defined runtime would be a single matrix multiplication as our linear model. Y' = WX  Could be written as  Y_est = W.dot(X)

Least Squares Regression

This is one of the favorite topics for people to start machine learning. It has roots more than a century. The basic problem of finding the rule behind a process lead people to think about how to create a rule from scientific measurements. Offcourse, linear relationships are the most intuitive ones. If you buy one apple it is 1$ if you buy 10 it is 10$. The fomulation in this case would be y=wx for single variable. Hoever, machine learning is reverse of the process we are not trying to find y or total amount in previous example instead we would like to find w from data. Lets extend on this apples example. If we have data like this 10 apples -> 9$ 8 apples -> 8$ 2 apples -> 3$ What would be your guess of w (unit price) if you assume linear relationship ? Least square estimate is a learning mechanism by optimizing squared discripancies between model and data. So lets formulate like this argmin_w \sum (wx-y_true)^2 In most minimization problems you tak...

When to do machine learning

I realized that before starting on technical details of methods I should write some about when to use machine learning, or when it is intelligent to use artificial intelligence ? In fact, in most of the cases avoid machine learning as much as possible. In first place, you use machine learning when your measurements, sensor values, data is not sufficiently descriptive to get final result that you are looking for. For example, covid tests works with very high precision currently. If your input is the result of the test you don't need machine learning. However, if you are detecting covid from chest x-ray you have many small tiny pixel transparancy measurements thus you need some kind of learning. In this case, you should ask while the alternative way is providing good quality result do we really need this learning ? In summary you should try to get descriptive data as possible in the first place. Later, if you have only small amount of samples, the best you can do is use them as te...

Basics

Lets start with some of the basics. What is the simplest form of machine learning ? If you consider machine learning as utilizing previous data to predict future outcomes then taking average is one of the simplest ways. For example, if you predict the todays temprature from the historical temprature data of same day you will get a reasonable estimate. Don't underestimate this the theories of law of large numbers and central limit is very powerful especially if you don't have additional variables to explain the data. However, often we have explonotary variables. In machine learning nomeclature we call them features. In this setting, each feature lies in euclidean vector space and a function maps these features to target variable. Now the task is finding that function. Of course, you can just construct lookup table for input output pairs from previous data. If you don't have much variation from cases in runtime vs previous data this will do the job. But the real problem of ...

Welcome to MLDeploy

Machine learning has changed numerous applications and would continue to change with more availability of data. Once you look at the literature, you can find many different documents describing algorithms. However, one aspect that I feel needs a more comprehensive overview is the deployment of those algorithms. In this blog channel, I would like to go over alternatives for the deployment methods. Let me name a few: REST API backends Desktop applications Edge devices Mobile deployment Script Executables Web front ends No deployment There are many pros and cons for each method in terms of latency and resource usage. We will be discussing them in more detail.