linear-regression

Simple prediction using linear regression with python

你离开我真会死。 提交于 2020-07-06 10:49:12
问题 data2 = pd.DataFrame(data1['kwh']) data2 kwh date 2012-04-12 14:56:50 1.256400 2012-04-12 15:11:55 1.430750 2012-04-12 15:27:01 1.369910 2012-04-12 15:42:06 1.359350 2012-04-12 15:57:10 1.305680 2012-04-12 16:12:10 1.287750 2012-04-12 16:27:14 1.245970 2012-04-12 16:42:19 1.282280 2012-04-12 16:57:24 1.365710 2012-04-12 17:12:28 1.320130 2012-04-12 17:27:33 1.354890 2012-04-12 17:42:37 1.343680 2012-04-12 17:57:41 1.314220 2012-04-12 18:12:44 1.311970 2012-04-12 18:27:46 1.338980 2012-04-12

Simple prediction using linear regression with python

落爺英雄遲暮 提交于 2020-07-06 10:49:06
问题 data2 = pd.DataFrame(data1['kwh']) data2 kwh date 2012-04-12 14:56:50 1.256400 2012-04-12 15:11:55 1.430750 2012-04-12 15:27:01 1.369910 2012-04-12 15:42:06 1.359350 2012-04-12 15:57:10 1.305680 2012-04-12 16:12:10 1.287750 2012-04-12 16:27:14 1.245970 2012-04-12 16:42:19 1.282280 2012-04-12 16:57:24 1.365710 2012-04-12 17:12:28 1.320130 2012-04-12 17:27:33 1.354890 2012-04-12 17:42:37 1.343680 2012-04-12 17:57:41 1.314220 2012-04-12 18:12:44 1.311970 2012-04-12 18:27:46 1.338980 2012-04-12

R^2 score is not well-defined with less than two samples. Python Sklearn

╄→гoц情女王★ 提交于 2020-06-29 03:50:26
问题 I am using a Linear Regression classifier to predict some values. I already figured the basic part of the out and now it looks like this: import time as ti import pandas as pd import numpy as np from matplotlib import pyplot as plt import csv from sklearn.datasets import load_boston from sklearn import preprocessing, svm from sklearn.model_selection import train_test_split from sklearn import linear_model from scipy.interpolate import * import datetime data = pd.read_csv(r"C:\Users\simon

Computing weights in linear regression problem

白昼怎懂夜的黑 提交于 2020-06-27 16:52:05
问题 I have written the script that demonstrates the linear regression algorithm as follows: training_epochs = 100 learning_rate = 0.01 # the training set x_train = np.linspace(0, 10, 100) y_train = x_train + np.random.normal(0,1,100) # set up placeholders for input and output X = tf.placeholder(tf.float32) Y = tf.placeholder(tf.float32) # set up variables for weights w0 = tf.Variable(0.0, name="w0") w1 = tf.Variable(0.0, name="w1") y_predicted = X*w1 + w0 # Define the cost function costF = 0.5*tf

Using scikit-learn (sklearn), how to handle missing data for linear regression?

给你一囗甜甜゛ 提交于 2020-06-27 07:23:14
问题 I tried this but couldn't get it to work for my data: Use Scikit Learn to do linear regression on a time series pandas data frame My data consists of 2 DataFrames. DataFrame_1.shape = (40,5000) and DataFrame_2.shape = (40,74) . I'm trying to do some type of linear regression, but DataFrame_2 contains NaN missing data values. When I DataFrame_2.dropna(how="any") the shape drops to (2,74) . Is there any linear regression algorithm in sklearn that can handle NaN values? I'm modeling it after the

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

一个人想着一个人 提交于 2020-06-27 07:20:11
问题 While practicing Simple Linear Regression Model I got this error, I think there is something wrong with my data set. Here is my data set: Here is independent variable X: Here is dependent variable Y: Here is X_train Here Is Y_train This is error body: ValueError: Expected 2D array, got 1D array instead: array=[ 7. 8.4 10.1 6.5 6.9 7.9 5.8 7.4 9.3 10.3 7.3 8.1]. 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

Multivariate Linear Regression in c++ [closed]

谁说胖子不能爱 提交于 2020-06-27 04:49:14
问题 Closed . This question needs to be more focused. It is not currently accepting answers. Want to improve this question? Update the question so it focuses on one problem only by editing this post. Closed 6 years ago . Improve this question I have a vector A[a1, a2, a3] and B[b1, b2, b3]. I want to find a "correlation" matrix X (3x3) that can predict from new incoming data of A' to to produce output predictions of B'. Basically in the end: A'*X to get B'. I have lots of recorded data of A and B

Neural Network unable to learn

丶灬走出姿态 提交于 2020-06-27 04:14:19
问题 I am following trask's article to build a bare bone neural network in Python. Though he builds 1 layer Network (that maps 3 inputs to a single output) and a 2 layer network (that has 3 inputs, 4 neuron hidden layer and output layer with single neuron). My task was to build a network that can approximate the function Y = X1 + X2 + X3 . I provide the network with Y and it guesses values of x1, x2 and x3. For this, I modified the above network. I tried to invert both above networks, i.e, tried

Using Linear Regression for Yearly distributed Time Series Data to get predictions after -N- years

家住魔仙堡 提交于 2020-06-26 14:56:15
问题 I am stuck with a very unique problem. I have Time Series Data where the data is given from the years 2009 to 2018. Problem is that I am to answer a very weird question using this data. Data sheets contains the energy generation statistics of each Australian State/Territory in GWh (​ Gigawatt​ hours) for the year 2009 to 2018. There are following fields: State: Names of different Australian states. Fuel_Type: ​ The type of fuel which is consumed. Category: ​ Determines whether a fuel is

ValueError: Expected 2D array, got scalar array instead

本小妞迷上赌 提交于 2020-06-22 12:52:11
问题 While practicing Simple Linear Regression Model I got this error: ValueError: Expected 2D array, got scalar array instead: array=60. 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. This is my code (Python 3.7): import pandas as pd import numpy as np import matplotlib.pyplot as plt from sklearn.linear_model import LinearRegression from sklearn.metrics import r2_score data = pd.read_csv("hw_25000.csv")