![](/img/trans.png)
[英]How do you cycle a Python list to extend it from M to N values (M < N)?
[英]How do you center N*M matrix in Python using sklearn
我有一個N by M數組,其中N對應於M維空間中的點數。 我想通過使用學習庫減去均值來將這些點居中。
您不需要sklearn,您將使用numpy
(scikit-learn也使用它)。 這是N = 2和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
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.