在mutual_info_regression
中预装n_neighbors=3
此代码适用于n_neighbors=3
:
selector = SelectKBest(mutual_info_regression, k='all').fit(X, y)
mutual_info_regression
中对n_neighbors=2
的请求?
不工作的变体:
selector = SelectKBest(mutual_info_regression, k='all').fit(X, y,**{'n_neighbors':2})
selector = SelectKBest(mutual_info_regression(**{'n_neighbors':2}), k='all').fit(X, y)
selector = SelectKBest(mutual_info_regression(n_neighbors=2), k='all').fit(X, y)
selector = SelectKBest(mutual_info_regression,n_neighbors=2, k='all').fit(X, y)
scoring = make_scorer(mutual_info_regression, greater_is_better=True, n_neighbors = 2)
selector = SelectKBest(scoring, k='all').fit(feat, targ)
您可以使用pythonspartial
函数创建具有非默认值的记分器:
from functools import partial
scorer_function = partial(mutual_info_regression, n_neighbors=2)
selector = SelectKBest(scorer_function, k='all').fit(X, y)