in tensorfow , you could take afvantage of tf.contrib API to implement the leanr mode prediction,

even we know the deep leaning power , leanr model is always the first method you should try before you take on hands of deep leanring .

Tensorflow has two kind of leanr regression : logisitc regression and classification.

.LinearClassifier

train a linear model to classify instances into one of multiple possible classes. When number of possible classes is 2, this is binary classification.

.Linearregressor

Train a linear regression model to predict label value given observation of feature values.

上面是线性回归和分类的两个主要函数,应用广泛。

tf.contrib.learn.DNNClassifier: 深度神经网络分类器

 

这里面tensorflow对于csv数据的转化成tensor花了大量篇幅

其中如何将数字 或者类别进行转化,下面这个列子就是自动将类别转化成稀疏矩阵

gender = tf.contrib.layers.sparse_column_with_keys(
  column_name="gender", keys=["Female", "Male"])

如果你不知道具体类别那么使用
education = tf.contrib.layers.sparse_column_with_hash_bucket("education", hash_bucket_size=1000)
这样的话 系统会自动分配。 

对于实数  也可以直接输入 但是一般需要做tensor转化的工作 利用:
age = tf.contrib.layers.real_valued_column("age")
如果需要对某个特殊类别进行分段:
age_buckets = tf.contrib.layers.bucketized_column(age, boundaries=[18, 25, 30, 35, 40, 45, 50, 55, 60, 65])
如果需要去几个属性的属性关系值:
education_x_occupation = tf.contrib.layers.crossed_column([education, occupation], hash_bucket_size=int(1e4))


再利用pandas进行csv的读取后,需要将数据分别转换成tensor格式 


Tensorflow with a new kind of method to do classfy. 

DNN combines with leanr model .