资源简介
c++实现k-mean算法#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <conio.h>
#include <math.h>
// FUNCTION PROTOTYPES
// DEFINES
#define SUCCESS 1
#define FAILURE 0
#define TRUE 1
#define FALSE 0
#define MA
代码片段和文件信息
function [features targets label] = k_means(train_features train_targets Nmu region plot_on)
%Reduce the number of data points using the k-means algorithm
%Inputs:
% train_features - Input features
% train_targets - Input targets
% Nmu - Number of output data points
% region - Decision region vector: [-x x -y y number_of_points]
% plot_on - Plot stages of the algorithm
%
%Outputs
% features - New features
% targets - New targets
% label - The labels given for each of the original features
if (nargin < 5)
plot_on = 0;
end
[DL] = size(train_features);
dist = zeros(NmuL);
label = zeros(1L);
%Initialize the mu‘s
mu = randn(DNmu);
mu = sqrtm(cov(train_features‘1))*mu + mean(train_features‘)‘*ones(1Nmu);
old_mu = zeros(DNm
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
文件 1833 2007-03-13 20:39 k_means.m
----------- --------- ---------- ----- ----
1833 1
- 上一篇:c语言做的成绩管理系统(单链表实现)
- 下一篇:大数实现的椭圆曲线ECC加解密算法
评论
共有 条评论