我在github(https://github.com/jpmml/sklearn2pmml-plugin/blob/master/README.md)中知道SkLearn2PMML-Plugin项目。但是我对Java的经验很少。有人可以帮我编写功能转换器的java插件。下面是我的特征转换器。
class FeatureSelector(TransformerMixin):
'''A transformer for extracting certain column(s)'''
def __init__(self, cols):
self.cols = cols
def fit(self, X, y=None, **fit_params):
return self
def transform(self, X, **transform_params):
return X[self.cols]
class ModelTransformer(TransformerMixin):
def __init__(self, model):
self.model = model
def fit(self, *args, **kwargs):
self.model.fit(*args, **kwargs)
return self
def transform(self, X, **transform_params):
return pd.DataFrame(self.model.predict(X))
答案 0 :(得分:0)
您可以使用FeatureSelector
转换来实现sklearn2pmml.preprocessing.ExpressionTransformer
的功能:
selector = ExpressionTransformer("X[0]")
ModelTransformer
功能有些棘手,但确实可行。下次,请考虑直接通过SkLearn2PMML项目打开功能请求(而不是要求SO为您编写代码):https://github.com/jpmml/sklearn2pmml/issues/118