admin 管理员组

文章数量: 887021

Matlab做mil,模式识别

处理多示例学习(MIL)特征(matlab)

本文地址: 

多示例学习(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]; %整合测试

本文标签: Matlab做mil 模式识别