弃用警告:numpy.core.umath_tests

dip*_*ali 6 python scikit-learn

我正在尝试运行下面的python脚本:

import pandas as pd
from sklearn.model_selection import train_test_split
from sklearn.ensemble import RandomForestClassifier
from sklearn.metrics import accuracy_score from sklearn.metrics import confusion_matrix

它给了我下面的错误.

警告(来自警告模块):来自numpy.core的文件"C:\ Users\Dipali\AppData\Local\Programs\Python\Python37-32\lib\site-packages\sklearn\ensemble\weight_boosting.py",第29行. umath_tests import inner1d DeprecationWarning:numpy.core.umath_tests是一个内部NumPy模块,不应导入.它将在未来的NumPy版本中删除.

我需要做什么?

小智 5

您可以通过以下方式忽略警告

示例 1:

#!/usr/bin/env python -W ignore::DeprecationWarning
Run Code Online (Sandbox Code Playgroud)

示例2:

import warnings
warnings.filterwarnings("ignore", category=DeprecationWarning) 
Run Code Online (Sandbox Code Playgroud)

示例 3:

import warnings

def fxn():
    warnings.warn("deprecated", DeprecationWarning)

with warnings.catch_warnings():
    warnings.simplefilter("ignore")
    fxn()
Run Code Online (Sandbox Code Playgroud)