Reputation: 31
I have a N by M array where N corresponds to the number of points in an M dimensional space. I would like to center these points by subtracting the mean point using the learn library.
Upvotes: 2
Views: 8091
Reputation: 18675
you don't need sklearn for this, you'll use numpy
(which is also used by scikit-learn). Here is an example for N = 2 and M = 3:
import numpy as np
points = np.array([
[1.,2.,3.], # 1st point
[4.,5.,6.]] # 2nd point
)
meanPoint = points.mean(axis = 0)
# subtract mean point
points -= meanPoint
Upvotes: 4