sklearn 标准化数据的方法
2024-09-01 09:14:42
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))
最新文章
- Windows消息机制详解
- 仿照微信的效果,实现了一个支持多选、选原图和视频的图片选择器,适配了iOS6-9系统,3行代码即可集成.
- openCV1
- Sprite的原点
- Apache+Tomcat +mod_proxy集群负载均衡及session
- Activity的跳转与传值(转载)
- macos10.8.5原版系统dmg转iso
- IDE-IntelliJ IDEA 主题、字体、编辑区主题、文件编码修改、乱码问题
- 2.QLabel,QPushButton,QLineEdit,QComboBox,QCheckBox,QRadioButton,QTextEdit,QTextBrowser,QGroupBox,QSl
- Asp.Net中virtual、override理解
- 20155309南皓芯 网络对抗《网络攻防》 Exp1 PC平台逆向破解(5)M
- 1.js基础(以通俗易懂的语言解释JavaScript)
- 《Go语言实战》摘录:6.2 并发 - goroutine
- <;漫步华尔街——股市历久弥新的成功投资策略>;读书笔记
- windows dos命令大全
- 安卓RecylerView嵌套和事件处理
- 转python+selenium 使用switch_to_alert 出现的怪异常
- TextView上下滑动
- css单位em、px、rem和pt的区别
- 转:Mosquitto配置----日志设置
热门文章
- Delphi - StringReplace用法
- node.js常用的全局成员和对象
- 自制轮子 canvas tree
- luogu -P1095 守望者的逃离 - 分别DP
- CodeForces - 940E - Cashback +贪心+DP
- 【欧拉降幂】Super_log
- Codefroces 366 C Dima and Salad(dp)
- Codeforces Round #481 (Div. 3) B. File Name
- lightoj 1036 - A Refining Company(简单dp)
- 牛客网暑期ACM多校训练营(第二场) 题解 A run 递推 dp