# coding=utf-8
import pandas as pd
import numpy as np
from sklearn import cross_validation
import tensorflow as tf global flag
flag=0 def DataPreprocessing():
abalone = pd.read_csv("train_data.csv", sep=',', header=0, keep_default_na=True)
X_train=np.array(abalone.iloc[:,:6])
Y_train_=np.array(abalone.iloc[:,6:])
print(X_train)
Y_train=[]
for i in range(len(X_train)): X_train[i][0] = ord(X_train[i][0])-97
X_train[i][2] = ord(X_train[i][2])-97
X_train[i][4] = ord(X_train[i][4])-97 # for i in range (len(X_train)):
# for j in range(6):
# X_train[i][j]=X_train[i][j]-0.0
#
#X_train.astype(np.float64)
# print(X_train,type(X_train),X_train[0][0],type(X_train[0][0])) #binary classifier
for i in range(len(Y_train_)): if Y_train_[i][0]=="draw":
Y_train.append(0)
else:
Y_train.append(1) # multiple classifer return cross_validation.train_test_split(X_train,Y_train,test_size=0.25,random_state=0,stratify=Y_train) def GetInputs():
global flag
X_train, X_test, Y_train, Y_test = DataPreprocessing() #print(type(X_train),type(X_train[0][0]))
#print(X_train)
# print(len(X_test))
# print(len(Y_train))
# print(len(Y_test)) #X_train[X_train.isnull().any(axis=1)]
#X_train.fillna('',inplace=True) # print(X_train)
# print(Y_test) x_train=tf.constant(X_train)
y_train=tf.constant(Y_train)
x_test=tf.constant(X_test)
y_test=tf.constant(Y_test)
#
# print(x_train)
# print(y_train)
# print(x_test)
# print(y_test) if flag==0:
return x_train,y_train
else:
return x_test,y_test def Main(): global flag feature_columns=[tf.contrib.layers.real_valued_column("",dimension=6)] clf=tf.contrib.learn.DNNClassifier(feature_columns=feature_columns,hidden_units=[20,40,20],n_classes=2,model_dir="/home/jiangjing/TensorflowModel/chess") clf.fit(input_fn=GetInputs,steps=2000) flag=1
accuracy_score=clf.evaluate(input_fn=GetInputs,steps=1)["accuracy"] print("nTest Accuracy:{0:f}".format(accuracy_score)) if __name__ =="__main__":
#DataPreprocessing() Main() exit(0)

Chess的更多相关文章

  1. hdu4405 Aeroplane chess

    Aeroplane chess Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)T ...

  2. HDU 5742 Chess SG函数博弈

    Chess Problem Description   Alice and Bob are playing a special chess game on an n × 20 chessboard. ...

  3. POJ2425 A Chess Game[博弈论 SG函数]

    A Chess Game Time Limit: 3000MS   Memory Limit: 65536K Total Submissions: 3917   Accepted: 1596 Desc ...

  4. HDU 4832 Chess (DP)

    Chess Time Limit: 6000/3000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submi ...

  5. 2016暑假多校联合---A Simple Chess

    2016暑假多校联合---A Simple Chess   Problem Description There is a n×m board, a chess want to go to the po ...

  6. HDU5724 Chess(SG定理)

    题目 Source http://acm.hdu.edu.cn/showproblem.php?pid=5724 Description Alice and Bob are playing a spe ...

  7. BFS AOJ 0558 Chess

    AOJ 0558 Chess http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0558    在H * W的地图上有N个奶酪工厂,每个 ...

  8. Codeforces Round #379 (Div. 2) D. Anton and Chess 水题

    D. Anton and Chess 题目连接: http://codeforces.com/contest/734/problem/D Description Anton likes to play ...

  9. dp - Codeforces Round #313 (Div. 1) C. Gerald and Giant Chess

    Gerald and Giant Chess Problem's Link: http://codeforces.com/contest/559/problem/C Mean: 一个n*m的网格,让你 ...

  10. hdu 4832 Chess(dp)

    Chess Time Limit: 6000/3000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submi ...

随机推荐

  1. Python 之 文件处理

    文件操作: 文件路径:d:\文件名.txt 编码方式:utf-8.gbk 操作方式:只读.只写.追加.读写.写读... 只读:r    或     rb #相对路径 f=open("文件名& ...

  2. 手打的table

    突然觉得,如果我不上传源码和写篇博客,对不起花在这个破网页2个小时的时间,完全手打,浏览器调效果. 源码如下: a.html: <!DOCTYPE html PUBLIC "-//W3 ...

  3. 编写高质量代码改善C#程序的157个建议——建议29:区别LINQ查询中的IEnumerable<T>和IQueryable<T>

    建议29:区别LINQ查询中的IEnumerable<T>和IQueryable<T> LINQ查询一共提供了两类扩展方法,在System.Linq命名空间下,有两个静态类:E ...

  4. OkHttp3的简单使用(一)

    一.导入 1)gradle方式: compile 'com.squareup.okhttp3:okhttp:3.8.0'(okhttp 最新版) compile 'com.squareup.okio: ...

  5. CentOS7 yum安装lamp环境

    1.安装apache yum install httpd #根据提示,输入Y安装即可成功安装 systemctl start httpd.service #启动apache systemctl sto ...

  6. 【转】android中layout_weight的理解

    android Layout_weight的理解 SDK中的解释: Indicates how much of the extra space in the LinearLayout will be ...

  7. C# socket请求的名称有效 但是找不到请求的类型的数据

    程序以前在xp下运行一直良好,但将安装在win7下面却出现"请求的名称有效 但是找不到请求的类型的数据"错误,程序底层通信是基于socket,时间久了就会出现系统黑屏死机,但并不知 ...

  8. web利用table表格生成excel格式问题

    当我们把web页面上的table导成excel形式时,有时候我们的数据需要以特定的格式呈现出来,这时候我们就需要给指定的单元格添加一些样式规格信息. 文本:vnd.ms-excel.numberfor ...

  9. UIButton的几种触发方式

    1.说明 说明:由于是在"iOS 模拟器"中测试的,所以不能用手指,只能用鼠标. 1)UIControlEventTouchDown 指鼠标左键按下(注:只是"按下&qu ...

  10. Python的特殊属性和魔法函数

    python中有很多以下划线开头和结尾的特殊属性和魔法函数,它们有着很重要的作用. 1.__doc__:说明性文档和信息,python自建,不需要我们定义. # -*- coding:utf- -*- ...