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


Python FeatureUnion.transformer_weights方法代码示例

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


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

示例1: KFold

# 需要导入模块: from sklearn.pipeline import FeatureUnion [as 别名]
# 或者: from sklearn.pipeline.FeatureUnion import transformer_weights [as 别名]
compteur = 0
proba = pm.Bernoulli('p',0.5)
best_val = 0

kf = KFold(len(X_trainDF),5,shuffle=True,random_state=55)

while compteur < Iteration:
    print compteur
    C = 10**(uniform(-6,-2))
    p = uniform(3,6)
    npca = randrange(5, 30)
    
    which_feature = {k:int(proba.random()) for k in Feature.transformer_weights.keys()}
    which_feature['HOGFeature'] = 1
    which_feature['SobelFeature'] = 1
    Feature.transformer_weights = which_feature
    param = {'SobelFeature__PCA__n_components':npca,
             'RawImage__PCA__n_components':npca,
             'HOGFeature__PCA__n_components':npca}
    Feature.set_params(**param)
    
    scores = []; rocauctr = []; rocaucval = []
    print 'Debut cross-validation'
    for train_index, val_index in kf:
        X_trDF, X_valDF = X_trainDF.iloc[train_index], X_trainDF.iloc[val_index]
        y_trDF, y_valDF = y_trainDF.iloc[train_index], y_trainDF.iloc[val_index]
        
        X_tr = Feature.fit_transform(X_trDF)
        y_tr = np.array(y_trDF)[:,np.newaxis]
        
        X_val = Feature.transform(X_valDF)
开发者ID:cthorey,项目名称:Crater_Classification,代码行数:33,代码来源:LR_Worker.py


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