我正在使用Scikit-Learn NMF算法,我想知道是否有任何方法可以在算法中使用负值,我需要它来处理BVH文件。
我使用的是python 3.7.5
import numpy as np
import re
from sklearn.decomposition import NMF
with open('01_01.bvh', 'r') as fr:
with open('01_01_NMF.bvh', 'w') as fw:
for line in fr.readlines():
if line[0].isdigit() or line[1].isdigit():
line = re.split('\s+|\n', line)
line.pop()
MOTION = [float(nums) for nums in line]
X = MOTION
print("Original")
print(X)
model = NMF(n_components=96, init='random', random_state=0)
W = model.fit_transform(X)
H = model.components_
print("NMF")
print(W)
OutputMotion = [str(nums) for nums in W]
out = ' '.join(OutputMotion)
fw.write(out + '\n')
else:
fw.write(line)代码已经逐行读取bvh文件,并验证它是否在Motion部分,该部分是必须通过NMF的部分,但它通常具有许多负值,并且算法会拒绝它们。欢迎任何帮助,谢谢。
发布于 2020-11-10 06:04:07
您必须对数据进行标准化,因此每个参数值都在0.0-1.0之间。请参阅scikit学习https://scikit-learn.org/stable/modules/generated/sklearn.decomposition.NMF.html
https://stackoverflow.com/questions/61492369
复制相似问题