1 00:00:00,033 --> 00:00:00,833 Hello, my friends. 2 00:00:00,833 --> 00:00:05,000 All right, let's make that prediction with the SVR model. 3 00:00:05,000 --> 00:00:07,500 So we're going to create a new code cell here. 4 00:00:07,500 --> 00:00:08,366 And here we go. 5 00:00:08,366 --> 00:00:11,366 We're going to start of course from our regressor 6 00:00:11,566 --> 00:00:16,500 from which we're going to call the predict method that will take as input. 7 00:00:16,633 --> 00:00:20,333 And now I'm asking you what what will it exactly take as input. 8 00:00:20,533 --> 00:00:23,600 Well it's not directly the 6.5 level 9 00:00:23,700 --> 00:00:27,433 but the scaled value of the 6.5 level. 10 00:00:27,500 --> 00:00:27,866 Right. 11 00:00:27,866 --> 00:00:33,033 Because our SVR model was trained on the scaled values at the training set, 12 00:00:33,033 --> 00:00:37,233 and therefore in the predict method, we must enter the scaled value 13 00:00:37,233 --> 00:00:39,600 of the input that we want to predict. 14 00:00:39,600 --> 00:00:44,300 And therefore here we must call our scalar x object 15 00:00:44,433 --> 00:00:48,600 from which we're going to call the transform method. 16 00:00:48,766 --> 00:00:49,366 There we go. 17 00:00:49,366 --> 00:00:52,133 And then in this transform method of our scaler object, 18 00:00:52,133 --> 00:00:55,500 well that's where we can enter our position level of 6.5. 19 00:00:55,500 --> 00:00:59,600 But remember we have to enter it in a double pair of square brackets 20 00:00:59,733 --> 00:01:03,466 because the predict method expects any input as a 2D array. 21 00:01:03,733 --> 00:01:04,200 All right. 22 00:01:04,200 --> 00:01:07,800 So let's enter 6.5. And now that's not all. 23 00:01:07,800 --> 00:01:09,833 There are two extra things we need to do. 24 00:01:09,833 --> 00:01:13,800 Remember that we not only scaled the inputs in X 25 00:01:14,066 --> 00:01:16,666 but we also scaled the output. 26 00:01:16,666 --> 00:01:19,266 Remember I'll go back to feature scaling here. 27 00:01:19,266 --> 00:01:22,066 We made that scaler object for the input x 28 00:01:22,066 --> 00:01:25,433 but also that scaler object as y for the output y. 29 00:01:25,433 --> 00:01:29,966 And indeed we used that scaler y object here to scale the output y. 30 00:01:29,966 --> 00:01:34,033 And therefore since the output y was killed, well, in order to get 31 00:01:34,200 --> 00:01:38,066 the prediction in the original scale, meaning the original salaries, 32 00:01:38,233 --> 00:01:43,100 well, we must apply a reverse scaling to that whole prediction. 33 00:01:43,333 --> 00:01:43,866 Right. 34 00:01:43,866 --> 00:01:49,300 And the method that will do exactly this is a method called inverse transform. 35 00:01:49,433 --> 00:01:54,300 And this will exactly reverse this killing that we applied to the output y. 36 00:01:54,533 --> 00:01:56,633 All right. So let's do this. Let's call this method. 37 00:01:56,633 --> 00:01:59,400 First we have to call it from our c underscore 38 00:01:59,400 --> 00:02:03,433 y object because we want to reverse the scaling of the output y. 39 00:02:03,533 --> 00:02:07,966 So let's see why from which we call this inverse underscore. 40 00:02:08,166 --> 00:02:10,600 There it is inverse transform method. 41 00:02:10,600 --> 00:02:14,500 And then we will put this whole prediction in the parentheses 42 00:02:14,500 --> 00:02:17,333 of this inverse transform method of the object. 43 00:02:17,333 --> 00:02:18,300 So here we go. 44 00:02:18,300 --> 00:02:21,600 We add a parenthesis here and we close it right here. 45 00:02:22,233 --> 00:02:23,666 All right almost ready. 46 00:02:23,666 --> 00:02:25,233 We're almost ready to get that prediction. 47 00:02:25,233 --> 00:02:27,533 But there is one less thing we need to do. 48 00:02:27,533 --> 00:02:29,600 And you don't need to worry too much about this. 49 00:02:29,600 --> 00:02:31,800 This is just for the SVR model. 50 00:02:31,800 --> 00:02:34,600 You won't have to apply too much of reshapes 51 00:02:34,600 --> 00:02:39,066 and all the other models of this course, but to avoid a format error, 52 00:02:39,066 --> 00:02:42,933 we must just add inside the parentheses of the inverse transform 53 00:02:42,933 --> 00:02:46,733 method another reshape which is dot reshape 54 00:02:46,966 --> 00:02:50,966 and then in parentheses you enter minus one and one. 55 00:02:51,000 --> 00:02:51,600 And this way 56 00:02:51,600 --> 00:02:55,800 we will all avoid a format error and we'll all be able to get the prediction. 57 00:02:56,133 --> 00:02:56,700 All right. 58 00:02:56,700 --> 00:02:57,433 So that's it. 59 00:02:57,433 --> 00:02:58,800 We are ready to get the prediction. 60 00:02:58,800 --> 00:03:02,466 But first remember that in the previous tutorial we didn't run the cell. 61 00:03:02,466 --> 00:03:05,633 So let's do it now to train the SVR model. 62 00:03:05,666 --> 00:03:06,700 Here it is. 63 00:03:06,700 --> 00:03:09,733 And so now if you're ready let's get the predicted 64 00:03:09,733 --> 00:03:13,700 salary of the position level 6.5 by the SVR model. 65 00:03:13,866 --> 00:03:14,566 Here we go. 66 00:03:14,566 --> 00:03:21,000 Let's run this cell and we get $170,370. 67 00:03:21,333 --> 00:03:23,000 All right. It looks pretty good. 68 00:03:23,000 --> 00:03:26,633 It looks to make pretty good sense, but that we will double check 69 00:03:26,633 --> 00:03:30,466 in the next tutorial by visualizing the SVR results. 70 00:03:30,666 --> 00:03:31,900 Try to do it before me. 71 00:03:31,900 --> 00:03:34,766 You will again have to play with the transform 72 00:03:34,766 --> 00:03:37,033 unless you are inverse transform. But you can do it. 73 00:03:37,033 --> 00:03:39,300 You can of course start from the codes 74 00:03:39,300 --> 00:03:41,233 at the end of the polynomial regression notebook. 75 00:03:41,233 --> 00:03:42,900 At least that's where we'll start from. 76 00:03:42,900 --> 00:03:44,200 So I look forward to this. 77 00:03:44,200 --> 00:03:46,200 And until then, enjoy machine learning.