# 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. Codeforces 429B B. Working out

    题目意思: 给n*m的矩阵,每个格子有个数,A从(1,1)出发只能向下或右走,终点为(n,m),B从(n,1)出发只能向上或右走,终点为(1,m).两个人的速度不一样,走到的格子可以获的该格子的数,两 ...

  2. poj 1988 Cube Stacking (并查集)

    题意:有N(N<=30,000)堆方块,开始每堆都是一个方块.方块编号1 – N. 有两种操作: M x y : 表示把方块x所在的堆,拿起来叠放到y所在的堆上. C x : 问方块x下面有多少 ...

  3. React官方网站学习

    React官方网站  英文版 https://reactjs.org/tutorial/tutorial.html React官方网站  中文版 https://react.docschina.org ...

  4. Java IO流的回顾与梳理(必记必会必写)

  5. Hacker News排名算法工作原理

    这篇文章我要向大家介绍Hacker News网站的文章排名算法工作原理,以及如何在自己的应用里使用这种算法,这个算法非常简单,但却在突出热门文章和遴选新文章上表现的非常优秀.本质上,这段Hacker ...

  6. angular ng-content

    <p> child works! </p> <ng-content></ng-content> <app-child> 父组件投影 < ...

  7. 以太坊系列之十一: 零起步使用remix开发智能合约

    一步一步使用remix开发智能合约 最新版的remix(2017-8-3)只能使用在线开发了,已经没有离线版本了,并且好像在线版本要FQ才能访问(自行解决). 1.打开remix 注意地址如果是htt ...

  8. 解决org.hibernate.NonUniqueObjectException的问题

    不知道是不是之前处理懒加载的问题对session工厂进行了处理,导致了之前没有问题的地方出现了错误. 当修改班级操作时出现了错误 前端错误信息 后台处理以及报错信息 16:37:36,034 ERRO ...

  9. Nginx 进行性能配置

    总所周知,网络上我们购买的服务器的性能各不相同,如果采用 Nginx 的默认配置的话,无法将服务器的全部性能优势发挥出来,我们应该选择适合自己需求的配置. 当我们默认安装后 Nginx 后,我们便得到 ...

  10. loj #6014. 「网络流 24 题」最长 k 可重区间集

    #6014. 「网络流 24 题」最长 k 可重区间集 题目描述 给定实直线 L LL 上 n nn 个开区间组成的集合 I II,和一个正整数 k kk,试设计一个算法,从开区间集合 I II 中选 ...