// 模糊C均值聚类.cpp : 此文件包含 "main" 函数。程序执行将在此处开始并结束。
//
#include "pch.h"
#include <iostream>
#include<iostream>
#include<cstdio>
#include<vector>
#include<fstream>
#include<cmath>
#include<ctime>
#include<cstdlib>
using namespace std;
struct Mode
{
int x, y;
int di;
vector<double> datas;
};
typedef vector<vector<Mode> > ModeVec;
const int N = 1000;
const double eps = 1e-2;
const double eps_dis = 1e-6;
double getDistance(Mode &m1, Mode &m2);
void FCM(Mode *p, int n, int di, int clusternum, vector<vector<Mode> > &ans);
void init_c(Mode *p, int n, int clusternum, Mode *c);
void comp_dis(Mode *p, Mode *c, int n, int clusternum, double dis[][10]);
void comp_u(double dis[][10], int n, int clusternum, double u[][10]);
void update_c(Mode *p, double u[][10], int n, int clusternum, Mode *c);
double comp_obj_func(double u[][10], double dis[][10], int n, int clusternum, int di);
int main()
{
int n, dimension, clusternum;
Mode p[N];
// freopen("in.txt","r",stdin);
// freopen("out.txt","w",stdout);
ifstream fin("E:\\iris.data.txt");
ofstream fout("E:\\out.txt");
cout << "输入点的个数,维度,聚类数目" << endl;
cin >> n >> dimension >> clusternum; //输入点的个数,维度,聚类数目
for (int i = 0; i < n; i++)
{
p[i].di = dimension;
for (int j =
模糊C均值聚类 C++代码
最新推荐文章于 2023-12-01 22:47:41 发布
本文介绍如何使用C++编程实现模糊C均值(Fuzzy C-Means, FCM)聚类算法,详细阐述了关键步骤和代码实现,帮助读者理解并应用该算法。"
132222813,7337247,个性化建模:挖掘用户行为习惯,打造精准推荐系统,"['自然语言处理', '人工智能', '机器学习', '数据挖掘', '推荐系统']
摘要由CSDN通过智能技术生成