我正试图在Jetson Nano上运行项目,我的sklearn有问题,我无法安装它。所以我需要在代码中用另一个函数替换它。我并不需要另一个函数来进行缩放,我只需要一些东西来更改我输入数据的数据类型。输入数据是时间序列,看起来像:
x,y,z,label
0.3303817887510875,-0.5849648154560647,-0.5946208414132126,0
-0.3422998500971291,-0.7617551561596086,-1.8129087998627638,0
0.7108553739574683,0.2990158994796035,-1.6783290599211453,0
1.191236392928778,-0.09859852595130766,-0.6166905447774964,0
0.906986335722905,-2.127061900910884,-0.23501034521839367,0
1.4818360997444877,-1.2481603362918865,-1.4146228769074463,0
1.0818554938741836,-1.6339111546601714,-0.90764424270149,0
0.0801109656147606,-2.069127923642923,0.9659228440461014,0
0.44856893505832246,-1.1452557618700572,-1.6831450778075085,0
def get_frames(df, frame_size, hop_size):
N_FEATURES = 3
frames = []
labels = []
for i in range(0,len(df )- frame_size, hop_size):
x = df['x'].values[i: i+frame_size]
y = df['y'].values[i: i+frame_size]
z = df['z'].values[i: i+frame_size]
label = stats.mode(df['label'][i: i+frame_size])[0][0]
frames.append([x,y,z])
labels.append(label)
frames = np.asarray(frames).reshape(-1, frame_size, N_FEATURES)
labels = np.asarray(labels)
return frames, labels
Fs=20
frame_size = Fs*4 #80
hop_size = Fs*2 #40
dataframe = pd.read_csv("f1.csv", header=None)
dataset = dataframe.values
final = pd.DataFrame(data=dataset, columns=['x','y','z','label'])
final = final.iloc[1: , :]
x = final[['x','y','z']]
y = final['label'].astype('float')
#### I NEED TO REPLACE THESE TWO LINES #########################
#scaler = StandardScaler()
#x = scaler.fit_transform(x)
#####################################################################
x = pd.DataFrame(data=x, columns=['x','y','z'])
x_train,y_train = get_frames(x, frame_size, hop_size)
我得到以下错误:
ValueError: Failed to convert a NumPy array to a Tensor (Unsupported object type float).
我找到了解决方案。我所要做的就是重新键入x.
x=x.astype(np.float)