gpt4 book ai didi

excel - 在带有 Excel 数据的 Matlab 中使用 lbsvm

转载 作者:行者123 更新时间:2023-12-04 21:05:27 26 4
gpt4 key购买 nike

我的数据在 Excel 中,所以要将它们转换为 Libsvm格式,我将 Excel 表转换为 CSV 格式并按照 Libsvm 网站上的程序进行操作:- 假设 CSV 文件是 SPECTF.train :-

matlab> SPECTF = csvread('SPECTF.train'); % read a csv file

matlab> labels = SPECTF(:, 1); % labels from the 1st column

matlab> features = SPECTF(:, 2:end);

matlab> features_sparse = sparse(features); % features must be in a sparse matrix

matlab> libsvmwrite('SPECTFlibsvm.train', labels, features_sparse);



然后我使用 libsvmread 阅读它。 (姓名)

有没有更短的方法可以直接以 Libsvm 格式格式化 excel 数据?谢谢。

最佳答案

我认为不需要转换为 csv。您可以使用 xlsread 直接从 excel 文件中读取数据,并使用 libsvmwrite 以与 libsvm 兼容的形式获取数据。

关于excel - 在带有 Excel 数据的 Matlab 中使用 lbsvm,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22312414/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com