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


Python linear_model.ARDRegression类代码示例

本文整理汇总了Python中sklearn.linear_model.ARDRegression的典型用法代码示例。如果您正苦于以下问题:Python ARDRegression类的具体用法?Python ARDRegression怎么用?Python ARDRegression使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: test_check_is_fitted

def test_check_is_fitted():
    # Check is ValueError raised when non estimator instance passed
    assert_raises(ValueError, check_is_fitted, ARDRegression, "coef_")
    assert_raises(TypeError, check_is_fitted, "SVR", "support_")

    ard = ARDRegression()
    svr = SVR()

    try:
        assert_raises(NotFittedError, check_is_fitted, ard, "coef_")
        assert_raises(NotFittedError, check_is_fitted, svr, "support_")
    except ValueError:
        assert False, "check_is_fitted failed with ValueError"

    # NotFittedError is a subclass of both ValueError and AttributeError
    try:
        check_is_fitted(ard, "coef_", "Random message %(name)s, %(name)s")
    except ValueError as e:
        assert_equal(str(e), "Random message ARDRegression, ARDRegression")

    try:
        check_is_fitted(svr, "support_", "Another message %(name)s, %(name)s")
    except AttributeError as e:
        assert_equal(str(e), "Another message SVR, SVR")

    ard.fit(*make_blobs())
    svr.fit(*make_blobs())

    assert_equal(None, check_is_fitted(ard, "coef_"))
    assert_equal(None, check_is_fitted(svr, "support_"))
开发者ID:Afey,项目名称:scikit-learn,代码行数:30,代码来源:test_validation.py

示例2: ARDRegression_on_fold

def ARDRegression_on_fold(feature_sets, train, test, y, y_all, X, dim, dimsum, learn_options):
    '''
    '''
    clf = ARDRegression()
    clf.fit(X[train], y[train][:, 0])
    y_pred = clf.predict(X[test])[:, None]
    return y_pred, clf
开发者ID:pablocarderam,项目名称:genetargeter,代码行数:7,代码来源:regression.py

示例3: fit_model_16

    def fit_model_16(self,toWrite=False):
        model = ARDRegression()

        for data in self.cv_data:
            X_train, X_test, Y_train, Y_test = data
            model.fit(X_train,Y_train)
            pred = model.predict(X_test)
            print("Model 16 score %f" % (logloss(Y_test,pred),))

        if toWrite:
            f2 = open('model16/model.pkl','w')
            pickle.dump(model,f2)
            f2.close()
开发者ID:JakeMick,项目名称:kaggle,代码行数:13,代码来源:days_work.py

示例4: ARDRegression

# Create weigts with a precision lambda_ of 4.
lambda_ = 4.
w = np.zeros(n_features)
# Only keep 10 weights of interest
relevant_features = np.random.randint(0, n_features, 10)
for i in relevant_features:
    w[i] = stats.norm.rvs(loc=0, scale=1. / np.sqrt(lambda_))
# Create noite with a precision alpha of 50.
alpha_ = 50.
noise = stats.norm.rvs(loc=0, scale=1. / np.sqrt(alpha_), size=n_samples)
# Create the target
y = np.dot(X, w) + noise

###############################################################################
# Fit the ARD Regression
clf = ARDRegression(compute_score=True)
clf.fit(X, y)

ols = LinearRegression()
ols.fit(X, y)

###############################################################################
# Plot the true weights, the estimated weights and the histogram of the
# weights
plt.figure(figsize=(6, 5))
plt.title("Weights of the model")
plt.plot(clf.coef_, 'b-', label="ARD estimate")
plt.plot(ols.coef_, 'r--', label="OLS estimate")
plt.plot(w, 'g-', label="Ground truth")
plt.xlabel("Features")
plt.ylabel("Values of the weights")
开发者ID:NicovincX2,项目名称:Python-3.5,代码行数:31,代码来源:ard_ols.py

示例5: ARDRegression

# Create weights with a precision lambda_ of 4.
lambda_ = 4.
w = np.zeros(n_features)
# Only keep 10 weights of interest
relevant_features = np.random.randint(0, n_features, 10)
for i in relevant_features:
    w[i] = stats.norm.rvs(loc=0, scale=1. / np.sqrt(lambda_))
# Create noise with a precision alpha of 50.
alpha_ = 50.
noise = stats.norm.rvs(loc=0, scale=1. / np.sqrt(alpha_), size=n_samples)
# Create the target
y = np.dot(X, w) + noise

###############################################################################
# Fit the ARD Regression
clf = ARDRegression(compute_score=True)
clf.fit(X, y)

ols = LinearRegression()
ols.fit(X, y)

###############################################################################
# Plot the true weights, the estimated weights, the histogram of the
# weights, and predictions with standard deviations
plt.figure(figsize=(6, 5))
plt.title("Weights of the model")
plt.plot(clf.coef_, color='darkblue', linestyle='-', linewidth=2,
         label="ARD estimate")
plt.plot(ols.coef_, color='yellowgreen', linestyle=':', linewidth=2,
         label="OLS estimate")
plt.plot(w, color='orange', linestyle='-', linewidth=2, label="Ground truth")
开发者ID:AlexandreAbraham,项目名称:scikit-learn,代码行数:31,代码来源:plot_ard.py

示例6: Normalizer

    
if __name__ == "__main__":
    
    ########################### Set script paramaters  ###########################
    #Gene expression paramaters
    log10Normalize = True
    standardizeByTCGA = True #Normalize expression data in a unified way for TCGA and cell lines
    L2Normalizer = Normalizer(norm='l2', copy=True) #Method to normalize gene expression values
    
    
    #Gene Pruning parameters
    pruneUncorrelatedGenes = True; #Eliminates genes that are uncorrelated between array and RNASeq
    pruneCutoff = 0.001; #p value cutoff for pruning
    clinicalSplitPoint =  60 #for the array data, the first 60 entries correspond to NCI60 dataset
   
    clf = ARDRegression(normalize=False)

    #Location for training data
    inputFolder = '../output/standardizedData/2015-07-30/'
    docetaxelArrayFolder = '../data/docetaxel_validation/'
    outputFolder = '../output/DocetaxelClinical/' + np.str(date.today()) + '/'

    if not os.path.exists(outputFolder):
            os.makedirs(outputFolder)
    #############################################################################
    
    cellExpression = joblib.load(inputFolder + 'cellExpression.pkl')
    tcgaExpression = joblib.load(inputFolder + 'tcgaExpression.pkl')
    mergedExpression = cellExpression.append(tcgaExpression)
            
    #Retrieves Combat homogonized data for NCI60 cell line and Docetaxel Clincal U95 Array Data
开发者ID:gkoytiger,项目名称:OncologyOracle,代码行数:30,代码来源:validateDocetaxelClinical.py

示例7: learn_model

def learn_model(x_mat, y):
    #model = SVR(kernel='rbf')
    model = ARDRegression()
    model.fit(x_mat, y)
    return model
开发者ID:tchajed,项目名称:partial-results,代码行数:5,代码来源:regression.py

示例8: load_boston

#+++++++++++++++++++++++++++++++++++++++++++++++++
#Importing sklearn, numpy pylab modules 
from sklearn.linear_model import ARDRegression
from sklearn.model_selection import cross_val_predict
from sklearn.datasets import load_boston
from sklearn.metrics import explained_variance_score, mean_squared_error
import numpy as np
import pylab as pl
#Loading boston datasets 
boston = load_boston()
# Creating Regression Design Matrix 
x = boston.data
# Creating target dataset
y = boston.target
# Create ARDRegression Regression object 
ARD= ARDRegression(alpha_1=0.01, alpha_2=0.01, lambda_1=1e-06, lambda_2=1e-06)
# Fitting a linear model using the dataset
ARD.fit(x,y)
# Y predicted values
yp = ARD.predict(x)
#Calculation 10-Fold CV
yp_cv = cross_val_predict(ARD, x, y, cv=10)
#Printing RMSE and Explained Variance
Evariance=explained_variance_score(y,yp)
Evariance_cv=explained_variance_score(y,yp_cv)
RMSE =np.sqrt(mean_squared_error(y,yp))
RMSECV=np.sqrt(mean_squared_error(y,yp_cv))
print('Method: ARDRegression Regression')
print('RMSE on the dataset: %.4f' %RMSE)
print('RMSE on 10-fold CV: %.4f' %RMSECV)
print('Explained Variance Regression Score on the dataset: %.4f' %Evariance)
开发者ID:omoreira,项目名称:GM-Python-Workbook,代码行数:31,代码来源:ARDRegression_boston10foldcv.py


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