I built my regression model, and now I want to make a staking regressor similar to the one presented in sklearn (Combine predictors using stacking — scikit-learn 1.2.1 documentation).

I want to make the stacking of three models. Each model receives one matrix and produces a matrix with the same dimensions. So model_1 receives matrix_input and produces matrix_output_1. Model_2 receives matrix_input and produces matrix_output_2. And model_3 receives matrix_input and produces matrix_output_3.

I can produce a single final matrix by using a weighted sum to produce the final output. However, instead of a weighted sum, I want to create a single model that receives matrix_output_1, matrix_output_2, and matrix_output_3 and produces the matrix_output.

Does anyone have suggestions on how I can do it?