WEBVTT

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

00:01.200 --> 00:05.080
Now let's use this class in our main activity.

00:05.080 --> 00:14.560
So here inside the main activity create private late initiate var tf Lite helper.

00:14.760 --> 00:17.360
It's of type TF Lite helper class.

00:17.360 --> 00:27.120
And then inside our Oncreate function let's initialize our TF Lite helper tf Lite helper and pass the

00:27.120 --> 00:27.800
context.

00:27.840 --> 00:35.280
This set the content prediction and pass the TF Lite helper.

00:35.280 --> 00:44.000
I need to change the parameters of the house price screen prediction function takes into the parameter

00:44.120 --> 00:46.720
tf Lite helper instance.

00:46.760 --> 00:51.840
Okay, later we're going to use this tf Lite helper with on click.

00:52.000 --> 00:58.360
But follow me now okay, so set content tf Lite helper instance.

00:58.360 --> 01:04.160
Also there is another function to override which is on destroy.

01:04.160 --> 01:10.640
So on destroy we need to call the close function that we create.

01:10.640 --> 01:13.560
So tf Lite helper dot close.

01:13.920 --> 01:16.560
Important to release the model.

01:16.560 --> 01:21.720
Closing the interpreter when the activity is destroyed.

01:21.760 --> 01:24.600
Okay, this is a very important step.

01:24.840 --> 01:32.880
Now let's move to the the, uh, house prediction price prediction function.

01:32.880 --> 01:38.000
And here we need to scroll down to the button.

01:38.000 --> 01:41.000
And on click we have this button.

01:41.000 --> 01:48.400
When I click on this I need to get the result and display a text for the price of the house.

01:48.480 --> 01:55.200
We have a variable x which is the size input of uh the the house.

01:55.440 --> 02:04.720
Here, if x does not equal to null val y equals to tf lite helper dot predict.

02:04.760 --> 02:12.120
You can see I am using the predict function that we create here in the TF Lite helper.

02:12.160 --> 02:13.800
It takes a float.

02:13.800 --> 02:18.840
So I need to pass a float which is y variable y.

02:19.040 --> 02:27.290
Now I need to store the result which is uh, which is uh x sorry, it's the input is X and the Y is

02:27.370 --> 02:28.570
the result.

02:28.610 --> 02:36.370
If y does not equal to null, then what we need to do predict the price.

02:36.610 --> 02:43.370
And we need to set the format like this and else failed to predict.

02:43.370 --> 02:46.570
And the result is the output result.

02:46.570 --> 02:49.050
So price output equals to.

02:49.090 --> 02:55.770
If y doesn't equals to null then go and set the price output to predicted price and get y.

02:55.970 --> 02:59.410
Otherwise print fail to predict.

02:59.410 --> 03:06.570
Then we need to use this price output here inside the text or under the text.

03:06.610 --> 03:16.010
If output price is not blank, make a spacer and create a text setting the price output.

03:16.010 --> 03:25.650
So here the price of the house is price output and set the style to material theme typography.

03:25.650 --> 03:26.810
Body medium.

03:26.850 --> 03:30.090
Okay, let's run our application.
