简体   繁体   English

如何在Tensorflow上使用带有我自己的数据的线性回归模型

[英]How to Use Linear Regression Model with My Own Data on Tensorflow

I have data set like this 我有这样的数据集

[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]
....
....

Size of this is [n][19], [n][1]. 这个大小是[n] [19],[n] [1]。 I want to use Tensorflow Linear Regression to get prediction on Python. 我想使用Tensorflow线性回归来预测Python。 I mean I want to use this 19 variable to predict 1 variable. 我的意思是我想用这个19变量来预测1个变量。 I have large data set. 我有大量的数据集。 I think it will be enough for training. 我认为这对培训来说已经足够了。

However, I am a beginner in Machine Learning and Tensorflow. 但是,我是机器学习和Tensorflow的初学者。 Can you give me any documentation or clue for this? 你能给我任何文件或线索吗? Thanks in advance. 提前致谢。

This is a simple Linear Regression model: 这是一个简单的线性回归模型:

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) 

Then you need to run the train_op under TensorFlow session. 然后你需要在TensorFlow会话下运行train_op。

For your dataset, you just need to change the w and x. 对于您的数据集,您只需要更改w和x。 See more examples at https://github.com/nlintz/TensorFlow-Tutorials/blob/master/01_linear_regression.py . 请参阅https://github.com/nlintz/TensorFlow-Tutorials/blob/master/01_linear_regression.py上的更多示例。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM