我使用sklearn_pandas和sklearn创建了一个ML管道。看起来像这样。
<style>
.showButon{
background:url('http://spacetelescope.github.io/understanding-json-schema/_static/pass.png');
background-repeat:repeat-y;
height:30px;
text-indent:20px;
}
</style>
<div id="myDiv">
<input id="info" type="button" value="Имате Въпрос?" class="showButon" />
</div>
(function(){
var button = document.getElementById("info");
var myDiv = document.getElementById("myDiv");
function toggle() {
if (myDiv.style.visibility === "hidden") {
myDiv.style.visibility = "visible";
} else {
myDiv.style.visibility = "hidden";
}
}
button.addEventListener("click", toggle, false);
})()
我喜欢我得到的模型和日志损失值。 如何使用此管道预测我的测试集?
当我执行pipe.predict(testX [features])时,我收到一条错误消息:
features = ['ColA','ColB','ColC']
labels = 'ColD'
mapper = sklearn_pandas.DataFrameMapper([
('ColB',sklearn.preprocessing.StandardScaler()),
('ColC',sklearn.preprocessing.StandardScaler())
])
pipe = sklearn.pipeline.Pipeline([
('featurize',mapper),
('imputer',imputer),
('logreg',sklearn.linear_model.LogisticRegression())
])
cross_val_score = sklearn_pandas.cross_val_score(pipe,traindf[features],traindf[labels],'log_loss')
我检查了我的测试集。看起来很好。
答案 0 :(得分:2)
您必须先安装管道,就像您适合任何型号/变压器一样:
pipe.fit(traindf[features], traindf[labels])