WEBVTT

00:00.080 --> 00:00.960
Welcome back.

00:00.960 --> 00:04.920
Now let's run our application and see if there is any error.

00:04.960 --> 00:08.960
Here I select the Xiaomi my physical device.

00:08.960 --> 00:12.520
Also you can select the emulators.

00:12.520 --> 00:17.840
But in order to prevent any errors I need to test on my real device.

00:17.840 --> 00:22.600
So here this is our application car mileage predictor.

00:22.840 --> 00:33.640
Set the cylinders for displacement 150 horsepower, weight acceleration and the model year.

00:33.840 --> 00:46.200
Let me test if I entered invalid model year for example 1999 okay so 90 select American predict mileage.

00:46.320 --> 00:53.560
And here we have this error model year must be between 70 and 82.

00:53.720 --> 00:59.200
So here our validation of errors is working fine.

00:59.200 --> 01:01.720
Let me make it as 76.

01:01.960 --> 01:03.120
This is good.

01:03.120 --> 01:05.800
Select American predict mpg.

01:06.080 --> 01:07.760
And here we go.

01:07.880 --> 01:12.720
Predicted mileage is 8184.

01:12.760 --> 01:24.120
This is not acceptable because we need to get, uh, data between and range between, uh, like 12 and

01:24.160 --> 01:26.040
25 or 30.

01:26.080 --> 01:28.960
So this is not acceptable.

01:28.960 --> 01:29.440
Why?

01:29.880 --> 01:35.480
Because we used data that are not scaled.

01:35.480 --> 01:43.680
So here I want from you to understand the importance of the scaled features.

01:43.720 --> 01:47.160
Again, guys, this is the most important thing.

01:47.200 --> 01:52.120
You should pay attention when training machine learning and models.

01:52.120 --> 01:54.120
You should make scales.

01:54.280 --> 02:02.010
This is your pay attention, your application is working fine and the model is predicting data as you

02:02.250 --> 02:02.850
need.

02:02.890 --> 02:09.610
But there is one thing you missed that is the scaled features.

02:09.730 --> 02:13.330
Back to our Google Colab here.

02:13.570 --> 02:21.450
If you remember, let me scroll down before training the model, we talked about feature scaling.

02:21.770 --> 02:28.090
This is especially crucial for neural networks and many other machine learning algorithms.

02:28.370 --> 02:34.050
It standardizes the range of independent features in the data to a common scale.

02:34.290 --> 02:44.210
So here the formula is very simple X, which is the data or the feature value minus mean over standard

02:44.210 --> 02:45.090
deviation.

02:45.330 --> 02:52.410
In this case, we need to get the mean for every feature and the standard deviation of every feature

02:52.410 --> 02:56.050
in order to transform our data to this.

02:56.210 --> 03:00.410
So this step is not included in our model.

03:00.410 --> 03:03.050
We need to include it in Android Studio.

03:03.050 --> 03:12.010
So we're going to do this as similar to this in Android Studio in order to get the correct and the exact

03:12.010 --> 03:12.770
values.

03:12.770 --> 03:23.250
So again guys, since we get an unacceptable data and unacceptable, um, like predictions and despite

03:23.250 --> 03:33.650
everything is working fine because we are not using data scaling, because weight is dominating over

03:33.650 --> 03:45.530
all the features we need to set, every feature has its own effect, has its own scale, and all the

03:45.650 --> 03:49.250
features has a common Unit.

03:49.250 --> 03:58.490
If you remember, guys, we talked about cylinders like in CC, horsepower in um, in HP, weight in

03:58.490 --> 04:01.890
pounds, acceleration in second and so on.

04:01.890 --> 04:06.490
So every feature is, has its own unit.

04:06.530 --> 04:12.810
We need to unify all those features into one scale.

04:12.850 --> 04:13.330
Okay.

04:13.570 --> 04:23.810
So I need from you to, uh, to focus with me and pay attention how I need to use standard scaler,

04:23.810 --> 04:28.530
how to use feature scaling in our Android application.

04:28.530 --> 04:33.050
So we're going to use this step in Android Studio.

04:33.090 --> 04:41.650
At first we need to get the standard deviation and the mean of every feature before we move to Android

04:41.650 --> 04:42.250
Studio.

04:42.250 --> 04:46.940
So let me scroll up here in the statistical summary.

04:46.940 --> 04:54.700
And step number three understanding data, we get the mean and the standard deviation.

04:54.700 --> 04:57.460
So std standard deviation and the mean.

04:57.500 --> 05:03.620
We need to um to subtract x from mean over standard deviation.

05:03.620 --> 05:12.180
So please pay attention cup those values the standard deviation and the mean of cylinders displacement

05:12.180 --> 05:15.100
horsepower weight acceleration model year and so on.

05:15.100 --> 05:18.100
So let me start with cylinders.

05:18.260 --> 05:24.900
So let me take here Open Android Studio go to Car Mileage Predictor.

05:25.140 --> 05:34.180
And here inside this class let me create a new variable of type array.

05:34.580 --> 05:38.260
So here feature scaling.

05:38.540 --> 05:41.540
This is the most important step.

05:41.780 --> 05:48.580
So private val feature means equals to float array of.

05:49.020 --> 05:51.820
And let's start with a cylinder.

05:51.860 --> 05:54.700
The cylinders is 5.4

05:54.940 --> 05:59.380
71939F.

05:59.580 --> 06:01.180
This is for cylinders.

06:01.180 --> 06:03.220
So let me mark it like this.

06:03.220 --> 06:05.020
Let's continue with the others.

06:25.980 --> 06:32.540
We can take the origin one mean similar to origin two mean and origin three mean.

06:32.580 --> 06:33.140
Okay.

06:33.300 --> 06:39.220
Later if we get errors we can modify those values okay.

06:39.260 --> 06:47.950
Now let's create another variable similar to what we've done before, but this time for the feature

06:48.190 --> 06:50.270
standard deviations.

06:50.270 --> 06:52.430
So float array of.

06:52.630 --> 06:58.430
Here we need to use the standard deviation of the data.

06:58.430 --> 07:01.310
So copy this 1.7.

07:01.350 --> 07:06.510
This is for cylinders standard deviation and so on.

07:15.990 --> 07:18.790
Is the cylinders standard deviation.

07:18.790 --> 07:21.350
This is for displacement.

07:21.390 --> 07:31.710
This is for horsepower the weight acceleration model year origin one, origin two and origin three.

07:31.750 --> 07:35.830
Those are the standard deviation and the feature means.
