当前位置: 首页>>代码示例>>Python>>正文


Python gaussian_process.GaussianProcessClassifier方法代码示例

本文整理汇总了Python中sklearn.gaussian_process.GaussianProcessClassifier方法的典型用法代码示例。如果您正苦于以下问题:Python gaussian_process.GaussianProcessClassifier方法的具体用法?Python gaussian_process.GaussianProcessClassifier怎么用?Python gaussian_process.GaussianProcessClassifier使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在sklearn.gaussian_process的用法示例。


在下文中一共展示了gaussian_process.GaussianProcessClassifier方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_custom_optimizer

# 需要导入模块: from sklearn import gaussian_process [as 别名]
# 或者: from sklearn.gaussian_process import GaussianProcessClassifier [as 别名]
def test_custom_optimizer(kernel):
    # Test that GPC can use externally defined optimizers.
    # Define a dummy optimizer that simply tests 50 random hyperparameters
    def optimizer(obj_func, initial_theta, bounds):
        rng = np.random.RandomState(0)
        theta_opt, func_min = \
            initial_theta, obj_func(initial_theta, eval_gradient=False)
        for _ in range(50):
            theta = np.atleast_1d(rng.uniform(np.maximum(-2, bounds[:, 0]),
                                              np.minimum(1, bounds[:, 1])))
            f = obj_func(theta, eval_gradient=False)
            if f < func_min:
                theta_opt, func_min = theta, f
        return theta_opt, func_min

    gpc = GaussianProcessClassifier(kernel=kernel, optimizer=optimizer)
    gpc.fit(X, y_mc)
    # Checks that optimizer improved marginal likelihood
    assert_greater(gpc.log_marginal_likelihood(gpc.kernel_.theta),
                   gpc.log_marginal_likelihood(kernel.theta)) 
开发者ID:PacktPublishing,项目名称:Mastering-Elasticsearch-7.0,代码行数:22,代码来源:test_gpc.py

示例2: getModels

# 需要导入模块: from sklearn import gaussian_process [as 别名]
# 或者: from sklearn.gaussian_process import GaussianProcessClassifier [as 别名]
def getModels():
    result = []
    result.append("LinearRegression")
    result.append("BayesianRidge")
    result.append("ARDRegression")
    result.append("ElasticNet")
    result.append("HuberRegressor")
    result.append("Lasso")
    result.append("LassoLars")
    result.append("Rigid")
    result.append("SGDRegressor")
    result.append("SVR")
    result.append("MLPClassifier")
    result.append("KNeighborsClassifier")
    result.append("SVC")
    result.append("GaussianProcessClassifier")
    result.append("DecisionTreeClassifier")
    result.append("RandomForestClassifier")
    result.append("AdaBoostClassifier")
    result.append("GaussianNB")
    result.append("LogisticRegression")
    result.append("QuadraticDiscriminantAnalysis")
    return result 
开发者ID:tech-quantum,项目名称:sia-cog,代码行数:25,代码来源:scikitlearn.py

示例3: test_objectmapper

# 需要导入模块: from sklearn import gaussian_process [as 别名]
# 或者: from sklearn.gaussian_process import GaussianProcessClassifier [as 别名]
def test_objectmapper(self):
        df = pdml.ModelFrame([])
        dgp = df.gaussian_process

        self.assertIs(dgp.GaussianProcessClassifier,
                      gp.GaussianProcessClassifier)
        self.assertIs(dgp.GaussianProcessRegressor,
                      gp.GaussianProcessRegressor)
        self.assertIs(dgp.correlation_models.absolute_exponential,
                      gp.correlation_models.absolute_exponential)
        self.assertIs(dgp.correlation_models.squared_exponential,
                      gp.correlation_models.squared_exponential)
        self.assertIs(dgp.correlation_models.generalized_exponential,
                      gp.correlation_models.generalized_exponential)
        self.assertIs(dgp.correlation_models.pure_nugget,
                      gp.correlation_models.pure_nugget)
        self.assertIs(dgp.correlation_models.cubic,
                      gp.correlation_models.cubic)
        self.assertIs(dgp.correlation_models.linear,
                      gp.correlation_models.linear) 
开发者ID:pandas-ml,项目名称:pandas-ml,代码行数:22,代码来源:test_gaussian_process.py

示例4: test_custom_optimizer

# 需要导入模块: from sklearn import gaussian_process [as 别名]
# 或者: from sklearn.gaussian_process import GaussianProcessClassifier [as 别名]
def test_custom_optimizer():
    # Test that GPC can use externally defined optimizers.
    # Define a dummy optimizer that simply tests 50 random hyperparameters
    def optimizer(obj_func, initial_theta, bounds):
        rng = np.random.RandomState(0)
        theta_opt, func_min = \
            initial_theta, obj_func(initial_theta, eval_gradient=False)
        for _ in range(50):
            theta = np.atleast_1d(rng.uniform(np.maximum(-2, bounds[:, 0]),
                                              np.minimum(1, bounds[:, 1])))
            f = obj_func(theta, eval_gradient=False)
            if f < func_min:
                theta_opt, func_min = theta, f
        return theta_opt, func_min

    for kernel in kernels:
        if kernel == fixed_kernel:
            continue
        gpc = GaussianProcessClassifier(kernel=kernel, optimizer=optimizer)
        gpc.fit(X, y_mc)
        # Checks that optimizer improved marginal likelihood
        assert_greater(gpc.log_marginal_likelihood(gpc.kernel_.theta),
                       gpc.log_marginal_likelihood(kernel.theta)) 
开发者ID:alvarobartt,项目名称:twitter-stock-recommendation,代码行数:25,代码来源:test_gpc.py

示例5: __init__

# 需要导入模块: from sklearn import gaussian_process [as 别名]
# 或者: from sklearn.gaussian_process import GaussianProcessClassifier [as 别名]
def __init__(self, **kwargs):
        super(GaussianProcess, self).__init__()
        super(GaussianProcess, self).SetModel(GaussianProcessClassifier(
            random_state=RANDOM_SEED[CLASSIFIER_GP], **kwargs)) 
开发者ID:salan668,项目名称:FAE,代码行数:6,代码来源:Classifier.py

示例6: test_predict_consistent

# 需要导入模块: from sklearn import gaussian_process [as 别名]
# 或者: from sklearn.gaussian_process import GaussianProcessClassifier [as 别名]
def test_predict_consistent(kernel):
    # Check binary predict decision has also predicted probability above 0.5.
    gpc = GaussianProcessClassifier(kernel=kernel).fit(X, y)
    assert_array_equal(gpc.predict(X),
                       gpc.predict_proba(X)[:, 1] >= 0.5) 
开发者ID:PacktPublishing,项目名称:Mastering-Elasticsearch-7.0,代码行数:7,代码来源:test_gpc.py

示例7: test_lml_improving

# 需要导入模块: from sklearn import gaussian_process [as 别名]
# 或者: from sklearn.gaussian_process import GaussianProcessClassifier [as 别名]
def test_lml_improving(kernel):
    # Test that hyperparameter-tuning improves log-marginal likelihood.
    gpc = GaussianProcessClassifier(kernel=kernel).fit(X, y)
    assert_greater(gpc.log_marginal_likelihood(gpc.kernel_.theta),
                   gpc.log_marginal_likelihood(kernel.theta)) 
开发者ID:PacktPublishing,项目名称:Mastering-Elasticsearch-7.0,代码行数:7,代码来源:test_gpc.py

示例8: test_lml_precomputed

# 需要导入模块: from sklearn import gaussian_process [as 别名]
# 或者: from sklearn.gaussian_process import GaussianProcessClassifier [as 别名]
def test_lml_precomputed(kernel):
    # Test that lml of optimized kernel is stored correctly.
    gpc = GaussianProcessClassifier(kernel=kernel).fit(X, y)
    assert_almost_equal(gpc.log_marginal_likelihood(gpc.kernel_.theta),
                        gpc.log_marginal_likelihood(), 7) 
开发者ID:PacktPublishing,项目名称:Mastering-Elasticsearch-7.0,代码行数:7,代码来源:test_gpc.py

示例9: test_converged_to_local_maximum

# 需要导入模块: from sklearn import gaussian_process [as 别名]
# 或者: from sklearn.gaussian_process import GaussianProcessClassifier [as 别名]
def test_converged_to_local_maximum(kernel):
    # Test that we are in local maximum after hyperparameter-optimization.
    gpc = GaussianProcessClassifier(kernel=kernel).fit(X, y)

    lml, lml_gradient = \
        gpc.log_marginal_likelihood(gpc.kernel_.theta, True)

    assert np.all((np.abs(lml_gradient) < 1e-4) |
                  (gpc.kernel_.theta == gpc.kernel_.bounds[:, 0]) |
                  (gpc.kernel_.theta == gpc.kernel_.bounds[:, 1])) 
开发者ID:PacktPublishing,项目名称:Mastering-Elasticsearch-7.0,代码行数:12,代码来源:test_gpc.py

示例10: test_lml_gradient

# 需要导入模块: from sklearn import gaussian_process [as 别名]
# 或者: from sklearn.gaussian_process import GaussianProcessClassifier [as 别名]
def test_lml_gradient(kernel):
    # Compare analytic and numeric gradient of log marginal likelihood.
    gpc = GaussianProcessClassifier(kernel=kernel).fit(X, y)

    lml, lml_gradient = gpc.log_marginal_likelihood(kernel.theta, True)
    lml_gradient_approx = \
        approx_fprime(kernel.theta,
                      lambda theta: gpc.log_marginal_likelihood(theta,
                                                                False),
                      1e-10)

    assert_almost_equal(lml_gradient, lml_gradient_approx, 3) 
开发者ID:PacktPublishing,项目名称:Mastering-Elasticsearch-7.0,代码行数:14,代码来源:test_gpc.py

示例11: test_multi_class

# 需要导入模块: from sklearn import gaussian_process [as 别名]
# 或者: from sklearn.gaussian_process import GaussianProcessClassifier [as 别名]
def test_multi_class(kernel):
    # Test GPC for multi-class classification problems.
    gpc = GaussianProcessClassifier(kernel=kernel)
    gpc.fit(X, y_mc)

    y_prob = gpc.predict_proba(X2)
    assert_almost_equal(y_prob.sum(1), 1)

    y_pred = gpc.predict(X2)
    assert_array_equal(np.argmax(y_prob, 1), y_pred) 
开发者ID:PacktPublishing,项目名称:Mastering-Elasticsearch-7.0,代码行数:12,代码来源:test_gpc.py

示例12: test_multi_class_n_jobs

# 需要导入模块: from sklearn import gaussian_process [as 别名]
# 或者: from sklearn.gaussian_process import GaussianProcessClassifier [as 别名]
def test_multi_class_n_jobs(kernel):
    # Test that multi-class GPC produces identical results with n_jobs>1.
    gpc = GaussianProcessClassifier(kernel=kernel)
    gpc.fit(X, y_mc)

    gpc_2 = GaussianProcessClassifier(kernel=kernel, n_jobs=2)
    gpc_2.fit(X, y_mc)

    y_prob = gpc.predict_proba(X2)
    y_prob_2 = gpc_2.predict_proba(X2)
    assert_almost_equal(y_prob, y_prob_2) 
开发者ID:PacktPublishing,项目名称:Mastering-Elasticsearch-7.0,代码行数:13,代码来源:test_gpc.py

示例13: test_sklearn_49

# 需要导入模块: from sklearn import gaussian_process [as 别名]
# 或者: from sklearn.gaussian_process import GaussianProcessClassifier [as 别名]
def test_sklearn_49(self):
        iris = datasets.load_iris()
        irisd = pd.DataFrame(iris.data, columns=iris.feature_names)
        irisd['Species'] = iris.target
        target = 'Species'
        features = irisd.columns.drop('Species')
        f_name = "gpc.pmml"
        model = GaussianProcessClassifier()
        pipeline_obj = Pipeline([
            ('model', model)
        ])
        pipeline_obj.fit(irisd[features], irisd[target])
        with self.assertRaises(NotImplementedError):
            skl_to_pmml(pipeline_obj, numpy.array(features), target, f_name) 
开发者ID:nyoka-pmml,项目名称:nyoka,代码行数:16,代码来源:test_skl_to_pmml_UnitTest.py

示例14: test_sklearn_50

# 需要导入模块: from sklearn import gaussian_process [as 别名]
# 或者: from sklearn.gaussian_process import GaussianProcessClassifier [as 别名]
def test_sklearn_50(self):
        iris = datasets.load_iris()
        irisd = pd.DataFrame(iris.data, columns=iris.feature_names)
        irisd['Species'] = iris.target
        target = 'Species'
        features = irisd.columns.drop('Species')
        f_name = "no_pipeline.pmml"
        model = GaussianProcessClassifier()
        model.fit(irisd[features], irisd[target])
        with self.assertRaises(TypeError):
            skl_to_pmml(model, features, target, f_name) 
开发者ID:nyoka-pmml,项目名称:nyoka,代码行数:13,代码来源:test_skl_to_pmml_UnitTest.py

示例15: test_objectmapper_abbr

# 需要导入模块: from sklearn import gaussian_process [as 别名]
# 或者: from sklearn.gaussian_process import GaussianProcessClassifier [as 别名]
def test_objectmapper_abbr(self):
        df = pdml.ModelFrame([])
        dgp = df.gp

        self.assertIs(dgp.GaussianProcessClassifier,
                      gp.GaussianProcessClassifier)
        self.assertIs(dgp.GaussianProcessRegressor,
                      gp.GaussianProcessRegressor) 
开发者ID:pandas-ml,项目名称:pandas-ml,代码行数:10,代码来源:test_gaussian_process.py


注:本文中的sklearn.gaussian_process.GaussianProcessClassifier方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。