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


Python gaussian_process.GaussianProcess方法代码示例

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


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

示例1: gbc_gp_predict_part

# 需要导入模块: from sklearn import gaussian_process [as 别名]
# 或者: from sklearn.gaussian_process import GaussianProcess [as 别名]
def gbc_gp_predict_part(sub_x_Train, train_y, sub_x_Test_part):
    #Owing to out of memory, the model was trained by part of training data
    #Attention, this part was trained on the ram of more than 96G
    sub_x_Train[:,16] = np.log(1-sub_x_Train[:,16])
    scaler = pp.StandardScaler()
    scaler.fit(sub_x_Train)
    sub_x_Train = scaler.transform(sub_x_Train)
    ind_train = np.where(train_y>0)[0]
    part_size= int(0.7 * len(ind_train))
    gp = GaussianProcess(theta0=1e-3, thetaL=1e-5, thetaU=10, corr= 'absolute_exponential')
    gp.fit(sub_x_Train[ind_train[:part_size]], np.log(train_y[ind_train[:part_size]]))
    flag = (sub_x_Test_part[:,16] >= 1)
    ind_tmp0 = np.where(flag)[0]
    ind_tmp = np.where(~flag)[0]
    sub_x_Test_part[ind_tmp,16] = np.log(1-sub_x_Test_part[ind_tmp,16])
    sub_x_Test_part[ind_tmp] = scaler.transform(sub_x_Test_part[ind_tmp]) 
    gp_preds_tmp = gp_predict(gp, sub_x_Test_part[ind_tmp])
    gp_preds = np.zeros(len(sub_x_Test_part))
    gp_preds[ind_tmp] = gp_preds_tmp
    return gp_preds

# use gbm classifier to predict whether the loan defaults or not, then invoke the function gbc_gp_predict_part 
开发者ID:freedomljc,项目名称:Loan_Default_Prediction,代码行数:24,代码来源:predict.py

示例2: test_2d_2d

# 需要导入模块: from sklearn import gaussian_process [as 别名]
# 或者: from sklearn.gaussian_process import GaussianProcess [as 别名]
def test_2d_2d(regr=regression.constant, corr=correlation.squared_exponential,
               random_start=10, beta0=None):
    # MLE estimation of a two-dimensional Gaussian Process model accounting for
    # anisotropy. Check random start optimization.
    # Test the GP interpolation for 2D output
    b, kappa, e = 5., .5, .1
    g = lambda x: b - x[:, 1] - kappa * (x[:, 0] - e) ** 2.
    f = lambda x: np.vstack((g(x), g(x))).T
    X = np.array([[-4.61611719, -6.00099547],
                  [4.10469096, 5.32782448],
                  [0.00000000, -0.50000000],
                  [-6.17289014, -4.6984743],
                  [1.3109306, -6.93271427],
                  [-5.03823144, 3.10584743],
                  [-2.87600388, 6.74310541],
                  [5.21301203, 4.26386883]])
    y = f(X)
    gp = GaussianProcess(regr=regr, corr=corr, beta0=beta0,
                         theta0=[1e-2] * 2, thetaL=[1e-4] * 2,
                         thetaU=[1e-1] * 2,
                         random_start=random_start, verbose=False)
    gp.fit(X, y)
    y_pred, MSE = gp.predict(X, eval_MSE=True)

    assert_true(np.allclose(y_pred, y) and np.allclose(MSE, 0.)) 
开发者ID:alvarobartt,项目名称:twitter-stock-recommendation,代码行数:27,代码来源:test_gaussian_process.py

示例3: test_random_starts

# 需要导入模块: from sklearn import gaussian_process [as 别名]
# 或者: from sklearn.gaussian_process import GaussianProcess [as 别名]
def test_random_starts():
    # Test that an increasing number of random-starts of GP fitting only
    # increases the reduced likelihood function of the optimal theta.
    n_samples, n_features = 50, 3
    rng = np.random.RandomState(0)
    X = rng.randn(n_samples, n_features) * 2 - 1
    y = np.sin(X).sum(axis=1) + np.sin(3 * X).sum(axis=1)
    best_likelihood = -np.inf
    for random_start in range(1, 5):
        gp = GaussianProcess(regr="constant", corr="squared_exponential",
                             theta0=[1e-0] * n_features,
                             thetaL=[1e-4] * n_features,
                             thetaU=[1e+1] * n_features,
                             random_start=random_start, random_state=0,
                             verbose=False).fit(X, y)
        rlf = gp.reduced_likelihood_function()[0]
        assert_greater(rlf, best_likelihood - np.finfo(np.float32).eps)
        best_likelihood = rlf 
开发者ID:alvarobartt,项目名称:twitter-stock-recommendation,代码行数:20,代码来源:test_gaussian_process.py

示例4: gaussProcPred

# 需要导入模块: from sklearn import gaussian_process [as 别名]
# 或者: from sklearn.gaussian_process import GaussianProcess [as 别名]
def gaussProcPred(xTrain,yTrain,xTest,covar):
    xTrainAlter = []
    for i in range(1,len(xTrain)):
        tvec = xTrain[i-1]+xTrain[i]
        xTrainAlter.append(tvec)
    xTestAlter = []
    xTestAlter.append(xTrain[len(xTrain)-1]+xTest[0])
    for i in range(1,len(xTest)):
        tvec = xTest[i-1]+xTest[i]
        xTestAlter.append(tvec)
    clfr = gaussian_process.GaussianProcess(theta0=1e-2,
        thetaL=1e-4, thetaU=1e-1, corr=covar)
    clfr.fit(xTrainAlter,yTrain[1:])
    return clfr.predict(xTestAlter, eval_MSE=True)[0] 
开发者ID:lbenning,项目名称:Load-Forecasting,代码行数:16,代码来源:gpr.py

示例5: __init__

# 需要导入模块: from sklearn import gaussian_process [as 别名]
# 或者: from sklearn.gaussian_process import GaussianProcess [as 别名]
def __init__( self, n_outputs, regr='constant', corr='squared_exponential',
                 storage_mode='full', verbose=False, theta0=1e-1 ):
		self.gps = [ gaussian_process.GaussianProcess( regr=regr, corr=corr,
                 storage_mode=storage_mode, verbose=verbose, theta0=theta0 ) for i in range( n_outputs ) ] 
开发者ID:marcino239,项目名称:pilco,代码行数:6,代码来源:GPS.py

示例6: __init__

# 需要导入模块: from sklearn import gaussian_process [as 别名]
# 或者: from sklearn.gaussian_process import GaussianProcess [as 别名]
def __init__(self, f, pbounds):
        """
        参数:
        f: 需要最大化的函数,black-box
        pbounds: 字典,key为参数名称,value为最大最小值的tuple
        """
        self.pbounds = pbounds
        self.keys = list(pbounds.keys())
        self.dim = len(pbounds)
        self.bounds = []
        for key in self.pbounds.keys():
            self.bounds.append(self.pbounds[key])
        self.bounds = np.asarray(self.bounds)
        self.f = f

        self.initialized = False
        self.init_points = []
        self.x_init = []
        self.y_init = []

        self.X = None
        self.Y = None

        # 迭代次数i
        self.i = 0
        
        # scikit-learn中的GaussianProcess
        self.gp = GaussianProcess(corr=matern52,
                                  theta0=np.random.uniform(0.001, 0.05, self.dim),
                                  thetaL=1e-5 * np.ones(self.dim),
                                  thetaU=1e0 * np.ones(self.dim),
                                  random_start=30)

        # Utility喊出 
        self.util = None
        # 输出字典
        self.res = dict()
        self.res['max'] = {'max_val': None,
                           'max_params': None}
        self.res['all'] = {'values': [], 'params': []} 
开发者ID:X0Leon,项目名称:XQuant,代码行数:42,代码来源:bayesopt.py

示例7: __init__

# 需要导入模块: from sklearn import gaussian_process [as 别名]
# 或者: from sklearn.gaussian_process import GaussianProcess [as 别名]
def __init__(self, isTrain):
        super(RegressionGaussianProcess, self).__init__(isTrain)
        # data preprocessing
        #self.dataPreprocessing()

        # Create Gaussian process object
        self.gp = gaussian_process.GaussianProcess(theta0=1e-2, thetaL=1e-4, thetaU=1e-1) 
开发者ID:junlulocky,项目名称:AirTicketPredicting,代码行数:9,代码来源:RegressionGaussianProcess.py

示例8: test_1d

# 需要导入模块: from sklearn import gaussian_process [as 别名]
# 或者: from sklearn.gaussian_process import GaussianProcess [as 别名]
def test_1d(regr=regression.constant, corr=correlation.squared_exponential,
            random_start=10, beta0=None):
    # MLE estimation of a one-dimensional Gaussian Process model.
    # Check random start optimization.
    # Test the interpolating property.
    gp = GaussianProcess(regr=regr, corr=corr, beta0=beta0,
                         theta0=1e-2, thetaL=1e-4, thetaU=1e-1,
                         random_start=random_start, verbose=False).fit(X, y)
    y_pred, MSE = gp.predict(X, eval_MSE=True)
    y2_pred, MSE2 = gp.predict(X2, eval_MSE=True)

    assert_true(np.allclose(y_pred, y) and np.allclose(MSE, 0.)
                and np.allclose(MSE2, 0., atol=10)) 
开发者ID:alvarobartt,项目名称:twitter-stock-recommendation,代码行数:15,代码来源:test_gaussian_process.py

示例9: test_2d

# 需要导入模块: from sklearn import gaussian_process [as 别名]
# 或者: from sklearn.gaussian_process import GaussianProcess [as 别名]
def test_2d(regr=regression.constant, corr=correlation.squared_exponential,
            random_start=10, beta0=None):
    # MLE estimation of a two-dimensional Gaussian Process model accounting for
    # anisotropy. Check random start optimization.
    # Test the interpolating property.
    b, kappa, e = 5., .5, .1
    g = lambda x: b - x[:, 1] - kappa * (x[:, 0] - e) ** 2.
    X = np.array([[-4.61611719, -6.00099547],
                  [4.10469096, 5.32782448],
                  [0.00000000, -0.50000000],
                  [-6.17289014, -4.6984743],
                  [1.3109306, -6.93271427],
                  [-5.03823144, 3.10584743],
                  [-2.87600388, 6.74310541],
                  [5.21301203, 4.26386883]])
    y = g(X).ravel()

    thetaL = [1e-4] * 2
    thetaU = [1e-1] * 2
    gp = GaussianProcess(regr=regr, corr=corr, beta0=beta0,
                         theta0=[1e-2] * 2, thetaL=thetaL,
                         thetaU=thetaU,
                         random_start=random_start, verbose=False)
    gp.fit(X, y)
    y_pred, MSE = gp.predict(X, eval_MSE=True)

    assert_true(np.allclose(y_pred, y) and np.allclose(MSE, 0.))

    eps = np.finfo(gp.theta_.dtype).eps
    assert_true(np.all(gp.theta_ >= thetaL - eps))  # Lower bounds of hyperparameters
    assert_true(np.all(gp.theta_ <= thetaU + eps))  # Upper bounds of hyperparameters 
开发者ID:alvarobartt,项目名称:twitter-stock-recommendation,代码行数:33,代码来源:test_gaussian_process.py

示例10: test_wrong_number_of_outputs

# 需要导入模块: from sklearn import gaussian_process [as 别名]
# 或者: from sklearn.gaussian_process import GaussianProcess [as 别名]
def test_wrong_number_of_outputs():
    gp = GaussianProcess()
    gp.fit([[1, 2, 3], [4, 5, 6]], [1, 2, 3]) 
开发者ID:alvarobartt,项目名称:twitter-stock-recommendation,代码行数:5,代码来源:test_gaussian_process.py

示例11: test_no_normalize

# 需要导入模块: from sklearn import gaussian_process [as 别名]
# 或者: from sklearn.gaussian_process import GaussianProcess [as 别名]
def test_no_normalize():
    gp = GaussianProcess(normalize=False).fit(X, y)
    y_pred = gp.predict(X)
    assert_true(np.allclose(y_pred, y)) 
开发者ID:alvarobartt,项目名称:twitter-stock-recommendation,代码行数:6,代码来源:test_gaussian_process.py

示例12: test_mse_solving

# 需要导入模块: from sklearn import gaussian_process [as 别名]
# 或者: from sklearn.gaussian_process import GaussianProcess [as 别名]
def test_mse_solving():
    # test the MSE estimate to be sane.
    # non-regression test for ignoring off-diagonals of feature covariance,
    # testing with nugget that renders covariance useless, only
    # using the mean function, with low effective rank of data
    gp = GaussianProcess(corr='absolute_exponential', theta0=1e-4,
                         thetaL=1e-12, thetaU=1e-2, nugget=1e-2,
                         optimizer='Welch', regr="linear", random_state=0)

    X, y = make_regression(n_informative=3, n_features=60, noise=50,
                           random_state=0, effective_rank=1)

    gp.fit(X, y)
    assert_greater(1000, gp.predict(X, eval_MSE=True)[1].mean()) 
开发者ID:alvarobartt,项目名称:twitter-stock-recommendation,代码行数:16,代码来源:test_gaussian_process.py


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