% FIND_MEANS Find means of class features
%
% Given a set of training data features, we wish to find the mean of each feature
% for a given class of character. These mean values are then normalized to permit
% accurate distance measurements.
function T = find_means(stats,feature_name)
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Create a sorted list of the character classes
num = length(stats);
classes(1) = stats(1).Class;
ind = 1;
for k = 2:num
% if the class has not yet been encountered
if ~sum(classes==stats(k).Class)
ind = ind + 1;
classes(ind,:) = stats(k).Class;
end
end
classes = sort(classes);
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Create a matrix of mean feature values for each class of character
cc = [stats(:).Class]';
for feature_num = 1:length(feature_name)
s = ['[stats.' feature_name{feature_num} ']'''];
this_feature = eval(s);
for class_num = 1:length(classes)
% find which of the training characters belong to each class
char_ind = cc==classes(class_num);
f_temp = this_feature(char_ind);
f_mean(class_num,feature_num) = sum(f_temp)/length(f_temp);
end
end
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Normalize the class/feature means
min_f_val = min(f_mean);
f_mean_norm = f_mean;
for feature_num = 1:length(feature_name)
f_mean_norm(:,feature_num) = f_mean_norm(:,feature_num) - min_f_val(feature_num);
max_f_val(feature_num) = max(f_mean_norm(:,feature_num));
f_mean_norm(:,feature_num) = f_mean_norm(:,feature_num) / max_f_val(feature_num);
end
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Store the important variables in a structure
T.classes = classes;
T.min_f_val = min_f_val;
T.max_f_val = max_f_val;
T.f_mean_norm = f_mean_norm;
小贝德罗
- 粉丝: 89
- 资源: 1万+
最新资源
- ssm-vue-高校实验室管理系统-源码工程-29页从零开始全套图文详解-34页参考论文-27页参考答辩ppt-全套开发环境工具、文档模板、电子教程、视频教学资源分享.zip
- Java源码ssm+vue框架百色学院创新实践学分认定系统-毕业设计-期末大作业.zip
- Java源码ssm+vue框架宝康药房销售管理系统-毕业设计-期末大作业.zip
- Java源码ssm+vue框架包头市交通管理局路况查询系统-毕业设计-期末大作业.zip
- 基于小程序的新生自助报到系统源码(小程序毕业设计完整源码+LW).zip
- ssm-vue-海鲜自助餐厅系统-源码工程-29页从零开始全套图文详解-34页参考论文-27页参考答辩ppt-全套开发环境工具、文档模板、电子教程、视频教学资源分享.zip
- ssm-vue-个人博客网站-源码工程-29页从零开始全套图文详解-34页参考论文-27页参考答辩ppt-全套开发环境工具、文档模板、电子教程、视频教学资源分享.zip
- Java源码ssm+vue框架本科生毕业设计选题系统-毕业设计-期末大作业.zip
- Java源码ssm+vue框架毕业生就业信息统计系统+vue-毕业设计-期末大作业.zip
- Java源码ssm+vue框架编程类在线答题系统-毕业设计-期末大作业.zip
- 基于小程序的智能停车场管理系统源码(小程序毕业设计完整源码+LW).zip
- ssm-vue-理发店会员管理系统-源码工程-29页从零开始全套图文详解-34页参考论文-27页参考答辩ppt-全套开发环境工具、文档模板、电子教程、视频教学资源分享.zip
- ssm-vue-绿色农产品推广应用网站-源码工程-29页从零开始全套图文详解-34页参考论文-27页参考答辩ppt-全套开发环境工具、文档模板、电子教程、视频教学资源分享.zip
- ssm-vue-鲸落文化线上体验馆-源码工程-29页从零开始全套图文详解-34页参考论文-27页参考答辩ppt-全套开发环境工具、文档模板、电子教程、视频教学资源分享.zip
- Java源码ssm+vue框架超市场管理系统-毕业设计-期末大作业.zip
- Java源码ssm+vue框架大美新疆论坛交流系统-毕业设计-期末大作业.zip
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈