如何在 Tensorflow 上使用线性回归模型和我自己的数据
How to Use Linear Regression Model with My Own Data on Tensorflow
我有这样的数据集
[2016-10-24,23.00,76.00,1015.40,0.00,0.00,100.00,26.00,100.00,100.00,0.00,6.88,186.01,12.26,220.24,27.60,262.50,14.04,2.1] , [15.47]
[2016-10-24,22.00,73.00,1014.70,0.00,0.00,10.20,34.00,0.00,2.00,0.00,6.49,176.82,11.97,201.16,24.27,249.15,7.92,0.669999 ] , [16.14]
....
....
大小为 [n][19]、[n][1]。我想使用 Tensorflow 线性回归来预测 Python。我的意思是我想用这 19 个变量来预测 1 个变量。我有大数据集。我觉得足够训练了。
但是,我是机器学习和 Tensorflow 的初学者。你能给我任何文件或线索吗?
提前致谢。
这是一个简单的线性回归模型:
def model(X, w):
return tf.mul(X, w) # Just X*w so this model line is pretty simple
w = tf.Variable(0.0, name="weights")
y_model = model(X, w)
cost = tf.square(Y - y_model) # use square error for cost function
train_op = tf.train.GradientDescentOptimizer(0.01).minimize(cost)
然后你需要运行 TensorFlow会话下的train_op。
对于您的数据集,您只需更改 w 和 x。在 https://github.com/nlintz/TensorFlow-Tutorials/blob/master/01_linear_regression.py.
查看更多示例
我有这样的数据集
[2016-10-24,23.00,76.00,1015.40,0.00,0.00,100.00,26.00,100.00,100.00,0.00,6.88,186.01,12.26,220.24,27.60,262.50,14.04,2.1] , [15.47]
[2016-10-24,22.00,73.00,1014.70,0.00,0.00,10.20,34.00,0.00,2.00,0.00,6.49,176.82,11.97,201.16,24.27,249.15,7.92,0.669999 ] , [16.14]
....
....
大小为 [n][19]、[n][1]。我想使用 Tensorflow 线性回归来预测 Python。我的意思是我想用这 19 个变量来预测 1 个变量。我有大数据集。我觉得足够训练了。
但是,我是机器学习和 Tensorflow 的初学者。你能给我任何文件或线索吗? 提前致谢。
这是一个简单的线性回归模型:
def model(X, w):
return tf.mul(X, w) # Just X*w so this model line is pretty simple
w = tf.Variable(0.0, name="weights")
y_model = model(X, w)
cost = tf.square(Y - y_model) # use square error for cost function
train_op = tf.train.GradientDescentOptimizer(0.01).minimize(cost)
然后你需要运行 TensorFlow会话下的train_op。
对于您的数据集,您只需更改 w 和 x。在 https://github.com/nlintz/TensorFlow-Tutorials/blob/master/01_linear_regression.py.
查看更多示例