# 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文件复制移动shutil模块

    shutil.copyfile( src, dst) 从源src复制到dst中去.当然前提是目标地址是具备可写权限.抛出的异常信息为IOException. 如果当前的dst已存在的话就会被覆盖掉 s ...

  2. python之连接oracle数据库

    环境: windows,python2.7 1.下载cx_Oracle 在windows下不要使用easy_install或者pip,因为这样安装不会同步环境,并报错: distutils.error ...

  3. Entity Framework 6.0 Tutorials(10):Index Attribute

    Index Attribute: Entity Framework 6 provides Index attribute to create Index on a particular column ...

  4. KMP算法细讲(豁然开朗)

    一.KMP算法是如何针对传统算法修改的 用模式串P去匹配字符串S,在i=6,j=4时发生失配: ---------------------------------------------------- ...

  5. C# 操作Excel基础篇(读取Excel、写入Excel)

    注意事项:Excel的数据表中最多只能储存65535行数据,超出后,需要将数据分割开来进行储存.同时对于Excel中的乱码象限,是由于编码的错误方式导致引起的! 一.读取Excel数据表,获得Data ...

  6. 解决linux下80端口占用问题

    在即安装有tomcat,又安装有nginx的服务器上(典型阿里云驻云java镜像),系统默认配置nginx占用80端口,tomcat占用8080端口. 如果想要便于用户可以直接通过IP或者域名访问到t ...

  7. 三解炸弹人——DFS

    原创 枚举解炸弹人—— https://www.cnblogs.com/chiweiming/p/9295262.html BFS解炸弹人—— https://www.cnblogs.com/chiw ...

  8. XE改变图标颜色

    放一个image,load 一张png/..图片 再放一个FillRGBEffect, 将此控价拖到image下 改变FillRGBEffect的Color,就改变了image图标上的颜色. 原图为黑 ...

  9. c#字符相似度对比

    字符串相似度算法使用 Levenshtein Distance算法(中文翻译:编辑距离算法) 这算法是由俄国科学家Levenshtein提出的. 下面使用C#实现 public class Leven ...

  10. php代码审计8审计文件上传漏洞

    文件上传漏洞是指用户上传了一个可执行的脚步文件,并通过此脚本文件获得了执行服务器端命令的能力,这种攻击方式是最直接和有效的,文件上传本身是没问题的,有问题的是文件上传后,服务器怎么处理,解释文件,通过 ...