[英]Deploy pandas transformation as a machine learning model
I would like to deploy a simple pandas dataframe transformation as a machine learning model.我想部署一个简单的 pandas dataframe 转换作为机器学习 model。
Say, I have:说,我有:
X = pd.DataFrame({'A': [1, 2, 3], 'B': [4, 5, 6]})
How to create a 'model', which after the call pred = model.predict(X)
如何创建一个“模型”,在调用
pred = model.predict(X)
之后
will "predict" a sum of A and B: pred = df['A'] + df['B']
?将“预测” A 和 B 的总和:
pred = df['A'] + df['B']
?
My use case is to treat it as a kind of baseline model in my ML experiments, in which I will encode different heuristics.我的用例是在我的 ML 实验中将其视为一种基线 model,我将在其中编码不同的启发式方法。
Having such a "model" I would like to be able to eg pickle it and deploy on some endpoint to serve "human predictions".拥有这样一个“模型”,我希望能够例如腌制它并部署在某个端点上以服务于“人类预测”。
Many thanks in advance:)提前谢谢了:)
Andy安迪
Isn't this standard in OOP: OOP中不是这个标准吗:
class Model:
def predict(self, df):
# might need to check that A, B are in the columns
return df['A'] + df['B']
model = Model()
model.predict(X)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.