When I use the following code in python:
import xgboost as xgb
import pandas as pd
import numpy as np
import matplotlib. pyplot as plt
plt.style.use(‘seaborn-v0_8’)
import shap
from sklearn. model_selection import train_test_split
my_random_state = 50
data = pd. read_csv(‘G:/Input for model.csv’)
cols = [
‘Aspect’, ‘Aspect_cv’, ‘Slope_cv’, ‘Elevation_cv’,
‘Forest height’, ‘Root depth’, ‘Tree density’,
‘Drought intensity’, ‘Available water capacity’,
‘Soil clay’, ‘Soil sand’, ‘Precipitation’,
‘Native plant species richness’
]
x_all = data[cols].values
y_all = data[‘y’].values
x_train, x_test, y_train, y_test = train_test_split(x_all, y_all,test_size=0.3, random_state=my_random_state)
model = xgb. XGBRegressor(max_depth=4, learning_rate=0.05, n_estimators=150)
model. fit(x_train, y_train)
Error occurs
I have reinstalled the xgboost package and python several times, but it still doesn’t work, what can I do?