# 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("ceshi.csv", sep=',', header=0, keep_default_na=True,na_values=[])
X_train=np.array(abalone.iloc[:,:4])
Y_train=np.array(abalone.iloc[:,4:])
# Y_train=[]
# for i in range(len(X_train)):
# if X_train[i][0] == 'M':
# X_train[i][0]=0
# elif X_train[i][0]=='F':
# X_train[i][0]=1
# else:
# X_train[i][0]=2
#
# for i in range(len(Y_train_)):
#
# #print(Y_train[i][0])
# Y_train.append(Y_train_[i][0]) # print(X_train)
# print(len(X_train))
# print(Y_train)
# print(len(Y_train))
# print(min(Y_train))
# print(max(Y_train)) 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(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=4)] clf=tf.contrib.learn.DNNClassifier(feature_columns=feature_columns,hidden_units=[10,20,10],n_classes=2,model_dir="/home/jiangjing/TensorflowModel/banknote") 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)

BankNote的更多相关文章

  1. News common vocabulary

    英语新闻常用词汇与短语 经济篇 accumulated deficit 累计赤字 active trade balance 贸易顺差 adverse trade balance 贸易逆差 aid 援助 ...

  2. Euro Efficiency_完全背包

    Description On January 1st 2002, The Netherlands, and several other European countries abandoned the ...

  3. 基于异步的MVC webAPI控制器

    MVC – Task-based Asynchronous Pattern (TAP) – Async Controller and SessionLess Controller Leave a re ...

  4. Euro Efficiency(完全背包)

    Euro Efficiency Time Limit : 2000/1000ms (Java/Other)   Memory Limit : 20000/10000K (Java/Other) Tot ...

  5. B

    baababblebabblerbabebabelbaboonbabybabyhoodBabylonBabylonianbacchanalbacchanalianbachelorbacillusbac ...

  6. 【Java】-NO.16.EBook.4.Java.1.004-【疯狂Java讲义第3版 李刚】- 内部类

    1.0.0 Summary Tittle:[Java]-NO.16.EBook.4.Java.1.004-[疯狂Java讲义第3版 李刚]- 内部类 Style:EBook Series:Java S ...

  7. 学习笔记之1001 Inventions That Changed the World

    1001 Inventions That Changed the World: Jack Challoner: 9780764161360: Amazon.com: Books https://www ...

  8. 微信emoji的code

    const MAP = [        "\xc2\xa9" => 'COPYRIGHT SIGN',        "\xc2\xae" => ...

  9. CF-499div2-E-裴蜀定理

    E. Border time limit per test 1 second memory limit per test 256 megabytes input standard input outp ...

随机推荐

  1. location.replace() keeps the history under control

    from https://dev.opera.com/articles/efficient-javascript Occasionally, it is necessary to change the ...

  2. query聚类技术

    query聚类 目的 query聚类主要有以下两个目的 解决query空间稀疏问题(长尾query) 挖掘用户意图(一条行为包含的意图是稀疏的,当有一簇行为时,意图更明确) 可以说聚类是构建内容模型的 ...

  3. 【转】Android自定义控件(二)——有弹性的ScrollView

    原文地址:http://blog.csdn.net/a105865708/article/details/17784041 实现了当手指滑动到ScrollView的顶部.底部时, 可以继续的向上.向下 ...

  4. asp.net winform 界面传值

    第一种 //form1 //静态传值 public static string Chuanzhi; string Chuanzhi = textbox.text; //form2 string Chu ...

  5. laravel中firstOrCreate的使用

    laravel - firstOrCreate(判断是否存在, 不存在则新增数据) 1, 判断goods_name是否存在YKQ003213_G这个参数 2, 不存在则添加数组的内容 3, 需要设置自 ...

  6. 多态的作用-游戏编程展示------新标准c++程序设计

    游戏软件的开发最能体现面向对象设计方法的优势.游戏中的人物.道具.建筑物.场景等都是很直观的对象,游戏运行的过程就是这些对象相互作用的过程.每个对象都有自己的属性和方法,不同对象也可能有共同的属性和方 ...

  7. Struts2学习第3天--OGNL、EL、值栈

    JAVA中的OGNL: 1 调用对象的方法: 2 访问对象的静态方法: 3 获取OGNLContext.Root中的数据. User: 4 访问Context: 关键还是在Struts2环境中的使用: ...

  8. luoguP4172 [WC2006]水管局长

    https://www.luogu.org/problemnew/show/P4172 考虑倒序处理所有操作 先把不会被删掉的边加入图中,LCT 维护最小生成树,再倒序插入每一条边,如果边的 ( l, ...

  9. QT中QWidget、QDialog以及MainWindow的区别

    参考 http://blog.csdn.net/u011619422/article/details/47311101 QT中QWidget.QDialog以及MainWindow的区别 QWidge ...

  10. Spring Eureka的使用入门--服务端与客户端

    接上篇: Eureka作为注册中心,连接服务端与客户端: 服务端: 依赖包: apply plugin: 'org.springframework.boot' apply plugin: 'io.sp ...