Sklearn

标准化数据

from __future__ import print_function
from sklearn import preprocessing
import numpy as np
from sklearn.model_selection import train_test_split
from sklearn.datasets.samples_generator import make_classification
from sklearn.svm import SVC
import matplotlib.pyplot as plt
#每一列是一个属性
a = np.array([[10, 2.7, 3.6],
[-100, 5, -2],
[120, 20, 40]], dtype=np.float64) print(a)
#归一化
print(preprocessing.scale(a))
# 生成一堆数据 有两个属性 有两个相关属性
X, y = make_classification(n_samples=300, n_features=2 , n_redundant=0, n_informative=2,
random_state=22, n_clusters_per_class=1, scale=100)
plt.scatter(X[:, 0], X[:, 1], c=y)
plt.show()
X = preprocessing.scale(X) # normalization step
#minmax_scale(X,feature_range=(-1,1))
X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=.3)
clf = SVC()
clf.fit(X_train, y_train)
print(clf.score(X_test, y_test))

最新文章

  1. Windows消息机制详解
  2. 仿照微信的效果,实现了一个支持多选、选原图和视频的图片选择器,适配了iOS6-9系统,3行代码即可集成.
  3. openCV1
  4. Sprite的原点
  5. Apache+Tomcat +mod_proxy集群负载均衡及session
  6. Activity的跳转与传值(转载)
  7. macos10.8.5原版系统dmg转iso
  8. IDE-IntelliJ IDEA 主题、字体、编辑区主题、文件编码修改、乱码问题
  9. 2.QLabel,QPushButton,QLineEdit,QComboBox,QCheckBox,QRadioButton,QTextEdit,QTextBrowser,QGroupBox,QSl
  10. Asp.Net中virtual、override理解
  11. 20155309南皓芯 网络对抗《网络攻防》 Exp1 PC平台逆向破解(5)M
  12. 1.js基础(以通俗易懂的语言解释JavaScript)
  13. 《Go语言实战》摘录:6.2 并发 - goroutine
  14. <漫步华尔街——股市历久弥新的成功投资策略>读书笔记
  15. windows dos命令大全
  16. 安卓RecylerView嵌套和事件处理
  17. 转python+selenium 使用switch_to_alert 出现的怪异常
  18. TextView上下滑动
  19. css单位em、px、rem和pt的区别
  20. 转:Mosquitto配置----日志设置

热门文章

  1. Delphi - StringReplace用法
  2. node.js常用的全局成员和对象
  3. 自制轮子 canvas tree
  4. luogu -P1095 守望者的逃离 - 分别DP
  5. CodeForces - 940E - Cashback +贪心+DP
  6. 【欧拉降幂】Super_log
  7. Codefroces 366 C Dima and Salad(dp)
  8. Codeforces Round #481 (Div. 3) B. File Name
  9. lightoj 1036 - A Refining Company(简单dp)
  10. 牛客网暑期ACM多校训练营(第二场) 题解 A run 递推 dp