当前位置:网站首页>机器学习 —— Sklearn包中StandardScaler()、transform()、fit()的详细介绍
机器学习 —— Sklearn包中StandardScaler()、transform()、fit()的详细介绍
2022-07-25 09:19:00 【泡泡怡】
- sklearn(scikit-learn)是Scipy的扩展,建立在NumPy和matplotlib库的基础上。自2007年发布以来,sklearn已经成为Python重要的机器学习库。
- sklearn支持包括分类、回归、降维和聚类四大机器学习算法。还包含了特征提取、数据处理和模型评估三大模块。
一、 Sklearn包中StandardScaler()
1. from sklearn.preprocessing import StandardScaler #导入数据处理模块中的标准化函数
2. SS = StandardScaler() #生成实体类模块
3. scaler=SS.fit(X_train) #本质上就是求各列均值和方差
4. X_train=scaler.transform(X_train) #对数据各列进行标准化
5.#利用训练集中各列的均值和方差对测试集每一列进行标准化处理。
test1=scaler.transform(X_test1)
test2=scaler.transform(X_test2)
二、方法二(数据标准化):
mean=train_data.mean(axis=0)
train_data-=mean
std=train_data.std(axis=0)
train_data/=std
test_data-=mean
test_data/=std注意,用于测试数据标准化的均值和标准差都是在训练数据上计算得到的。在工作流程中,你不能使用在测试数据上计算得到任何结果,即使像数据标准化这么简单的事也不可以。
边栏推荐
- 将list集合的某一字段拼接单个String
- redis操作利用游标代替keys
- [WSN communication] optimize HWSN energy-saving clustering protocol based on MATLAB biogeography [including Matlab source code, 1989]
- How to use pixi.js to make simple Parkour games
- Solve NPM error: cannot find module 'shelljs‘
- [machine learning] Finally, the important steps of machine learning modeling have been clarified
- API健康状态自检
- Activemq-- delayed delivery and scheduled delivery
- 分享一个避免递归的部门设计方法
- Ranking of data results in MySQL
猜你喜欢

Guangzhou has carried out in-depth "100 day action" to check the safety of self built commercial houses, and more than 2 million houses have been checked in two months

How to avoid duplicate data when the database is high and distributed

实现简单的RESTful API服务器
![[stl]list Simulation Implementation](/img/92/2a78382700c1ebf299c6505d962c9c.png)
[stl]list Simulation Implementation

Sort out Huawei ap-3010dn_ V2 configuration create WiFi

神经网络学习(1)前言介绍

Nacos启动报错Unable to start web server

Unable to start debugging on the web server, the web server failed to find the requested resource

Uniapp intercepts route jumps through addinterceptor to control whether the page needs to log in

DVWA练习一 暴力破解
随机推荐
Probe into Druid query timeout configuration → who is the querytimeout of datasource and jdbctemplate effective?
MySQL appends a string to the string of a field in the table [easy to understand]
uni-app - Refused to display ‘xxx‘ in a frame because an ancestor violates the following Content Sec
Silicon Valley classroom lesson 15 - Tencent cloud deployment
多态和接口
有误差的字符串型时间比较方法String.compareTo
C#语言和SQL Server数据库技术
sqli-labs Basic Challenges Less11-22
CentOS changes MySQL database directory
office文件对应的Content-Type类型
Dark horse programmer JDBC
OmniPeek packet capturing tool
mysql中的数据结果排名
28.插槽
C#语言和SQL Server数据库技术
c语言中的六个存储类型:auto register static extern const volatile
ActiveMQ -- JDBC with persistent mechanism
In mysql, update and select are used together
[SCADA case] myscada helps VIB company realize the modernization and upgrading of production line
sqli-labs安装 环境:ubuntu18 php7