WEBVTT

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

00:01.080 --> 00:08.000
Let's use this validation errors composable in our car features form.

00:08.000 --> 00:13.720
And here you see that we didn't use this validation errors parameter.

00:13.920 --> 00:19.920
Scroll down to under the origin card origin chip.

00:20.080 --> 00:26.680
And under the scope of this row let me use the validation errors.

00:26.680 --> 00:35.760
If validation errors is not empty, go and display the validation errors composable with the validation

00:35.760 --> 00:37.000
errors inside it.

00:37.200 --> 00:47.000
And also you can make a spacer between the validation errors and the button or the row that here of

00:47.280 --> 00:48.280
origin chip.

00:48.320 --> 00:50.760
Okay so let me run.

00:50.760 --> 01:00.360
So if the user missed anything here, there is an error displaying that you should specify the correct

01:00.360 --> 01:04.000
input or you should specify the missing inputs.

01:04.040 --> 01:06.800
Now I want from you to focus with me.

01:06.840 --> 01:08.000
We finished the UI.

01:08.360 --> 01:13.400
Now let's move to the functional coding here.

01:13.560 --> 01:18.320
Create a new package named as predictions.

01:18.320 --> 01:22.600
And inside this package, create a new Kotlin class.

01:22.800 --> 01:25.040
Name it as car.

01:25.160 --> 01:27.320
My mileage predictor.

01:27.360 --> 01:36.080
We need to connect our user interface with the TensorFlow Lite model that we created.

01:36.240 --> 01:38.680
We need to get those data.

01:38.680 --> 01:45.800
And when the user clicks on the submit button, we need to get the data into TensorFlow.

01:46.040 --> 01:53.160
And the TensorFlow will predict the mileage and display the result here.

01:53.280 --> 01:56.280
So this is a connection.

01:56.280 --> 02:02.560
This is a bridge between our TensorFlow and the user interface.

02:02.600 --> 02:11.630
So I want from you to understand it like it's a bridge between TensorFlow model And user interface.

02:11.630 --> 02:18.630
This car mileage predictor class takes into the constructor a context object.

02:18.830 --> 02:24.670
And as we did before, let's start with the interpreter.

02:24.830 --> 02:25.910
Interpreter.

02:26.070 --> 02:29.630
It's from TensorFlow Lite.

02:29.950 --> 02:33.790
It's of type TensorFlow Lite interpreter.

02:33.910 --> 02:39.310
This line of code declares a private variable named interpreter.

02:39.670 --> 02:47.310
That is your app engine for running TensorFlow Lite machine learning models.

02:47.350 --> 02:48.270
TF Lite.

02:48.510 --> 02:57.230
So you give it a model and some input data and it gives you back the predictions or results.

02:57.270 --> 02:57.830
Okay.

02:58.030 --> 03:02.110
The second step is to create the input shape and the output shape.

03:02.230 --> 03:06.070
This is very important in machine learning.

03:06.110 --> 03:12.670
We need to get the shape of our input and get the output shape of our model.

03:12.710 --> 03:16.830
Private val input shape.

03:16.870 --> 03:20.310
What is the shape of our model?

03:20.470 --> 03:25.190
It's an int array of one and nine.

03:25.350 --> 03:29.950
We need to pass one sample and nine features.

03:29.990 --> 03:31.630
Did you remember the features?

03:31.630 --> 03:33.110
Let me go back to here.

03:33.150 --> 03:38.910
Car features 123, four, five, six, seven, eight and nine.

03:39.070 --> 03:48.910
So we need to set the input shape to 1999 features and one sample.

03:49.110 --> 03:55.710
So one sample and nine features we need to get the output shape.

03:55.710 --> 04:03.270
So output shape equals to int array of one of one.

04:03.430 --> 04:06.750
So here we have one sample.

04:06.750 --> 04:10.990
And we need to get only the mileage.

04:11.150 --> 04:13.990
So the output would be a one number.

04:14.150 --> 04:16.870
It's the mileage of our car.

04:16.910 --> 04:17.390
Okay.

04:17.590 --> 04:19.940
So the output shape.

04:19.980 --> 04:23.300
Output shape is a number.

04:23.340 --> 04:25.980
This is very very important.

04:26.220 --> 04:32.420
We need to understand the input and the output of our shape and our model.

04:32.460 --> 04:32.940
Okay.

04:33.100 --> 04:35.940
So give me nine parameters.

04:35.980 --> 04:41.340
Nine features I'll give you one output okay.

04:41.700 --> 04:46.380
So this is the meaning of the input and output shape here.

04:46.420 --> 04:47.260
To solve it.

04:47.300 --> 04:48.380
We need to use it.

04:48.420 --> 04:52.060
Private var interpreter add late.

04:52.060 --> 04:52.660
Initiate.

04:52.660 --> 04:54.780
You can late initiate it okay.

04:54.940 --> 04:58.220
Then start with init block.

04:58.260 --> 05:01.180
We need to load that Tflite model.

05:01.180 --> 05:09.620
So here val model equals to load model file and set the context.

05:09.820 --> 05:17.100
The parameter interpreter equals to interpreter and pass the model.

05:17.140 --> 05:20.620
In the next video we're going to create this function.
