필터 지우기
필터 지우기

Restrict ypred in fitrgp function

조회 수: 2 (최근 30일)
Giacomo Caporusso
Giacomo Caporusso 2023년 6월 29일
댓글: Giacomo Caporusso 2023년 7월 3일
I have a dataset where x is the independent variable and y is the dependent variable. I'm using the fitrgp function to model the response to the variable x given the values of y. I need to enforce fitrgp's ypred output to be between two values 'a' and 'b'.
How can I do?
Are there any options for fitrgp to enforce this constraint?
Thank you.

채택된 답변

Manas
Manas 2023년 6월 29일
Hi Giacomo,
There is no direct way to enforce constraints on the predicted values. You may use the following code to enforce the constraints.
ypred(ypred < a) = a; % Set values below 'a' to 'a'
ypred(ypred > b) = b; % Set values above 'b' to 'b'
  댓글 수: 1
Giacomo Caporusso
Giacomo Caporusso 2023년 7월 3일
Thanks for the reply. I hope that over time it will be possible to set the domain and codomain of the fitrgp function.

댓글을 달려면 로그인하십시오.

추가 답변 (1개)

Cyrus Monteiro
Cyrus Monteiro 2023년 6월 29일
The `fitrgp` function in MATLAB does not have a built-in option to enforce constraints on the predicted output (`ypred`) to be within a specific range. However, you can manually enforce this constraint after obtaining the predictions.
Here's an example of how you can enforce the constraint on `ypred` to be between two values, 'a' and 'b'
% Assuming you have already trained the Gaussian Process model using fitrgp
model = fitrgp(X, y);
% Obtain the predicted values
ypred = predict(model, X);
% Enforce the constraint on ypred to be between 'a' and 'b'
a = 0; % Lower bound
b = 1; % Upper bound
ypred_constrained = max(min(ypred, b), a);
In the code above, `ypred_constrained` is the predicted output (`ypred`) after enforcing the constraint to be between 'a' and 'b'. The `max` function limits the values of `ypred` to be less than or equal to 'b', and the `min` function ensures the values are greater than or equal to 'a'.
By applying this constraint manually, you can ensure that the predicted values (`ypred_constrained`) fall within the desired range.
More about the fitrgp here
  댓글 수: 1
Giacomo Caporusso
Giacomo Caporusso 2023년 7월 3일
Thanks for the reply. I hope that over time it will be possible to set the domain and codomain of the fitrgp function.

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Gaussian Process Regression에 대해 자세히 알아보기

태그

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by