regression

Regression confidence using SVMs in python

旧城冷巷雨未停 提交于 2019-12-10 11:43:19
问题 I'm using regression SVMs in python and I am wondering if there is any way to get a "confidence-measure" value for its predictions. Previously, when using SVMs for binary classification, I was able to compute a confidence-type value from the 'margin'. Here is some pseudo-code showing how I got a confidence value: # Begin pseudo-code import svm as svmlib prob = svmlib.svm_problem(labels, data) param = svmlib.svm_parameter(svm_type=svmlib.C_SVC, kernel_type = svmlib.RBF) model = svmlib.svm

Automatic vlookup and multiply coefficients with R

陌路散爱 提交于 2019-12-10 10:17:57
问题 I´m trying to code a function in R (stats programming language) that would allow me to automate the calculation of a linear regression (lm) The problem: The regression is calculated through the "step" function, so the coefficients selected cannot be known in advance. Problem Automate identifying the coefficients selected by the step function. Vlookup and cross multiply the second column of the results Ex."View(OpenCoefs)" (estimates) with the last row(last day) of respective columns of the

Automatically use LRT to assess significance of entire factor variable

别说谁变了你拦得住时间么 提交于 2019-12-10 09:43:15
问题 R's output for a multivariable regression model including one or more factor variable does not automatically include a likelihood ratio test (LRT) of the significance of the entire factor variable in the model. For example: fake = data.frame( x1=rnorm(100), x2=sample(LETTERS[1:4], size=100, replace=TRUE), y=rnorm(100) ) head(fake) x1 x2 y 1 0.6152511 A 0.7682467 2 -0.8215727 A -0.5389245 3 -1.3287208 A -0.1797851 4 0.5837217 D 0.9509888 5 -0.2828024 C -0.9829126 6 0.3971358 B -0.4895091 m =

How do I add regression lines to a scatterplot matrix?

跟風遠走 提交于 2019-12-10 06:00:48
问题 How do I go about adding regression lines to a scatterplot matrix? I have the following script: NewNEMSIS = read.csv("NewNEMSIS.csv") library(gclus) newmatrix = NewNEMSIS[,2:5] newmatrix.r = abs(cor(newmatrix)) newmatrix.col = dmat.color(newmatrix.r) area = NewNEMSIS$area cpairs(newmatrix[which(area=="A"),c('Response','SceneToPatient','TotalScene','TotalCall')], panel.colors=newmatrix.col, gap=.5, main="Scatterplot Matrix of City A Times", ylim=c(0,60), xlim=c(0,60), na.omit=TRUE, ) How can I

Python Keras cross_val_score Error

吃可爱长大的小学妹 提交于 2019-12-10 02:06:40
问题 I am trying to do this little tutorial on keras about regression: http://machinelearningmastery.com/regression-tutorial-keras-deep-learning-library-python/ Unfortunately I am running into an error I cannot fix. If i just copy and paste the code I get the following error when running this snippet: import numpy import pandas from keras.models import Sequential from keras.layers import Dense from keras.wrappers.scikit_learn import KerasRegressor from sklearn.model_selection import cross_val

Difference between the interaction : and * term for formulas in StatsModels OLS regression

谁说我不能喝 提交于 2019-12-09 13:15:50
问题 Hi I'm learning Statsmodel and can't figure out the difference between : and * (interaction terms) for formulas in StatsModels OLS regression. Could you please give me a hint to figure this out? Thank you! The documentation: http://statsmodels.sourceforge.net/devel/example_formulas.html 回答1: ":" will give a regression without the level itself. just the interaction you have mentioned. "*" will give a regression with the level itself + the interaction you have mentioned. for example a .

Python Multiple Simple Linear Regression

大憨熊 提交于 2019-12-09 12:41:12
问题 Note this is not a question about multiple regression, it is a question about doing simple (single-variable) regression multiple times in Python/NumPy (2.7). I have two m x n arrays x and y . The rows correspond to each other, and each pair is the set of (x,y) points for a measurement. That is, plt.plot(x.T, y.T, '.') would plot each of m datasets/measurements. I'm wondering what the best way to perform the m linear regressions is. Currently I loop over the rows and use scipy.stats.linregress

Factor levels default to 1 and 2 in R | Dummy variable

大兔子大兔子 提交于 2019-12-09 06:56:52
问题 I am transitioning from Stata to R. In Stata, if I label a factor levels (say--0 and 1) to (M and F), 0 and 1 would remain as they are. Moreover, this is required for dummy-variable linear regression in most software including Excel and SPSS. However, I've noticed that R defaults factor levels to 1,2 instead of 0,1. I don't know why R does this although regression internally (and correctly) assumes 0 and 1 as the factor variable. I would appreciate any help. Here's what I did: Try #1: sex<-c

What does predict.glm(, type=“terms”) actually do?

走远了吗. 提交于 2019-12-09 06:07:49
问题 I am confused with the way predict.glm function in R works. According to the help, The "terms" option returns a matrix giving the fitted values of each term in the model formula on the linear predictor scale. Thus, if my model has form f(y) = X*beta, then command predict(model, X, type='terms') is expected to produce the same matrix X, multiplied by beta element-wise. For example, if I train the following model test.data = data.frame(y = c(0,0,0,1,1,1,1,1,1), x=c(1,2,3,1,2,2,3,3,3)) model =

Any Python Library Produces Publication Style Regression Tables

丶灬走出姿态 提交于 2019-12-09 04:04:02
问题 I've been using Python for regression analysis. After getting the regression results, I need to summarize all the results into one single table and convert them to LaTex (for publication). Is there any package that does this in Python? Something like estout in Stata that gives the following table: 回答1: Well, there is summary_col in statsmodels ; it doesn't have all the bells and whistles of estout , but it does have the basic functionality you are looking for (including export to LaTeX):