处理多演示样例学习(MIL)特征(matlab)
本文地址: http://blog.csdn.net/caroline_wendy/article/details/27206325
多演示样例学习(MIL)的特征(features)包括, "演示样例编号+视频编号+标签+特征"的形式;
须要组成多演示样例学习特定包的形式, 每个元胞是一个多演示样例包, 后面一位是标签, 即"特征包+标签"的形式;
代码:
%author @ C.L.Wang %time @ 2014.5.27 %matlab @ R2012a %% 载入数据 clc, clear; features = load('ViolenceMILFeatures.txt'); %% 提取多演示样例包 head = features(:,1:3); % 头部信息 video_vector = features(:,2); % 视频名称 total_num = size(unique(video_vector),1); video_cell = cell(total_num,2); for video_num = 1:total_num temp = find(video_vector==video_num); video_cell{video_num,1} = features(temp(1,1):temp(end,1),4:end); video_cell{video_num,2} = features(temp(1,1),3); end %% 分类训练和測试 negative_train_features = video_cell(1:(total_num/4), :); negative_test_features = video_cell((total_num/4+1):(total_num*2/4), :); positive_train_features = video_cell((total_num*2/4+1):(total_num*3/4), :); positive_test_features = video_cell((total_num*3/4+1):end, :); train_features = [positive_train_features; negative_train_features]; %整合训练 test_features = [positive_test_features; negative_test_features]; %整合測试