Мой код следующий:
Код: Выделить всё
!pip install xgboost
import seaborn as sns
import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
from sklearn.model_selection import train_test_split
import xgboost as xgb
# Read data and drop categorical variables; split as X and y
diamonds = sns.load_dataset("diamonds")
X, y = diamonds.drop(['price', 'color', 'cut', 'clarity'], axis = 1), diamonds[['price']]
# Split the data into train and test
X_train, X_test, y_train, y_test = train_test_split(X, y, random_state = 1)
# Create regression matrices
dtrain_reg = xgb.DMatrix(X_train, y_train, enable_categorical = True)
dtest_reg = xgb.DMatrix(X_test, y_test, enable_categorical = True)
ImportError Traceback (последний последний вызов)
в
1 # Создать регрессию матрицы
----> 2 dtrain_reg = xgb.DMatrix(X_train, y_train, Enable_categorical = True)
3 dtest_reg = xgb.DMatrix(X_test, y_test, Enable_categorical = True)
....
....
~\Downloads\Новая папка\lib\site-packages\xgboost\data.py в pandas_transform_data(data)
474 """Обрабатывать категориальные типы dtype и расширения из pandas."""
475 импортировать панды как pd
--> 476 из pandas import Float32Dtype, Float64Dtype
477
478 результат: List[np.ndarray] = []
ImportError: невозможно импортировать имя «Float32Dtype» из «Pandas» (C:\Users\lordp\Downloads\New папка\lib\site-packages\pandas_init_.py)
Подробнее здесь: https://stackoverflow.com/questions/792 ... -on-python
Мобильная версия