I make this code
# Numeric Pipeline
num_pipeline = make_pipeline(RobustScaler(), PCA(n_components=0.95))
# Categorical Pipeline
cat_pipeline = make_pipeline(OneHotEncoder(handle_unknown="ignore"))
# Creating Column Transformer
preprocessing_pipeline = ColumnTransformer([
('num', num_pipeline, num_columns),
('cat', cat_pipeline, cat_columns)
])
# Full Pipeline
full_pipeline = make_pipeline(preprocessing_pipeline, LinearRegression())
# Tuning Parameters with GridSearchCV
param_grid = {
'linearregression__fit_intercept': [True, False], # Whether to calculate the intercept for this model
}
grid_LR = GridSearchCV(full_pipeline, param_grid, cv=6)
# Get the best linear regression model from the grid search
best_linear_reg_model = grid_LR.best_estimator_
from sklearn.ensemble import AdaBoostRegressor
# Create AdaBoostRegressor with the best linear regression model as the base estimator
ada_reg = AdaBoostRegressor(estimator=best_linear_reg_model, random_state=42)
# Fit Model
ada_reg.fit(X_train_overall, y_train)
I got this error
AttributeError: ‘numpy.ndarray’ object has no attribute ‘columns’
ValueError: Specifying the columns using strings is only supported for dataframes.
Fix this code or suggestion
New contributor
Darly Purba is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.