All Questions
18 questions
0
votes
1
answer
4k
views
UserWarning: X does not have valid feature names, but LinearRegression was fitted with feature names warnings.warn(
screenshot here Help please?
Already tried adding .values to the X's, still resulted in an error. Any suggestions?
X = df[['Personal income','Personal saving']]
y = df['Gross domestic product']
...
0
votes
0
answers
308
views
Multiple Linear Regression Model - ValueError: X has 6 features, but LinearRegression is expecting 22 features as input
I have fitted a Linear Regression model using sklearn in python using 22 columns of training data in order to predict market prices. See below:
#X_train is our training values to predict y
X_train = ...
0
votes
0
answers
214
views
Linear Regression complains about array shape
I'm trying to fit a column in pandas dataframe with sklearn LinearRegression(). I follow the example here: Linear Regression on Pandas DataFrame using Sklearn ( IndexError: tuple index out of range) ...
4
votes
1
answer
2k
views
python linear regression: dense vs sparse
I need to use linear regression on a sparse matrix. I have been getting poor results, so I decided to test it on a non-sparse matrix represented sparsely. The data is taken from https://www....
0
votes
0
answers
255
views
Interpreting array of coefficients for multiple regression
I created a multiple regression model with sklearn and used .coef_ to get the coefficients. It returned an array of coefficients but I am not sure what each one represents. Could someone help me ...
1
vote
1
answer
268
views
Perform linear regression with sunspot dataset
I'm trying to perform a linear regression using k-fold validation, in the sunspost dataset.
In this exercise I need to take the last 10 years as test and use the rest for tranning, further I should ...
0
votes
1
answer
2k
views
Returns TypeError: 'LinearRegression' object is not callable. Other answers with this error say LinearRegression has not been initialized
I have looked up questions with similar errors and thought I had followed the steps to initialize LinearRegression with the lines
linreg_mean_dif = LinearRegression().fit(X_train_dif, y_train_dif)
...
-1
votes
1
answer
744
views
Python NameError: name 'ridge_regression_sklearn' is not defined
I am working on Cross validation for k-fold using ridge regression. I want to do y_pred using ridge_regression_sklearn and got the error message that 'ridge_regression_sklearn' is not defined.
Some ...
0
votes
1
answer
169
views
Unable to make Prediction on Test Data
#Linear Regression Model
from sklearn import linear_model
linear_model = linear_model.LinearRegression()
linear_model.fit(x_train, y_train)
print("Linear Model Coefficients:", linear_model.coef_)
...
0
votes
1
answer
85
views
Sklearn Fit Linear Regression [closed]
I have this problem:
regression.fit(X_train, y_train)
I got the following error:
ValueError: Expected 2D array, got 1D array instead:
array=[ 2.9 5.1 3.2 4.5 8.2 6.8 1.3 10.5 3. 2.2 5.9 ...
0
votes
1
answer
834
views
How to get the 4th order of polynomial from random generated values and reshape array from (100) to (100,4)?
I'm trying to implement the fourth-order of the polynomial and implemented the following logic with the following instructions:
first of all, import PolynomialFeatures function from scikit-learn
and ...
1
vote
1
answer
2k
views
already installed but ModuleNotFoundError: No module named 'sklearn'
I'm pretty sure I have installed scikit learn because I've tried pip install and Conda in terminal and I get the message "# All requested packages already installed." but when I run my code in Python ...
0
votes
0
answers
832
views
R^2 negative using sklearn and 0.92 using statsmodels
I am so confused. I am comparing lasso and linear regression on a model that predicts housing prices. I don't understand how when I run a linear model in sklearn I get a negative for R^2 yet when I ...
1
vote
1
answer
749
views
Getting shape not aligned error sklearn .
import pandas as pd
from sklearn.model_selection import train_test_split
from sklearn.linear_model import LinearRegression
Dataset = pd.read_csv('Salary_Data.csv')
Salary , YearsExperience = Dataset['...
2
votes
2
answers
3k
views
Using sklearn linear regression, how can I constrain the calculated regression coefficients to be greater than 0?
I'm using the reference for sklearn here http://scikit-learn.org/stable/modules/generated/sklearn.linear_model.LinearRegression.html but there is no option to constrain the regression coefficients.
...