So, my python script generates a (25,8) variable "latent_vars". I save this variable as a .mat file. Then, from python, I run a matlab script that runs a trained kriging model with "latent_var" as input. The kriging model (in matlab) outputs "comp_vals", a 1x25 double variable, which I then save as a .mat file and open back up in python. The problem is that this process takes a while (about a minute and 15 seconds), but I need it to occur in under 3 seconds.
Is there any other way I can go about this to speed the process up?
This is they python code:
import scipy.io as sio
import numpy as np
sio.savemat('latent_vars.mat', {'latent_vars':noise})
import matlab.engine
eng = matlab.engine.start_matlab()
eng.Kriging_to_python(nargout=0)
eng.quit()
comp_vals=sio.loadmat('comp_vals.mat')
And this is the matlab code:
%Load matlab workspace with kriging model
krig_workspace=load('C:\Users\User\Documents\MATLAB\krig_posttrain_workspace2.mat');
%Import latent variable values from python
latent_from_python=load('/Users/User/Documents/project/Interactive Framework/latent_vars.mat');
latent_vars=latent_from_python.latent_vars;
latent_vars=single(latent_vars);
%Save kriging model from workspace as new variable
krig_model=krig_workspace.dmodel;
%Run kriging model with latent variables generated from python
[comp_vals MSEpredict] = predictor(latent_vars, krig_model);
comp_vals=transpose(comp_vals);
save('/Users/User/Documents/project/Interactive Framework/comp_vals.mat','comp_vals');
Any help/insight would be appreciated! Thanks.
matlab -batch scriptname, which you can do from within Python withos.system.