在XGBoost回归中预测价格,如何获取系数,模型的截距?像我们在Statsmodel中获得线性回归一样,如何获取模型摘要? 参见下面的代码
import { Popover } from '@material-ui/core/'
import classnames from 'classnames'
import React from 'react'
import { withStyles } from '../styles/'
import { popoverStyles } from './styles'
const MYPopover = withStyles(popoverStyles)(class extends React.Component {
static displayName = 'MYPopover'
static propTypes = Popover.propTypes
render() {
const { props } = this
return (
<Popover {...{
...props,
className: classnames('my-popover', props.className)
}} />
)
}
})
export default MYPopover
from xgboost import XGBRegressor
# fit model no training data
model = XGBRegressor()
model.fit(X_train, y_train)
# make predictions for test data
y_pred = model.predict(X_test)
这是我建立模型并尝试获得这样的系数的方法:
print("R^2: {}".format(model.score(X_test, y_test)))
rmse = np.sqrt(mean_squared_error(y_test, y_pred))
print("Root Mean Squared Error: {}".format(rmse))
#print the intercept
print(model.intercept_)
AttributeError: Intercept (bias) is not defined for Booster type gbtree
print(model.coef_)
有人可以帮我解决这个问题吗?谢谢。
答案 0 :(得分:1)