MLP 64,2  preprocessing.MinMaxScaler().fit(X)
                               test confusion_matrix:
[[129293   2734]
 [   958  23375]]
             precision    recall  f1-score   support

0       0.99      0.98      0.99    132027
          1       0.90      0.96      0.93     24333

avg / total       0.98      0.98      0.98    156360

all confusion_matrix:
[[646945  13384]
 [  4455 117015]]
             precision    recall  f1-score   support

0       0.99      0.98      0.99    660329
          1       0.90      0.96      0.93    121470

avg / total       0.98      0.98      0.98    781799

black verify confusion_matrix:
[0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 1 1 0 0 0
 0 0 0 0 0]
/root/anaconda2/lib/python2.7/site-packages/sklearn/metrics/classification.py:1137: UndefinedMetricWarning: Recall and F-score are ill-defined and being set to 0.0 in labels with no true samples.
  'recall', 'true', average, warn_for)
             precision    recall  f1-score   support

0       0.00      0.00      0.00         0
          1       1.00      0.07      0.13        42

avg / total       1.00      0.07      0.13        42

white verify confusion_matrix:
[1 1 1 1 1 1 0]
             precision    recall  f1-score   support

0       1.00      0.14      0.25         7
          1       0.00      0.00      0.00         0

avg / total       1.00      0.14      0.25         7

unknown_verify:
[1 0 0 1 1 0 0 0 1 1 0 0 1 0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0 0 1 0 0 1 1 1 1
 0 1 1 1 1 0 1 0 0 1 0 1 0 1 0 0 1 0 0 1 1 0 0 1 0 0 0 1 0 1 1 0 0 1 0 0 0]

MLP 64,2 使用preprocessing.StandardScaler().fit(X)
 [[131850    180]
 [   230  24100]]
             precision    recall  f1-score   support

0       1.00      1.00      1.00    132030
          1       0.99      0.99      0.99     24330

avg / total       1.00      1.00      1.00    156360

all confusion_matrix:
[[659500    829]
 [  1195 120275]]
             precision    recall  f1-score   support

0       1.00      1.00      1.00    660329
          1       0.99      0.99      0.99    121470

avg / total       1.00      1.00      1.00    781799

black verify confusion_matrix:
[0 1 1 0 0 0 0 1 1 1 0 1 1 1 1 1 1 0 1 1 1 0 0 0 1 1 1 0 0 0 1 1 1 1 1 1 1
 0 0 0 1 1]
/root/anaconda2/lib/python2.7/site-packages/sklearn/metrics/classification.py:1137: UndefinedMetricWarning: Recall and F-score are ill-defined and being set to 0.0 in labels with no true samples.
  'recall', 'true', average, warn_for)
             precision    recall  f1-score   support

0       0.00      0.00      0.00         0
          1       1.00      0.62      0.76        42

avg / total       1.00      0.62      0.76        42

white verify confusion_matrix:
[0 0 1 0 1 1 0]
             precision    recall  f1-score   support

0       1.00      0.57      0.73         7
          1       0.00      0.00      0.00         0

avg / total       1.00      0.57      0.73         7

unknown_verify:
[1 0 0 0 1 0 1 1 0 0 1 0 1 1 0 1 0 1 0 0 0 0 1 0 1 0 0 0 0 0 0 1 0 0 1 0 0
 0 1 1 1 0 0 0 0 0 0 0 0 0 0 1 0 0 1 0 0 1 0 0 0 0 0 0 0 0 0 0 1 1 0 0 0 0]

代码:

    from sklearn import preprocessing
scaler = preprocessing.StandardScaler().fit(X)
#scaler = preprocessing.MinMaxScaler().fit(X)
X = scaler.transform(X)
print("standard X sample:", X[:3]) black_verify = scaler.transform(black_verify)
print(black_verify) white_verify = scaler.transform(white_verify)
print(white_verify) unknown_verify = scaler.transform(unknown_verify)
print(unknown_verify) # ValueError: operands could not be broadcast together with shapes (756140,75) (42,75) (756140,75)
for i in range(20):
X = np.concatenate((X, black_verify))
y += black_verify_labels labels = ['white', 'CC']
if True:
# pdb.set_trace()
ratio_of_train = 0.8
X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=(1 - ratio_of_train))
# X_train=preprocessing.normalize(X_train)
# X_test=preprocessing.normalize(X_test)
clf = MLPClassifier(solver='sgd', batch_size=128, learning_rate='adaptive', max_iter=256,
hidden_layer_sizes=(64, 2), random_state=1) """
clf = sklearn.ensemble.RandomForestClassifier(n_estimators=n_estimators, verbose=verbose, n_jobs=n_jobs,
random_state=random_state, oob_score=True)
""" clf.fit(X_train, y_train)
print "test confusion_matrix:"
# print clf.feature_importances_
y_pred = clf.predict(X_test)
print(sklearn.metrics.confusion_matrix(y_test, y_pred))
print(classification_report(y_test, y_pred))
else:
#clf = pickle.loads(open("mpl-acc97-recall98.pkl", 'rb').read())
clf = pickle.loads(open("mlp-add-topx10.model", 'rb').read())
y_pred = clf.predict(X)
print(sklearn.metrics.confusion_matrix(y, y_pred))
print(classification_report(y, y_pred))
import sys
#sys.exit(0) print "all confusion_matrix:"
y_pred = clf.predict(X)
print(sklearn.metrics.confusion_matrix(y, y_pred))
print(classification_report(y, y_pred))

python MLP 神经网络使用 MinMaxScaler 没有 StandardScaler效果好的更多相关文章

  1. "多层感知器"--MLP神经网络算法

    提到人工智能(Artificial Intelligence,AI),大家都不会陌生,在现今行业领起风潮,各行各业无不趋之若鹜,作为技术使用者,到底什么是AI,我们要有自己的理解. 目前,在人工智能中 ...

  2. MLP神经网络实例--手写识别

    1.导入MNIST数据集 直接使用fetch_mldata会报错,错误信息是python3.7把fetch_mldata方法移除了,所以需要单独下载数据集从这个网站上下载数据集: https://gi ...

  3. c++实现mlp神经网络

    之前一直用theano训练样本,最近需要转成c或c++实现.在网上参考了一下其它代码,还是喜欢c++.但是看了几份cpp代码之后,发现都多少有些bug,很不爽.由于本人编码能力较弱,还花了不少时间改正 ...

  4. 深度学习与计算机视觉:基于Python的神经网络的实现

    在前面两篇文章介绍了深度学习的一些基本概念,本文则使用Python实现一个简单的深度神经网络,并使用MNIST数据库进行测试. 神经网络的实现,包括以下内容: 神经网络权值的初始化 正向传播 误差评估 ...

  5. python视频 神经网络 Tensorflow

    python视频 神经网络 Tensorflow 模块 视频教程 (带源码) 所属网站分类: 资源下载 > python视频教程 作者:smile 链接:http://www.pythonhei ...

  6. python 实现神经网络算法

    注: Scratch是一款由麻省理工学院(MIT) 设计开发的一款面向少年的简易编程工具.这里写链接内容         本文翻译自“IMPLEMENTING A NEURAL NETWORK FRO ...

  7. 使用python制作神经网络——搭建框架

    一.神经网络的大体结构可分为三个函数,分别如下: 1.初始化函数 设定输入层节点,隐藏层节点和输出层节点的数量. 2.训练 学习给定训练集样本后,优化权重. 3.查询 给定输入,从输出节点给出答案 所 ...

  8. python keras 神经网络框架 的使用以及实例

    先吐槽一下这个基于theano的keras有多难装,反正我是在windows下折腾到不行(需要64bit,vs c++2015),所以自己装了一个双系统.这才感到linux系统的强大之初,难怪大公司都 ...

  9. Python实现神经网络算法识别手写数字集

    最近忙里偷闲学习了一点机器学习的知识,看到神经网络算法时我和阿Kun便想到要将它用Python代码实现.我们用了两种不同的方法来编写它.这里只放出我的代码. MNIST数据集基于美国国家标准与技术研究 ...

随机推荐

  1. jquery基础研究学习【基础】

    2017年6月6日15:07:58     该看:http://www.runoob.com/jquery/jquery-fade.html                淡入淡出 jQuery 教程 ...

  2. python利用正则表达式提取字符串

    前言 正则表达式的基础知识就不说了,有兴趣的可以点击这里,提取一般分两种情况,一种是提取在文本中提取单个位置的字符串,另一种是提取连续多个位置的字符串.日志分析会遇到这种情况,下面我会分别讲一下对应的 ...

  3. EhCache 集群 配置(RMI方式)

    这里先说明下环境:JDK1.6.ehcache-core-2.1.0.jar.Tomcat6.Spring3.0.2.使用的是RMI方式配置集群的,这里先吐槽下遇到的情况,在搜相关知识的时候发现到处都 ...

  4. 1065. [Nescafe19] 绿豆蛙的归宿(概率)

    1065. [Nescafe19] 绿豆蛙的归宿 ★   输入文件:ldfrog.in   输出文件:ldfrog.out   简单对比时间限制:1 s   内存限制:128 MB [背景] 随着新版 ...

  5. Android 新建一个类,在src新建一个类,使继承自活动

    一:先新建一个包 右键src,新建包: 二:包中新建类 右建包,新建类,将超类改为andorid.app.Activity

  6. [原创]css设置禁止中文换行

    white-space: nowrap;   如有需要还可以设置word-break,word-wrap配合.

  7. Java编程中的一些常见问题汇总

    转载自  http://macrochen.iteye.com/blog/1393502 每天在写Java程序,其实里面有一些细节大家可能没怎么注意,这不,有人总结了一个我们编程中常见的问题.虽然一般 ...

  8. ElasticSearch(三十)基于scoll+bulk+索引别名实现零停机重建索引

    1.为什么要重建索引? 总结,一个type下的mapping中的filed不能被修改,所以如果需要修改,则需要重建索引 2.怎么zero time重建索引? 一个field的设置是不能被修改的,如果要 ...

  9. angular中按需加载js

    按需加载估计是大家在使用angular之后最想解决的问题吧,因为angular的依赖机制,导致了必须在第一次加载的时候就加载所有js文件,小项目还好,稍大一点的项目如果有上百个js文件,不管是从效率还 ...

  10. 用Visual Studio编辑Linux代码

    估计很多人都是用惯了Visual Studio的主,怎么也不适应Linux的一套编辑器,比如vim.source insight这些东西,可视化的eclipse效果还好点,但一般以远程共享一台Linu ...