# 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. https抓包

  2. 方向ajax(http long request实现实时通信)

    现在我们就要通过这种方法来实现实时通信,先说一下原理: 客户端发起一个ajax长链接查询,然后服务端就开始执行代码,主要是检查某个文件是否被更新,如果没有,睡一会(sleep),醒来接着检查 如果客户 ...

  3. Flask框架 之 wtforms

    简介 WTForms是一个支持多个web框架的form组件,主要用于对用户请求数据进行验证. 作用 生成HTML标签 form表单验证 使用 - 用户登录示例- 用户注册示例- 数据库获取数据实时更新 ...

  4. 用JQuery获取输入框中的光标位置

    (function ($, undefined) { $.fn.getCursorPosition = function () { var el = $(this).get(0); var pos = ...

  5. php无限级分类

    使用递归方法,遍历子类,对数据进行重新排序,使用level进行无限级分类 /** * 功能:无限级分类 * 参数:$data 类别查询结果集 * 返回值:$arr 排序后的数组 */ public f ...

  6. 系统架构一:snmp+mrtg服务器监控

    //@author:yuan<turing_zhy@163.com> 码字不易,转载请注明出处 #================================== 开始,服务器准备   ...

  7. 微信运动数据抓取(Python)

    "微信运动"能够向朋友分享一个包含有运动数据的网页,网页中就有我们需要的数据.url类似于:http://hw.weixin.qq.com/steprank/step/person ...

  8. C#Thread学习

    一.Thread的使用方式 1.不带参数 (1)使用lambda public static void fun1() { Console.WriteLine($"Main ThreadId: ...

  9. MySql8.0后密码认证方式问题[caching-sha2-password]

    这个问题通常在laravel中表现为类似下边的异常: local.ERROR: SQLSTATE[HY000] [2006] MySQL server has gone away {"exc ...

  10. 871. Minimum Number of Refueling Stops

    A car travels from a starting position to a destination which is target miles east of the starting p ...