# Questions tagged [regression]

4281 questions

votes
2

answer
852

Views

### How to interpret MSE in Keras Regressor

I am new to Keras/TF/Deep Learning and I am trying to build a model to predict house prices. I have some features X (no. of bathrooms , etc.) and target Y (ranging around \$300,000 to \$800,000) I have used sklearn's Standard Scaler to standardize Y before fitting it to the model. Here is my Keras mod...
Ivan

votes
3

answer
356

Views

### Mini Batch Gradient Descent, adam and epochs

I am taking a course on Deep Learning in Python and I am stuck on the following lines of an example: regressor.compile(optimizer = 'adam', loss = 'mean_squared_error') regressor.fit(X_train, y_train, epochs = 100, batch_size = 32) From the definitions I know, 1 epoch = going through all training ex...
Eyal2000

votes
2

answer
12

Views

### Fitting Logistic Regression model to MNIST data takes very long

I am trying to apply LogisticRegression model from sklearn to the MNIST dataset and i have split the training - test data into a 70-30 split. However, when i simply say model.fit(train_x, train_y) it takes a very long time. I have added no parameters when initiating logisticregression. code : im...
TheNoob

votes
0

answer
23

Views

### How to create a loop on linear regression in Rstudio?

I have data that looks something like this, there is time series data for many Rute over multiple RASK. Rute Year Month RASK Fare A 2017 1 10 38 A 2017 2 9 37 A 2017 3 11 40 A 2017 4 12 42 B 2017 5 13 45 B 2017 6 1...

votes
0

answer
13

Views

### Any better idea to build regression model for crime data?

I am trying to understand how crime frequency affect house price in certain area. To do so, I started with Chicago crime data and zillow real estate data. I want to understand the relation between house price and crime frequency and top 5 crimes in certain areas. Initially, I build up model for this...
beyond_inifinity

votes
0

answer
17

Views

### How to do weighting in regression in SAS?

I've set up a table with age and average spending by age. Age is my dependent variable. In my dataset, I have a lot of members at age 21, so I need to put more weight on it when I run regression in SAS. I'm new to SAS. I have used that regression button, but have not written codes. Is there another...
Pumpkin

votes
0

answer
3

Views

### Ordinal Regression (polr)

I am trying to implement Ordinal Regression on a data set. Where Class is my target variable with levels(HIGH, MEDIUM & LOW). Following are the attributes of my data set. 'Customer' 'Customer.No' 'Shop' 'Invoice' 'Quantity' 'Sales' 'Cash.Amt'...
Rutaba

votes
1

answer
10.8k

Views

### confusionMatrix for logistic regression in R

I want to calculate two confusion matrix for my logistic regression using my training data and my testing data: logitMod = 0.5, train\$LoanStatus_B == 1)) And the the code below works well for my training set. However, when i use the test set: confusionMatrix(table(predict(logitMod, type='response')...
Pumpkin C

votes
4

answer
93

Views

### Linear regression with two variables on python

I am developing a code to analyze the relation of two variables. I am using a DataFrame to save the variables in two columns as it follows: column A = 132.54672, 201.3845717, 323.2654551 column B = 51.54671995, 96.38457166, 131.2654551 I have tried to use statsmodels but it says that I do not hav...
Hugo Assis Brandao

votes
3

answer
500

Views

### Logistic regression - eval(family\$initialize) : y values must be 0 <= y <= 1

I am trying to perform logistic regression using R in a dataset provided here : http://archive.ics.uci.edu/ml/machine-learning-databases/00451/ It is about breast cancer. This dataset contains a column Classification which contains only 1 (if patient doesn't have cancer) or 2 (if patient has cancer)...
Ilan

votes
1

answer
42

Views

### Run several regressions in a function

I want to write a function that I can pass a data.table, a column in this data.table as the dependant variable and several columns as regressors. create_tables
Florestan

votes
1

answer
44

Views

### Why is this code yielding erroneous P-values?

I am trying to calculate P-values associated with point estimates obtained from a Cox PH model with time-varying coefficients. The function that I have written does not provide the correct P-values. I will illustrate this by making use of the NCCTG Lung Cancer Data from the survival package. # Setup...
Dion

votes
1

answer
425

Views

### What is the Search/Prediction Time Complexity of Logistic Regression?

I am looking into the time complexities of Machine Learning Algorithms and I cannot find what is the time complexity of Logistic Regression for predicting a new input. I have read that for Classification is O(c*d) c-beeing the number of classes, d-beeing the number of dimensions and I know that for...
Ana Smile

votes
2

answer
41

Views

### Scikit learn order of coefficients for multiple linear regression and polynomial features

I'm fitting a simple polynomial regression model, and I want get the coefficients from the fitted model. Given the prep code: import pandas as pd from itertools import product from sklearn.linear_model import LinearRegression from sklearn.preprocessing import PolynomialFeatures from sklearn.pipeline...
rovyko

votes
0

answer
4

Views

### How to fix negative chi-square values in nested model comparisons (SUDAAN/SAS)

We are conducting a series of logistic regressions comparing nested models (comparing 4-predictor models with 3-predictor models; each model contains one continuous variable). The variable added in the 4-predictor models is highly correlated with another predictor included in the model (~0.9). We ar...
ach

votes
2

answer
29

Views

### How to create a function to perform regressions for a range of variables and extract model estimates: e.g. coefficients, p-values?

I'm currently performing multiple linear regression analyses across a range of dependent variables (almost 200) and would like to create a function that runs this for a specified set of columns, then extracts relelvant model estimates, e.g. Beta-coefficients and p-values. Simulated data: df = data.f...
M_Oxford

votes
0

answer
39

Views

### why does change in data doesn't change the plot line?

I am new to machine learning and i am building a simple linear regession model. The variables for the model are as follows: X_train = [3, 5, 3, 4, 8, 7, 1, 10, 3, 2, 6, 6, 4, 9, 2, 1, 7, 5, 4, 8] X_test = [2, 10, 4, 4, 10, 9, 10, 4, 5, 8] Y_train = [56642, 66029, 64445, 61111, 113812, 91738, 46205,...
Samarth Saxena

votes
0

answer
92

Views

### Singularity error when doing Tobit regression

I'm trying to estimate a standard tobit model which is censored left at zero. Variables are Dependent variable: Happiness Independent variable: City(Chicago,New York), Gender(Man,Woman), Employment(0=Unemployed, 1=Employed), Worktype(Unemployed, Bluecolor, Whitecolor), Holiday(Unemployed, 1day a wee...
Daniel Cho

votes
1

answer
87

Views

### predict.glm() on blind test data

I'm using regularized logistic regression for a classification problem using the glmnet package. In the development process, everything is working fine, but I have a problem when it comes to making predictions on blind test data. Because I don't know the class label, my data frame for testing has a...
ahanf

votes
0

answer
514

Views

### Is passing sklearn tfidf matrix to train MultinomialNB model proper?

I'm do some text classification tasks. What I have observed is that if fed tfidf matrix(from sklearn's TfidfVectorizer), Logistic Regression model is always outperforming MultinomialNB model. Below is my code for training both: X = df_new['text_content'] y = df_new['label'] X_train, X_test, y_train,...
ZEE

votes
1

answer
19

Views

### Codename One Form.removeAllCommands() dosn't seem to work any longer

We have a form manager system we have used in a number of Codename One apps. This system includes a process for populating the side menu. When the menu is updated removeAllCommands() is used on the form to clear out the current items in the side menu. Then the updated ones are added back in. At some...

votes
0

answer
329

Views

### Linearmodels value error - do not have full column rank

This is similar to another question. I'm running a 2-stage least square regression with set of categorical variables. I've run the model successfully once but when I tried to replicate the model it ran into this error: ValueError: instruments [exog instruments] do not have full column rank As fa...
R_Queery

votes
0

answer
164

Views

### How do I propagate the error of a linear regression when projecting from Y to X?

I'm trying to figure out how to propagate errors in the following case I am calibrating a machine with a couple of standards (a, b, c) with accepted values x. My machine measures y for these standards, with a certain error (standard deviation of 1 in this example). Then I measure replicates of a sam...
Japhir

votes
0

answer
103

Views

### Admitted data type in RFE to keep features in a logistic regression

I'm trying to build a logistic regression in python with a dataset that contains continuous features and some binary features. In order to choose the features that I will include in the model I am using RFE. So basically I have this code y=HRData['left'] collist = HRData.columns.tolist() collist.rem...
Maria F Cadena

votes
0

answer
20

Views

### write functional regression test for nova

I have an open bug in gerrit here code reviewer ask me to write functional regression test for the changes, anyone can help me to do that? Thanks in advance.
Ameed

votes
1

answer
71

Views

### How to create an easy to explain regression model in Python with categorical features?

I have a dataset that looks like this, where each row is a user. gender age_group c1 c2 c3 total_cost F 0-10 10 F1234 3456 135.2 F 65-100 10 G5143 876 523.6 M 18-35 15 F3457 876 98.5 F 0-10 10 F1234 545 1052.1 M 35-65 2...
sfactor

votes
1

answer
133

Views

### The fit function from tf.contrib.learn.LinearRegressor asks to switch to tf.train.get_global_step

I am trying to get a LinearRegressor to work and I get an error for which there doesn't seem to be much documentation about. When I do: regressor = tf.contrib.learn.LinearRegressor(feature_columns=linear_features) regressor.fit(input_fn=training_input_fn, steps=10000) regressor.evaluate(input_fn=eva...
Trufa

votes
0

answer
389

Views

### Uncomprehensibly high loss value in regression

Based on some research and experimentation, I'm trying to build a Keras regressor for a few select input attributes which I've run feature selection on to determine importance. Now, the loss is insanely high, along the lines of loss: 70155460.5246 - mean_squared_error: 70155460.5246. Scaling the in...
Ishwar

votes
1

answer
100

Views

### train the network with matlab matconvnet

I want to train my network using matlab and matconvnet-1.0-beta25. My problem is regression and I use pdist as loss function to get mse. The inputs data is 56*56*64*6000 and the targets data is 56*56*64*6000 and network architecture is as follows: opts.networkType = 'simplenn' ; opts = vl_argparse(o...

votes
1

answer
1.8k

Views

### tensorflow random forest regression

I would like to implement a simple random forest regression to predict a value. The inputs are some samples with several features, and the label is a value. However, I cannot find a simple example about the random forest regression problem. Thus, I saw the document of tensorflow and I found that: An...
rita33cool1

votes
0

answer
74

Views

### Error in if (object\$offset) { : argument is of length zero in relaxnet R package

I want to perform a cross validation to select tuning parameter for relaxed lasso model using relaxnet package. Below I have attached a sample code that is closely related to the one from relaxnet vignette but with a two level factor as a response variable: nobs
CherryGarcia

votes
1

answer
66

Views

### Flexible, variable number of regressors in glm

I have a set of linear regressions (lets assume 100) that I need to run with variable number of regressors in R. Some of the regressors are common to all 100 regression models, but others are variable and depends on the specific dependent variable. As an example, here are three such models: Y1 ~ x1...
VWarrier

votes
0

answer
146

Views

### Phpml\Exception\MatrixException Message: Matrix is singular

I'm making a program that will predict the next year's collection from the database using php-ml. and I'm getting this error. Phpml\Exception\MatrixException Message: Matrix is singular Im using this functions use Phpml\Regression\LeastSquares; use \Phpml\Math\Matrix; use \Phpml\Math\Set; newbie he...
stephoroi

votes
0

answer
33

Views

### Running in spark MLlib in Databricks , how to interpret the one more weighs in logistic regression

I have 12 feature variables, but why are there 13 weighs shown here for logistic regression in spark MLlib Databricks? How can I interpret it? Following this link it says: 'intercept – Intercept computed for this model. (Only used in Binary Logistic Regression, the intercepts will not bea single v...
Mia

votes
1

answer
149

Views

### Plotting multiple effect plots from logistic regression

I have a number of logistic regression models with different response variables but the same predictor variables. I want to use grid.arrange (or anything else) to make a single figure with all these effect plots that were made with the effects package. I followed the advice here to make such a gra...
person

votes
0

answer
332

Views

### Multivariable linear regression in JS

I am trying to perform multivariable linear regression with a single dependent variable Y and two independent variables x1, x2. This is simply an OLS regression with an additional dependent variable: Y = b0 + b1 x1 + b2 x2 I need to also calculate the correlation coefficient R^2 for this relationsh...
Martin

votes
0

answer
62

Views

### How to generate the diagnostic regression plots of rbase to an object that is not a lm class?

I would like to generate the regression diagnostic plots from the base of r, to a 'non-lm' object. ## Generate reg. with lm function set.seed(2458840) x
Mario GS

votes
0

answer
291

Views

### Any workaround to program incremental SGD algorithm sequentially for logistic regression?

I am trying to program incremental stochastic gradient descent (ISGD) algorithm in logistic regression. Initially, I coded respective logistic regression' loss function and its gradient, also got some idea to proceed rest of workflow. But, I have no idea how to apply sequential operation in incremen...
Andy.Jian

votes
1

answer
89

Views

### Linear regression with two independent variables in javascript

The following will output the slope, intercept and correlation coefficient R^2 for a given set of x and y values. let linearRegression = (y,x) => { let lr = {} let n = y.length let sum_x = 0 let sum_y = 0 let sum_xy = 0 let sum_xx = 0 let sum_yy = 0 for (let i = 0; i < y.length; i++) { sum_x += x[i]...
Martin

votes
0

answer
226

Views

### Why does the DNNRegressor in tensorflow.estimator cannot fit to a sin function?

I am a new comer to tensorflow and its estimators. I try to use its DNNRegressor to fit data generated by a sin function. However, it does not work and it seems that the regressor fail to work. I would appreciate if any experienced researher or engineer could give me an answer. Thanks a lot! import...
wei liu