Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/307.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 如何在没有tf idf的情况下创建组合?_Python_Gridsearchcv - Fatal编程技术网

Python 如何在没有tf idf的情况下创建组合?

Python 如何在没有tf idf的情况下创建组合?,python,gridsearchcv,Python,Gridsearchcv,我正在尝试不同的参数组合,以确定哪种参数组合给了我最好的结果。根据下面显示的代码,我已经尝试了8种不同的组合,但我想尝试其他没有tf idf的组合 因此,我的问题是,我应该如何处理参数,以便让python知道,在8个组合之后,现在我们继续进行无tf-idf(tf\u-use\u-idf)的操作,以便我们可以有另外4个组合(仅基于binary和stop\u-word),即总共12个组合 pipeline = Pipeline([ ('vect', CountVectorizer()),

我正在尝试不同的参数组合,以确定哪种参数组合给了我最好的结果。根据下面显示的代码,我已经尝试了8种不同的组合,但我想尝试其他没有tf idf的组合

因此,我的问题是,我应该如何处理
参数
,以便让python知道,在8个组合之后,现在我们继续进行无tf-idf(
tf\u-use\u-idf
)的操作,以便我们可以有另外4个组合(仅基于
binary
stop\u-word
),即总共12个组合

pipeline = Pipeline([
    ('vect', CountVectorizer()),
    ('tf', TfidfTransformer()),
    ('clf', SGDClassifier(loss='log', penalty='l2', max_iter=20, verbose=1)),
    ])

    parameters = {
    'vect__stop_words': ('english', None),
    'vect__binary': (True, False),
    'tf__use_idf': (True, False),
    }

    grid_search = GridSearchCV(pipeline, parameters, cv=5, n_jobs=-1, verbose=1)
    grid_search.fit(train.x, train.y)
    best_parameters = grid_search.best_params_

我想你正在寻找这样的东西:

管道=管道([
#reduce_dim阶段由参数网格填充
('reduce_dim'、'passthrough'),
(“分类”,线性RSVC(双=假,最大值=10000))
])
参数网格=[
{
“减少维度”:[PCA(迭代幂=7),NMF()],
“缩小尺寸”n“组件”:n“功能”n“选项”,
“分类”:C\U选项
},
{
“缩小尺寸”:[SelectKBest(chi2)],
“缩小尺寸”:N\u功能\u选项,
“分类”:C\U选项
},
]
这个例子是我从