本文整理汇总了Python中sklearn.linear_model.ARDRegression.predict方法的典型用法代码示例。如果您正苦于以下问题:Python ARDRegression.predict方法的具体用法?Python ARDRegression.predict怎么用?Python ARDRegression.predict使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类sklearn.linear_model.ARDRegression
的用法示例。
在下文中一共展示了ARDRegression.predict方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: ARDRegression_on_fold
# 需要导入模块: from sklearn.linear_model import ARDRegression [as 别名]
# 或者: from sklearn.linear_model.ARDRegression import predict [as 别名]
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
示例2: fit_model_16
# 需要导入模块: from sklearn.linear_model import ARDRegression [as 别名]
# 或者: from sklearn.linear_model.ARDRegression import predict [as 别名]
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()
示例3: f
# 需要导入模块: from sklearn.linear_model import ARDRegression [as 别名]
# 或者: from sklearn.linear_model.ARDRegression import predict [as 别名]
plt.plot(clf.scores_, color='navy', linewidth=2)
plt.ylabel("Score")
plt.xlabel("Iterations")
# Plotting some predictions for polynomial regression
def f(x, noise_amount):
y = np.sqrt(x) * np.sin(x)
noise = np.random.normal(0, 1, len(x))
return y + noise_amount * noise
degree = 10
X = np.linspace(0, 10, 100)
y = f(X, noise_amount=1)
clf_poly = ARDRegression(threshold_lambda=1e5)
clf_poly.fit(np.vander(X, degree), y)
X_plot = np.linspace(0, 11, 25)
y_plot = f(X_plot, noise_amount=0)
y_mean, y_std = clf_poly.predict(np.vander(X_plot, degree), return_std=True)
plt.figure(figsize=(6, 5))
plt.errorbar(X_plot, y_mean, y_std, color='navy',
label="Polynomial ARD", linewidth=2)
plt.plot(X_plot, y_plot, color='gold', linewidth=2,
label="Ground Truth")
plt.ylabel("Output y")
plt.xlabel("Feature X")
plt.legend(loc="lower left")
plt.show()
示例4: standardizeExpression
# 需要导入模块: from sklearn.linear_model import ARDRegression [as 别名]
# 或者: from sklearn.linear_model.ARDRegression import predict [as 别名]
rescaledExpressionClinical = L2Normalizer.transform(np.log10(rescaledExpressionClinical+1))
# else:
# prunedRnaSeqExpressionNormalized, L2Normalizer = standardizeExpression(prunedRnaSeqExpression.ix[cellExpression.shape[0],;], L2Normalizer, log10Normalize)
# prunedArrayExpressionNormalized = L2Normalizer.transform(np.log10(prunedRescaledExpressionClinical+1))
#Load Docetaxel IC50 Data
docetaxelData = getDrugIC50('Docetaxel', inputFolder)
#Assemble training data with both IC50 and expression data
docetaxelData = pd.merge(docetaxelData, rnaSeqExpressionNormalized, how='inner', left_index=True, right_index=True).drop('cell_line', axis=1)
#Train Docetaxel model
clf.fit(docetaxelData.drop(['IC50'], axis=1), docetaxelData['IC50'])
#Validate on Clinical Data
resistance_predictions = clf.predict(rescaledExpressionClinical)
#Calculates ROC, first 11 samples correspond to sensitive patients, last 13 are resistant
roc_auc_score(np.hstack((np.repeat(0,11), np.repeat(1,13))), resistance_predictions)
roc_data = pd.DataFrame()
roc_data['fpr'], roc_data['tpr'],roc_data['thresholds'] = roc_curve(np.hstack((np.repeat(0,11), np.repeat(1,13))), resistance_predictions)
#Plot Results
from bokeh.charts import show, output_file
from bokeh.plotting import figure
output_file(outputFolder + 'Docetaxel_ROC_Curve_rankIC50.html')
示例5: load_boston
# 需要导入模块: from sklearn.linear_model import ARDRegression [as 别名]
# 或者: from sklearn.linear_model.ARDRegression import predict [as 别名]
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)
print('Explained Variance Regression 10-fold CV: %.4f' %Evariance_cv)
#plotting real vs predicted data
pl.figure(1)
pl.plot(yp, y,'ro')