我标记了数据,耦合了分类变量和两个二进制目标变量。
例如标题;
column_1,column_2,column_3,column_4,target_1,target_1
如何将其导出为PMML?我发现的唯一例子是无监督数据
import pandas
iris_df = pandas.read_csv("Iris.csv")
from sklearn2pmml import PMMLPipeline
from sklearn2pmml.decoration import ContinuousDomain
from sklearn_pandas import DataFrameMapper
from sklearn.decomposition import PCA
from sklearn.feature_selection import SelectKBest
from sklearn.preprocessing import Imputer
from sklearn.linear_model import LogisticRegression
iris_pipeline = PMMLPipeline([
("mapper", DataFrameMapper([
(["Sepal.Length", "Sepal.Width", "Petal.Length", "Petal.Width"], [ContinuousDomain(), Imputer()])
])),
("pca", PCA(n_components = 3)),
("selector", SelectKBest(k = 2)),
("classifier", LogisticRegression())
])
iris_pipeline.fit(iris_df, iris_df["Species"])
from sklearn2pmml import sklearn2pmml
sklearn2pmml(iris_pipeline, "LogisticRegressionIris.pmml", with_repr = True)
答案 0 :(得分:1)
提供的示例是关于监督分类 - y
方法的Pipeline#fit(X, y)
参数是标签。
你的情况如下:
pipeline = PMMLPipeline(
("mapper", DataFrameMapper([
(feature_column, LabelBinarizer()) for feature_column in ["column_1", "column_2", "column_3", "column_4"]
])),
("classifier", LogisticClassification())
)
pipeline.fit(df, df["target_1"])