# Minimal example - part 2

/ / درس 2

### توضیح مختصر

• زمان مطالعه 0 دقیقه
• سطح خیلی سخت

### دانلود اپلیکیشن «زوم»

این درس را می‌توانید به بهترین شکل و با امکانات عالی در اپلیکیشن «زوم» بخوانید ### متن انگلیسی درس

Let’s start this lesson by generating the data we will train on this step is not part of the machine

learning algorithm.

Essentially we will create big data with a linear relationship.

Once again we will do that to prove the methodology is working.

Feel free to move on to the next lecture if you’d like in real life.

We would normally load the data from some external source but that’s a topic we’ll deal with starting

from our next section.

All right.

If you are still here we can generate the data.

First I will declare a variable called observations.

This variable will contain the size of the dataset we want to generate.

Let’s work with 1000 observations.

You can do the same with 100000 or 10 million numbers if you’d like.

This choice will affect the speed of the algorithm.

When we are done with this example you can play around with the number of observations.

Try one thousand and then one hundred thousand and even 10 million.

Be careful as 10 million observations may cause computers to freeze alright.

We are about to create a two variable linear model and the two variables will be called X and Z.

Let’s work on the inputs we will use the PI method random uniform.

It draws a random value from a specified interval where each number has an equal chance of being selected

this method requires three arguments.

The lowest point of the interval.

The highest point of the interval and XYZ The size is actually the shape in which we want to generate

the data.

Let’s choose an interval from minus 10 to 10.

It doesn’t matter.

Once again you can play around with these numbers for homework according to our theory the appropriate

size is the number of observations by the number of variables.

So observations by one as we are only talking about one variable x will generate the Z’s in the same

manner.

So these are the two input variables we will feed to the algorithm Let’s combine them in one matrix

called inputs as theories suggested the inputs matrix will be of shape the number of observations by

the number of variables or 1000 by two

the appropriate method to use is N.P.

column Steck.

It literally stacks the observations into a matrix.

This results in a matrix with dimensions one thousand by two dimensionality is very important in linear

algebra.

We can only multiply major C’s that are compatible.

We want to make sure we can multiply X times w.

Since our linear model relies on that.

In these lectures I will print the shape of each variable using the shape method to make sure we are

working properly.

The appropriate Python method is the object in question dot shape as expected input is a matrix of size

1000 by two.

So we have worked properly

OK in supervised learning.

We must know two major parameters inputs and targets will also have to generate targets.

The weights and the biases are varied through the algorithm and the outputs are the result from the

model employed.

We’ll leave them to the computer OK since we have only seen the linear model.

We will do that in a linear model friendly way so say our targets will be defined by a function f of

x and z which is equal to 2 times X minus 3 times Z plus 5 plus some noise.

Conceptually the algorithm must learn.

This is the function the weights are two and minus three.

And the bias is 5.

That’s the correct result if we don’t get that at the end we haven’t worked properly.

You may be wondering about the noise it is introduced to randomize our data a bit.

Real data always contains noise.

It’s never perfect.

Introducing some small noise will make the data a bit random.

Yet the underlying linear relationship will be retained.

Let’s declare the noise variable using the random uniform method.

Once again I’ll constrain it from minus 1 to plus 1 and its size will match the size of the X’s and

Z’s.

OK the target values will be given according to the function we wanted.

The proper line of code is.

Targets equals two times the axes.

Mine minus three times the Z’s plus five.

Plus the noise the targets are a linear combination of two vectors 1000 by 1 a scalar and noise 1000

by one.

Their shape should be 1000 by one.

Let’s check that cool.

We have our inputs and the desired targets.

It is time to create the algorithm.

### مشارکت کنندگان در این صفحه

تا کنون فردی در بازسازی این صفحه مشارکت نداشته است.

🖊 شما نیز می‌توانید برای مشارکت در ترجمه‌ی این صفحه یا اصلاح متن انگلیسی، به این لینک مراجعه بفرمایید.