linear-regression

How to change decimal format inside a transform_calculate function (Altair)

How to change decimal format inside a transform_calculate function (Altair) Question: I’m trying to limit the numbers after the decimal in the text displayed in my graph, but I’m having a hard time doing so inside a transform_calculate function, this is what it looks like : (I am printing the equation to a linear regression …

Total answers: 1

Getting infinity values from gradient descent

Getting infinity values from gradient descent Question: I’m trying to implement a multivariable linear regression with gradient descent but when I try this: # Starting values w = np.ones(3) # The number of features is 3 b = float(0) def gradient_descent(): global w global b learning_rate = 0.0001 for i in range(x_train.shape[0]): prediction = np.dot(x_train[i], …

Total answers: 2

How to correctly plot a linear regression on a log10 scale?

How to correctly plot a linear regression on a log10 scale? Question: I am plotting two lists of data against each other, namely freq and data. Freq stands for frequency, and data are the numeric observations for each frequency. In the next step, I apply the ordinary linear least-squared regression between freq and data, using …

Total answers: 2

How to create Predicted vs. Actual plot using abline_plot and statsmodels

How to create Predicted vs. Actual plot using abline_plot and statsmodels Question: I am trying to recreate this plot from this website in Python instead of R: Background I have a dataframe called boston (the popular educational boston housing dataset). I created a multiple linear regression model with some variables with statsmodels api below. Everything …

Total answers: 1

Pytorch Linear regression 1x1d, consistantly wrong slope

Pytorch Linear regression 1x1d, consistantly wrong slope Question: I am mastering pytorch here, and decided to implement very simple 1 to 1 linear regression, from height to weight. Got dataset: https://www.kaggle.com/datasets/mustafaali96/weight-height but any other would do nicely. Lets import libraries and information about females: import torch from torch.utils.data import Dataset from torch.utils.data import DataLoader import …

Total answers: 4

linear regression: my plotting doesn't show the line

linear regression: my plotting doesn't show the line Question: I am working on implementing from scratch a linear regression model means without using Sklearn package. all was working just fine , until i tried ploting the result. my fit line isn’t showing: i looked at a bunch of solution but neither of them was for …

Total answers: 2

Linear regression for time series

Linear regression for time series Question: I am pretty new to Machine Learning and have some confusion, so sorry for trivial question. I have time series data set, very simple with two columns – Date and Price. I’m predicting the price and want to add some features to my model like moving average for last …

Total answers: 2

ValueError:Reshape your data either using array.reshape(-1, 1)if your data has a single feature or array.reshape(1, -1) if it contains a single sample

ValueError:Reshape your data either using array.reshape(-1, 1)if your data has a single feature or array.reshape(1, -1) if it contains a single sample Question: **the code predict the house price with polynomial regression model and fastapi **` make class have an one parameter and have a 4 value class features(BaseModel): X2_house_age: float X3_distance_to_the_nearest_MRT_station: float X4_number_of_convenience_stores: float …

Total answers: 1

Getting ValueError: Expected 2D array, got 1D array instead:

Getting ValueError: Expected 2D array, got 1D array instead: Question: When I run this code I am getting an error. I am a newbie. Please help me. Thanks in advance. from sklearn import linear_model from sklearn.metrics import mean_squared_error, r2_score import pandas as pd df_percentage = (pd.read_csv("Data.csv", sep=’;’)) print(df_percentage) x=df_percentage.Percentage y=df_percentage.Peakintensity x = x.reshape(-1,1) from sklearn.model_selection …

Total answers: 1

Linear Regression with np.arrays and scipy.stats

Linear Regression with np.arrays and scipy.stats Question: I’m trying to do a linear regression on two 2×3 arrays, one of x values and one of y values where each row is a separate data set, but when I try to compute it on the whole array: import numpy as np from scipy.stats import linregress sigma …

Total answers: 1