本文整理汇总了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)