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


Python RidgeCV.score方法代码示例

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


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

示例1: regularizedreg

# 需要导入模块: from sklearn.linear_model import RidgeCV [as 别名]
# 或者: from sklearn.linear_model.RidgeCV import score [as 别名]
def regularizedreg(Xtrain,Xtest,ytrain,ytest):
    Rclf = RidgeCV(alphas=[1,2,20,40,50]) # RidgeCV(alphas=[0.1, 1.0, 2.0, 4.0, 20.0], cv=None, fit_intercept=True, scoring=None, normalize=False)
    Rclf.fit(Xtrain,ytrain);
    print("Residual sum of squares: %.2f"
         % np.mean((Rclf.predict(Xtest) - ytest) ** 2))
    print('Regularization choosen, alpha = %.2f' % Rclf.alpha_);
    print(' Coef values = ', Rclf.coef_);                                      
    print('Variance score: %.2f' % Rclf.score(Xtest, ytest))
开发者ID:chezhia,项目名称:PySci,代码行数:10,代码来源:selectfeatures.py

示例2: LinearRegression

# 需要导入模块: from sklearn.linear_model import RidgeCV [as 别名]
# 或者: from sklearn.linear_model.RidgeCV import score [as 别名]
X = X[:-predPeriod] #re-sizing the features for training
dataset.dropna(inplace=True) # get rid of naN for 'label' column

# create label 
y = np.array(dataset['label'])

X_train, X_test, y_train, y_test = cross_validation.train_test_split(X, y, test_size=0.2, random_state=1)

# use linearRegression as algrithm
#clf = LinearRegression()
clf = RidgeCV (alphas =[0.1, 0.5, 1, 10])
clf.fit(X_train, y_train)
#start_time = time.time()
y_pred = clf.predict(X_pred)
#print time.time() - start_time
accuracy = clf.score(X_test, y_test)
# visualize Learning Curves
#ML.ModelLearning(X, y)
#ML.ModelComplexity(X_train, y_train)

#Linear slope calculation
#print clf.alpha_
#print clf
#print clf.coef_
#print clf.intercept_
print 'predict accuracy is: {:0.2f}'.format(accuracy)


# build a column in data for predict result
data['predict/Adj Close'] = data['Adj Close'] # add column for predict value/Adj Close
开发者ID:jay56567,项目名称:Machine-Learning,代码行数:32,代码来源:tradePred.py

示例3: print

# 需要导入模块: from sklearn.linear_model import RidgeCV [as 别名]
# 或者: from sklearn.linear_model.RidgeCV import score [as 别名]
print(ridge)
print("Percent variance explained: {0}".format(ridge.score(X_aging, y_aging)))
print("Coefficients found: \n{0}\n".format(prettyprint(ridge.coef_, col, sort=True)))
print("ORDINARY LEAST SQUARES")
print(ols)
print("Percent variance explained: {0}".format(ols.score(X_aging, y_aging)))
print("Coefficients found: \n{0}\n".format(prettyprint(ols.coef_, col, sort=True)))
print("WHOLE DATASET //////////////////////////")

print("SUPER AGERS //////////////////////////")
ridge = RidgeCV(alphas=alpha_params, cv=7, scoring=score)
ridge.fit(X_sa, y_sa)
ols = LinearRegression()
ols.fit(X_sa, y_sa)
print("RIDGE REGRESSION")
print("Percent variance explained: {0}".format(ridge.score(X_sa, y_sa)))
print("Coefficients found: \n{0}\n".format(prettyprint(ridge.coef_, col, sort=True)))
print("ORDINARY LEAST SQUARES")
print("Percent variance explained: {0}".format(ols.score(X_sa, y_sa)))
print("Coefficients found: \n{0}\n".format(prettyprint(ols.coef_, col, sort=True)))
print("SUPER AGERS //////////////////////////")

print("MCIS //////////////////////////")
ridge = RidgeCV(alphas=alpha_params, cv=7, scoring=score)
ridge.fit(X_mci, y_mci)
ols = LinearRegression()
ols.fit(X_mci, y_mci)
print("RIDGE REGRESSION")
print("Percent variance explained: {0}".format(ridge.score(X_mci, y_mci)))
print("Coefficients found: \n{0}\n".format(prettyprint(ridge.coef_, col, sort=True)))
print("ORDINARY LEAST SQUARES")
开发者ID:canlabluc,项目名称:scripts,代码行数:33,代码来源:aging-feature-selection-ridge.py


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