首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >sklearn.preprocessing.scale是如何工作的?

问sklearn.preprocessing.scale是如何工作的?
EN

Stack Overflow用户
提问于 2020-03-28 04:17:19
回答 1查看 399关注 0票数 0

我有一系列的二维数据。描述一个人的收入和他的年龄,数据是在模型准备之前进行缩放的。在对数据进行缩放之后,它将以前数据的值完全更改为一些新的(接近0)值。

代码语言:javascript
复制
from numpy import random, array

#Create fake income/age clusters for N people in k clusters
def createClusteredData(N, k):
    random.seed(10)
    pointsPerCluster = float(N)/k
    X = []
    for i in range (k):
        incomeCentroid = random.uniform(20000.0, 200000.0)
        ageCentroid = random.uniform(20.0, 70.0)
        for j in range(int(pointsPerCluster)):
            X.append([random.normal(incomeCentroid, 10000.0), random.normal(ageCentroid, 2.0)])
    X = array(X)
    return X



%matplotlib inline

from sklearn.cluster import KMeans

import matplotlib.pyplot as plt
from sklearn.preprocessing import scale
from numpy import random, float

data = createClusteredData(100, 5)

model = KMeans(n_clusters=5)

model = model.fit(scale(data))```


what does that scale actually do in that model? I came to know it brings data to the same level or at comparison state. But what Mathematical functions it performs in data. I have referenced the documentation of sci-kit learn but couldn't get what it means.  Please explain the operations performed in simple language
EN

回答 1

Stack Overflow用户

发布于 2020-03-28 04:25:30

它是从每个观测数据中除去平均值,然后除以数据的标准差。

查看参数以获得更多详细信息。

代码语言:javascript
复制
with_mean boolean, True by default
   If True, center the data before scaling.

with_std boolean, True by default
   If True, scale the data to unit variance (or equivalently, unit standard deviation).
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/60897174

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档