Я пытаюсь запустить базовую модель XGBoost на Python (версия 3.8.5), однако получаю ошибку, которую не могу устранить. Благодарим за помощь!
Мой код выглядит следующим образом:
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 (most recent call last)
in
1 # Create regression matrices
----> 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\New folder\lib\site-packages\xgboost\data.py in pandas_transform_data(data)
474 """Handle categorical dtype and extension types from pandas."""
475 import pandas as pd
--> 476 from pandas import Float32Dtype, Float64Dtype
477
478 result: List[np.ndarray] = []
ImportError: cannot import name 'Float32Dtype' from 'pandas' (C:\Users\lordp\Downloads\New folder\lib\site-packages\pandas\__init__.py)
Подробнее здесь: https://stackoverflow.com/questions/792 ... -on-python
Ошибка ImportError из Pandas при запуске модели XGBoost на Python ⇐ Python
Программы на Python
-
Anonymous
1734213767
Anonymous
Я пытаюсь запустить базовую модель XGBoost на Python (версия 3.8.5), однако получаю ошибку, которую не могу устранить. Благодарим за помощь!
Мой код выглядит следующим образом:
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 (most recent call last)
in
1 # Create regression matrices
----> 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\New folder\lib\site-packages\xgboost\data.py in pandas_transform_data(data)
474 """Handle categorical dtype and extension types from pandas."""
475 import pandas as pd
--> 476 from pandas import Float32Dtype, Float64Dtype
477
478 result: List[np.ndarray] = []
ImportError: cannot import name 'Float32Dtype' from 'pandas' (C:\Users\lordp\Downloads\New folder\lib\site-packages\pandas\__init__.py)
Подробнее здесь: [url]https://stackoverflow.com/questions/79281302/importerror-from-pandas-while-running-xgboost-model-on-python[/url]
Ответить
1 сообщение
• Страница 1 из 1
Перейти
- Кемерово-IT
- ↳ Javascript
- ↳ C#
- ↳ JAVA
- ↳ Elasticsearch aggregation
- ↳ Python
- ↳ Php
- ↳ Android
- ↳ Html
- ↳ Jquery
- ↳ C++
- ↳ IOS
- ↳ CSS
- ↳ Excel
- ↳ Linux
- ↳ Apache
- ↳ MySql
- Детский мир
- Для души
- ↳ Музыкальные инструменты даром
- ↳ Печатная продукция даром
- Внешняя красота и здоровье
- ↳ Одежда и обувь для взрослых даром
- ↳ Товары для здоровья
- ↳ Физкультура и спорт
- Техника - даром!
- ↳ Автомобилистам
- ↳ Компьютерная техника
- ↳ Плиты: газовые и электрические
- ↳ Холодильники
- ↳ Стиральные машины
- ↳ Телевизоры
- ↳ Телефоны, смартфоны, плашеты
- ↳ Швейные машинки
- ↳ Прочая электроника и техника
- ↳ Фототехника
- Ремонт и интерьер
- ↳ Стройматериалы, инструмент
- ↳ Мебель и предметы интерьера даром
- ↳ Cантехника
- Другие темы
- ↳ Разное даром
- ↳ Давай меняться!
- ↳ Отдам\возьму за копеечку
- ↳ Работа и подработка в Кемерове
- ↳ Давай с тобой поговорим...
Мобильная версия