regression

AttributeError: module ‘xgboost’ has no attribute ‘XGBRegressor’

一笑奈何 提交于 2019-12-18 07:23:21
问题 I am trying to run xgboost using spyder and python, but I keep getting this error: AttributeError: module ‘xgboost’ has no attribute ‘XGBRegressor’ Here is the code: import xgboost as xgb xgb.XGBRegressor(max_depth=3, learning_rate=0.1, n_estimators=100, silent=True, objective='reg:linear', gamma=0, min_child_weight=1, max_delta_step=0, subsample=1, colsample_bytree=1, seed=0, missing=None) Error is Traceback (most recent call last): File "<ipython-input-33-d257a9a2a5d8>", line 1, in <module>

plot linear regressions lines without interaction in ggplot2

和自甴很熟 提交于 2019-12-18 06:08:02
问题 This code plots regression lines with interactions in ggplot2: library(ggplot2) ggplot(mtcars, aes(hp, mpg, group = cyl)) + geom_point() + stat_smooth(method = "lm") Can lines without interactions be plotted with stat_smooth ? 回答1: Workaround would be to make model outside the ggplot() . Then make predicition for this model and add result to the original data frame. This will add columns fit , lwr and upr . mod<-lm(mpg~factor(cyl)+hp,data=mtcars) mtcars<-cbind(mtcars,predict(mod,interval=

plot linear regressions lines without interaction in ggplot2

女生的网名这么多〃 提交于 2019-12-18 06:07:09
问题 This code plots regression lines with interactions in ggplot2: library(ggplot2) ggplot(mtcars, aes(hp, mpg, group = cyl)) + geom_point() + stat_smooth(method = "lm") Can lines without interactions be plotted with stat_smooth ? 回答1: Workaround would be to make model outside the ggplot() . Then make predicition for this model and add result to the original data frame. This will add columns fit , lwr and upr . mod<-lm(mpg~factor(cyl)+hp,data=mtcars) mtcars<-cbind(mtcars,predict(mod,interval=

Regression line for the entire dataset together with regression lines based on groups in R ggplot2 ?

て烟熏妆下的殇ゞ 提交于 2019-12-18 04:19:08
问题 I am new to ggplot2 and have problem displaying the regression line for the entire data-set together with the regression lines for groups. So far i can plot regression line based on the group but I have no success in getting the regression line for the entire data-set on the same plot. I want all the regression lines with different line style so that they can be easily identified in black and white print. Any help would be highly appreciated. here is my code so far: ggplot(alldata,aes(y = y,

Adding Regression Line Equation and R2 on SEPARATE LINES graph

非 Y 不嫁゛ 提交于 2019-12-18 04:18:20
问题 A few years ago, a poster asked how to add regression line equation and R2 on ggplot graphs at the link below. Adding Regression Line Equation and R2 on graph The top solution was this: lm_eqn <- function(df){ m <- lm(y ~ x, df); eq <- substitute(italic(y) == a + b %.% italic(x)*","~~italic(r)^2~"="~r2, list(a = format(coef(m)[1], digits = 2), b = format(coef(m)[2], digits = 2), r2 = format(summary(m)$r.squared, digits = 3))) as.character(as.expression(eq)); } p1 <- p + geom_text(x = 25, y =

Search for corresponding node in a regression tree using rpart

谁都会走 提交于 2019-12-18 04:15:33
问题 I'm pretty new to R and I'm stuck with a pretty dumb problem. I'm calibrating a regression tree using the rpart package in order to do some classification and some forecasting. Thanks to R the calibration part is easy to do and easy to control. #the package rpart is needed library(rpart) # Loading of a big data file used for calibration my_data <- read.csv("my_file.csv", sep=",", header=TRUE) # Regression tree calibration tree <- rpart(Ratio ~ Attribute1 + Attribute2 + Attribute3 + Attribute4

Non-linear regression in C#

牧云@^-^@ 提交于 2019-12-17 22:16:07
问题 I'm looking for a way to produce a non-linear (preferably quadratic) curve, based on a 2D data set, for predictive purposes. Right now I'm using my own implementation of ordinary least squares (OLS) to produce a linear trend, but my trends are much more suited to a curve model. The data I'm analysing is system load over time. Here's the equation that I'm using to produce my linear coefficients: I've had a look at Math.NET Numerics and a few other libs, but they either provide interpolation

Double clustered standard errors for panel data

戏子无情 提交于 2019-12-17 18:33:33
问题 I have a panel data set in R (time and cross section) and would like to compute standard errors that are clustered by two dimensions, because my residuals are correlated both ways. Googling around I found http://thetarzan.wordpress.com/2011/06/11/clustered-standard-errors-in-r/ which provides a function to do this. It seems a bit ad-hoc so I wanted to know if there is a package that has been tested and does this? I know sandwich does HAC standard errors, but it doesn't do double clustering (i

mgcv: How to set number and / or locations of knots for splines

 ̄綄美尐妖づ 提交于 2019-12-17 18:29:48
问题 I want to use function gam in mgcv packages: x <- seq(0,60, len =600) y <- seq(0,1, len=600) prova <- gam(y ~ s(x, bs='cr') can I set the number of knots in s() ? and then can I know where are the knots that the spline used? Thanks! 回答1: It is always disappointing to see a wrong answer... While setting k is the correct way to go, fx = TRUE is definitely not right: it will force using pure regression spline without penalization. locations of knots For penalized regression spline, the exact

Linear regression analysis with string/categorical features (variables)?

爱⌒轻易说出口 提交于 2019-12-17 17:26:37
问题 Regression algorithms seem to be working on features represented as numbers. For example: This dataset doesn't contain categorical features/variables. It's quite clear how to do regression on this data and predict price. But now I want to do regression analysis on data that contain categorical features: There are 5 features: District , Condition , Material , Security , Type How can I do regression on this data? Do I have to transform all this string/categorical data to numbers manually? I