Как работает sklearn.preprocessing.scale? - PullRequest
0 голосов
/ 28 марта 2020

У меня есть массив двумерных данных. описание дохода человека и его возраста Данные масштабируются до подготовки модели. После масштабирования данных он полностью меняет значение предыдущих данных на новые (близкие к 0) значения.

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

1 Ответ

0 голосов
/ 28 марта 2020

Это удаление среднего значения из данных каждого наблюдения, а затем деление на стандартное отклонение данных

Проверьте аргументы для более подробной информации

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).
...