本文整理汇总了Python中autosklearn.pipeline.classification.SimpleClassificationPipeline.pipeline_方法的典型用法代码示例。如果您正苦于以下问题:Python SimpleClassificationPipeline.pipeline_方法的具体用法?Python SimpleClassificationPipeline.pipeline_怎么用?Python SimpleClassificationPipeline.pipeline_使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类autosklearn.pipeline.classification.SimpleClassificationPipeline
的用法示例。
在下文中一共展示了SimpleClassificationPipeline.pipeline_方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_predict_batched
# 需要导入模块: from autosklearn.pipeline.classification import SimpleClassificationPipeline [as 别名]
# 或者: from autosklearn.pipeline.classification.SimpleClassificationPipeline import pipeline_ [as 别名]
def test_predict_batched(self):
cs = SimpleClassificationPipeline.get_hyperparameter_search_space()
default = cs.get_default_configuration()
cls = SimpleClassificationPipeline(default)
# Multiclass
X_train, Y_train, X_test, Y_test = get_dataset(dataset="digits")
cls.fit(X_train, Y_train)
X_test_ = X_test.copy()
prediction_ = cls.predict(X_test_)
cls_predict = mock.Mock(wraps=cls.pipeline_)
cls.pipeline_ = cls_predict
prediction = cls.predict(X_test, batch_size=20)
self.assertEqual((1647,), prediction.shape)
self.assertEqual(83, cls_predict.predict.call_count)
assert_array_almost_equal(prediction_, prediction)
# Multilabel
X_train, Y_train, X_test, Y_test = get_dataset(dataset="digits")
Y_train = np.array(list([(list([1 if i != y else 0 for i in range(10)])) for y in Y_train]))
cls.fit(X_train, Y_train)
X_test_ = X_test.copy()
prediction_ = cls.predict(X_test_)
cls_predict = mock.Mock(wraps=cls.pipeline_)
cls.pipeline_ = cls_predict
prediction = cls.predict(X_test, batch_size=20)
self.assertEqual((1647, 10), prediction.shape)
self.assertEqual(83, cls_predict.predict.call_count)
assert_array_almost_equal(prediction_, prediction)
示例2: test_predict_batched_sparse
# 需要导入模块: from autosklearn.pipeline.classification import SimpleClassificationPipeline [as 别名]
# 或者: from autosklearn.pipeline.classification.SimpleClassificationPipeline import pipeline_ [as 别名]
def test_predict_batched_sparse(self):
cs = SimpleClassificationPipeline.get_hyperparameter_search_space(dataset_properties={"sparse": True})
config = Configuration(
cs,
values={
"balancing:strategy": "none",
"classifier:__choice__": "random_forest",
"imputation:strategy": "mean",
"one_hot_encoding:minimum_fraction": 0.01,
"one_hot_encoding:use_minimum_fraction": "True",
"preprocessor:__choice__": "no_preprocessing",
"classifier:random_forest:bootstrap": "True",
"classifier:random_forest:criterion": "gini",
"classifier:random_forest:max_depth": "None",
"classifier:random_forest:min_samples_split": 2,
"classifier:random_forest:min_samples_leaf": 2,
"classifier:random_forest:max_features": 0.5,
"classifier:random_forest:max_leaf_nodes": "None",
"classifier:random_forest:n_estimators": 100,
"classifier:random_forest:min_weight_fraction_leaf": 0.0,
"rescaling:__choice__": "min/max",
},
)
cls = SimpleClassificationPipeline(config)
# Multiclass
X_train, Y_train, X_test, Y_test = get_dataset(dataset="digits", make_sparse=True)
cls.fit(X_train, Y_train)
X_test_ = X_test.copy()
prediction_ = cls.predict(X_test_)
cls_predict = mock.Mock(wraps=cls.pipeline_)
cls.pipeline_ = cls_predict
prediction = cls.predict(X_test, batch_size=20)
self.assertEqual((1647,), prediction.shape)
self.assertEqual(83, cls_predict.predict.call_count)
assert_array_almost_equal(prediction_, prediction)
# Multilabel
X_train, Y_train, X_test, Y_test = get_dataset(dataset="digits", make_sparse=True)
Y_train = np.array(list([(list([1 if i != y else 0 for i in range(10)])) for y in Y_train]))
cls.fit(X_train, Y_train)
X_test_ = X_test.copy()
prediction_ = cls.predict(X_test_)
cls_predict = mock.Mock(wraps=cls.pipeline_)
cls.pipeline_ = cls_predict
prediction = cls.predict(X_test, batch_size=20)
self.assertEqual((1647, 10), prediction.shape)
self.assertEqual(83, cls_predict.predict.call_count)
assert_array_almost_equal(prediction_, prediction)