简体   繁体   中英

I can't ignore python's deprecated warning in jupyter notebook

I keep getting the following warning:

[17:04:03] WARNING: src/objective/regression_obj.cu:152: reg:linear is now deprecated in favor of reg:squarederror.

What i've tried:

1)

import warnings
warnings.filterwarnings("ignore", category=DeprecationWarning) 

2) #:/usr/bin/env python -W ignore::DeprecationWarning

3) python -W ignore foo.py

4)

%env PYTHONWARNINGS="ignore"
%env PYTHONDEPRECATEDWARNINGS="ignore"

Code For Recreating the error(below): This is just an example, if you run this on jupternotebook the warning is given, followed by a bunch of errors. Ignore the errors because I haven't entered proper data for the machine learning model, I don't encounter those errors in my actual code. But just the warning

import pandas as pd
import numpy as np
import datetime
todays_date = datetime.datetime.now().date()
index = pd.date_range(todays_date-datetime.timedelta(10), periods=10, freq='D')
columns = ['A','B', 'C']
df = pd.DataFrame(index = index, columns=columns)
df = df.fillna(0) 
x = df['A']
y = df['B']
from sklearn.model_selection import train_test_split
from xgboost import XGBRegressor
x_train, x_test, y_train, y_test = train_test_split(x,y,test_size=0.2,random_state=0)
regressor = XGBRegressor(learning_rate=0.1,alpha=0,max_depth=6,sample=0.5,min_sample=10,n_estimators=500)
regressor.fit(x_train,y_train)
#regressor.predict(x_test)
enter code here
enter code here

Upgrading libraries is not helping. I fixed it when changing the default value for property objective="reg:squarederror" which was ="reg:linear" for def init in file [path\Python\Lib\site-packages\xgboost\sklearn.py].

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM