[英]Can I use a machine learning model as the objective function in an optimization problem?
I have a data set for which I use Sklearn Decision Tree regression machine learning package to build a model for prediction purposes.我有一个数据集,我使用 Sklearn 决策树回归机器学习包来构建用于预测的模型。 Subsequently, I am trying to utilize scipy.optimize package to solve for the minimized solution based on a given constraint.随后,我试图利用 scipy.optimize 包来解决基于给定约束的最小化解决方案。 However, I am not sure if I can take the decision tree model as the objective function for the optimization problem.但是,我不确定是否可以将决策树模型作为优化问题的目标函数。 What should be the approach in a situation like this?在这种情况下应该采取什么方法? I have tried linear regression models such as LarsCV in the past and they worked just fine.我过去曾尝试过线性回归模型,例如 LarsCV,它们工作得很好。 But in a linear regression model, you can essentially extract the coefficients and interception point from the model.但是在线性回归模型中,您基本上可以从模型中提取系数和截点。
Yes;是的; a linear regression model is a straightforward linear function of coefficients (one of which is the "intercept" or "bias").线性回归模型是系数的直接线性函数(其中之一是“截距”或“偏差”)。
The problem you have now is that a more complex model isn't quite so simple.您现在面临的问题是更复杂的模型并不那么简单。 You need to load the model into an appropriate engine.您需要将模型加载到适当的引擎中。 To "call" the model, you feed that engine the input vector (the cognate of a list of arguments), and wait for the model to return the prediction.要“调用”模型,您需要为引擎提供输入向量(参数列表的同源词),然后等待模型返回预测。
You need to wrap this process in a function call, perhaps one that issues the model load and processing as external system / shell commands, and returns the results to your main program.您需要将此过程包装在一个函数调用中,可能是一个将模型加载和处理作为外部系统/shell 命令发出的函数,并将结果返回到您的主程序。 Some applications are large enough that it makes sense to implement a full-bore data stream with listener and reporter to handle the throughput.一些应用程序足够大,可以使用侦听器和报告器实现全孔数据流来处理吞吐量。
Does that get you moving?这能让你动起来吗?
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.