python sklearn的特点是选择mutual_info_regression



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)

最新更新