以下是与问题相关的部分代码。如果需要完整代码,这里有一个完整的可重现代码也可以下载数据:https ://github.com/ageron/handson-ml2/blob/master/02_end_to_end_machine_learning_project.ipynb
我有一个管道:
prepare_select_and_predict_pipeline = Pipeline([
('preparation', full_pipeline),
('feature_selection', TopFeatureSelector(feature_importances, k)),
('svm_reg', SVR(**rnd_search.best_params_))
])
现在,我只想从上面的管道执行这一部分:
('preparation', full_pipeline),
('feature_selection', TopFeatureSelector(feature_importances, k)),
我试过prepare_select_and_predict_pipeline.fit(housing, housing_labels)了,但它也执行 SVM 部分。
最后,我需要从上面的管道中获得与执行以下代码相同的结果:
preparation_and_feature_selection_pipeline = Pipeline([
('preparation', full_pipeline),
('feature_selection', TopFeatureSelector(feature_importances, k))
])
housing_prepared_top_k_features = preparation_and_feature_selection_pipeline.fit_transform(housing)
我该怎么做?
冉冉说
BIG阳
相关分类