All Questions
Tagged with sklearn-pandas linear-regression
49 questions
1
vote
2
answers
75
views
I want to create a linear regression scatterplot for an assignment. State names are giving me an error (?)
I am working on a project tracking poverty across the US between 1995 and 2020.
As I am working on a linear regression scatterplot, I have this:
# Create a regression object.
regression = ...
0
votes
1
answer
230
views
How to find RMSE without test value in python [closed]
First, I am wondering if is there a way to find the RMSE value with the y-test value(I can do it if I have a y-test value). For instance, we have train data and test data. But in the test data, we don'...
0
votes
1
answer
364
views
Linear regression (Plotting a regression line)
I am trying to plot a regression line for my assignment as shown below.
# Basic Libraries
import numpy as np
import pandas as pd
import seaborn as sb
import matplotlib.pyplot as plt
sb.set()
from ...
1
vote
1
answer
46
views
Predicted y during training by linear regression
I'm doing a linear regression:
lr = LinearRegression(fit_intercept=True)
lr.fit(X_train, y_train)
print("R2 OLS: " + str(lr.score(X_train, y_train)))
It is easy to get the predicted values ...
0
votes
1
answer
198
views
ValueError: Expected 2D array, got 1D array instead in Ridge Regression Prediction Model
I'm building a prediction model that takes user input for different movie attributes and returns the gross revenue. I have two questions:
I am getting a ValueError for reshaping. I'm not sure where ...
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
1
answer
1k
views
Apply Linear Regression Prediction to Dataframe in Python
I have a linear regression model that I've run, and I'm wanting to apply it to each row in a Data frame to compare the residuals with another model. I'm stuck with how to apply the prediction to each ...
1
vote
1
answer
3k
views
AttributeError: 'LinearRegression' object has no attribute 'coef_'
I am self-studying machine learning and python. I am using sklearn and I want to plot the regression line, but I get the attributeError: 'LinearRegression' object has no attribute 'coef_. Could ...
0
votes
1
answer
562
views
Linear Regression ValueError: Input contains NaN, infinity or a value too large for dtype('float64')
I'm working on a linear regression model and I'm getting the error:
ValueError: Input contains NaN, infinity or a value too large for dtype('float64')
Here's my code:
### List Column Data Types ...
0
votes
0
answers
465
views
Linear Regression TypeError: float() argument must be a string or a number, not 'NaTType'
I am currently working on a linear regression model to try and predict prices of certain shoes. After loading in the data frames for the training data and the data to test and dropping the unwanted ...
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) ...
1
vote
0
answers
125
views
how to use Date in string in LinearRegression model
i want to use date like 8/12/2004 in LinearRegression model and convert all of the dataset to range like(0.2008)strong text in order to sort date
0
votes
1
answer
61
views
Why line fit is not drawn?
I'm trying to plot a simple line fit using sklearn linear regression. Unfortunately, for some reason, the line fit itself is not drawn.
import numpy as np
from sklearn.linear_model import ...
1
vote
1
answer
47
views
Using Python to build a linear regression model and find R2'd; cannot get the model to fit or predict
Some imports for several reasons
import pandas as pd
import numpy as np
I successfully split the data -test(30%) and train(70%) and separated it:
X_train = df_train.drop(columns='Rating')
y_train = ...