如何解决未来警告->;%(min_组,self.n_拆分),警告)在python中?

如何解决未来警告->;%(min_组,self.n_拆分),警告)在python中?,python,scikit-learn,linearmodels,future-warning,Python,Scikit Learn,Linearmodels,Future Warning,当我在程序中运行mean_acc()方法时,有%(min_组,self.n_拆分),警告)错误 def mean_acc(): models = [ RandomForestClassifier(n_estimators=200, max_depth=3, random_state=0), LinearSVC(), MultinomialNB(), LogisticRegression(random_state=0)]

当我在程序中运行mean_acc()方法时,有%(min_组,self.n_拆分),警告)错误

def mean_acc():
    models = [
        RandomForestClassifier(n_estimators=200, max_depth=3, random_state=0),
        LinearSVC(),
        MultinomialNB(),
        LogisticRegression(random_state=0)]
    CV = 6
    cv_df = pd.DataFrame(index=range(CV * len(models)))
    entries = []
    for model in models:
        model_name = model.__class__.__name__
        accuracies = cross_val_score(model, features, labels, scoring='accuracy', cv=CV)
        for fold_idx, accuracy in enumerate(accuracies):
            entries.append((model_name, fold_idx, accuracy))
    cv_df = pd.DataFrame(entries, columns=['model_name', 'fold_idx', 'accuracy'])

    print(cv_df.groupby('model_name').accuracy.mean())
这些是使用mean_acc()方法运行程序时显示的错误。我可以知道如何解决以下错误吗?请帮助我看看上面导致这些错误的代码,谢谢

 % (min_groups, self.n_splits)), Warning)
C:\Users\L31307\PycharmProjects\FYP\venv\lib\site-packages\sklearn\model_selection\_split.py:626: Warning: The least populated class in y has only 1 members, which is too few. The minimum number of members in any class cannot be less than n_splits=5.
  % (min_groups, self.n_splits)), Warning)
C:\Users\L31307\PycharmProjects\FYP\venv\lib\site-packages\sklearn\model_selection\_split.py:626: Warning: The least populated class in y has only 1 members, which is too few. The minimum number of members in any class cannot be less than n_splits=5.
  % (min_groups, self.n_splits)), Warning)
C:\Users\L31307\PycharmProjects\FYP\venv\lib\site-packages\sklearn\model_selection\_split.py:626: Warning: The least populated class in y has only 1 members, which is too few. The minimum number of members in any class cannot be less than n_splits=5.
  % (min_groups, self.n_splits)), Warning)
C:\Users\L31307\PycharmProjects\FYP\venv\lib\site-packages\sklearn\linear_model\logistic.py:432: FutureWarning: Default solver will be changed to 'lbfgs' in 0.22. Specify a solver to silence this warning.
  FutureWarning)
C:\Users\L31307\PycharmProjects\FYP\venv\lib\site-packages\sklearn\linear_model\logistic.py:459: FutureWarning: Default multi_class will be changed to 'auto' in 0.22. Specify the multi_class option to silence this warning.
  "this warning.", FutureWarning)
C:\Users\L31307\PycharmProjects\FYP\venv\lib\site-packages\sklearn\linear_model\logistic.py:432: FutureWarning: Default solver will be changed to 'lbfgs' in 0.22. Specify a solver to silence this warning.
  FutureWarning)
C:\Users\L31307\PycharmProjects\FYP\venv\lib\site-packages\sklearn\linear_model\logistic.py:459: FutureWarning: Default multi_class will be changed to 'auto' in 0.22. Specify the multi_class option to silence this warning.
  "this warning.", FutureWarning)
C:\Users\L31307\PycharmProjects\FYP\venv\lib\site-packages\sklearn\linear_model\logistic.py:432: FutureWarning: Default solver will be changed to 'lbfgs' in 0.22. Specify a solver to silence this warning.
  FutureWarning)
C:\Users\L31307\PycharmProjects\FYP\venv\lib\site-packages\sklearn\linear_model\logistic.py:459: FutureWarning: Default multi_class will be changed to 'auto' in 0.22. Specify the multi_class option to silence this warning.
  "this warning.", FutureWarning)
C:\Users\L31307\PycharmProjects\FYP\venv\lib\site-packages\sklearn\linear_model\logistic.py:432: FutureWarning: Default solver will be changed to 'lbfgs' in 0.22. Specify a solver to silence this warning.
  FutureWarning)
C:\Users\L31307\PycharmProjects\FYP\venv\lib\site-packages\sklearn\linear_model\logistic.py:459: FutureWarning: Default multi_class will be changed to 'auto' in 0.22. Specify the multi_class option to silence this warning.
  "this warning.", FutureWarning)

如果要忽略它,请在顶部的代码中添加以下内容:

import warnings
warnings.filterwarnings("ignore", category=FutureWarning)
否则指定解算器如下:

LogisticRegression(solver='lbfgs')
:


如果您使用的逻辑回归模型的惩罚为'l1',则可以使用
solver='liblinear'

我的代码示例::

logistic_regression_model=LogisticRegression(penalty='l1',dual=False,max_iter=110, solver='liblinear')

它告诉你该做什么do@RadosławGanczarek我不明白。。。但我如何不让它在控制台中显示…@RadosławGanczarek我如何消除控制台上显示的错误:向右滚动,警告消息上写着“指定[事物]以使此警告静音。”
logistic_regression_model=LogisticRegression(penalty='l1',dual=False,max_iter=110, solver='liblinear')