May-19-2020, 03:30 PM
Dear Sir, I'm trying do to a program that predict the emission of polluting gases from a Thermal Coal Plant. I would like help to solve the following mensagem error:
Thanks in advance
Thanks in advance
!pip install xgboost
import xgboost as xgb import numpy as np import matplotlib.pyplot as plt from sklearn.model_selection import GridSearchCV import pandas as pd from sklearn.metrics import mean_squared_error, r2_score, explained_variance_score, mean_absolute_error, median_absolute_error, mean_squared_log_erro
df = pd.read_csv('Dados_AP_CO_07_04_2020_5.csv',encoding='cp1252') df.tail()
X = df.drop(['[CO]mg/m³N'], axis = 1) y = df['[CO]mg/m³N']
data_dmatrix = xgb.DMatrix(data=X, label=y) df.columns = [regex.sub("_", col) if any(x in str(col) for x in set(('[', ']', '<'))) else col for col in df.columns.values]
Error:---------------------------------------------------------------------------
ValueError Traceback (most recent call last)
<ipython-input-4-8fdb17ecdc00> in <module>
----> 1 data_dmatrix = xgb.DMatrix(data=X, label=y)
2 df.columns = [regex.sub("_", col) if any(x in str(col) for x in set(('[', ']', '<'))) else col for col in df.columns.values]
~\Anaconda3\lib\site-packages\xgboost\core.py in __init__(self, data, label, weight, base_margin, missing, silent, feature_names, feature_types, nthread)
493 self.set_base_margin(base_margin)
494
--> 495 self.feature_names = feature_names
496 self.feature_types = feature_types
497
~\Anaconda3\lib\site-packages\xgboost\core.py in feature_names(self, feature_names)
956 not any(x in f for x in set(('[', ']', '<')))
957 for f in feature_names):
--> 958 raise ValueError('feature_names must be string, and may not contain [, ] or <')
959 else:
960 # reset feature_types also
ValueError: feature_names must be string, and may not contain [, ] or <