当前位置: 首页 > news >正文

oa做软件还是网站南京html5响应式网站建设

oa做软件还是网站,南京html5响应式网站建设,公司没注册可以做网站吗,鞋服外包加工网1、Kmeans的原理如下#xff1a; #xff08;1#xff09;首先选取样本中任一数据点作为第一个聚类中心#xff1b; #xff08;2#xff09;计算样本每一个数据点至现所有聚类中心的最近距离#xff0c;并记录下来#xff1b; #xff08;3#xff09;逐一挑选所…1、Kmeans的原理如下 1首先选取样本中任一数据点作为第一个聚类中心 2计算样本每一个数据点至现所有聚类中心的最近距离并记录下来 3逐一挑选所有数据点最近距离之中的最大值即最远距离最大值对应的数据点为待求聚类中心 4剔除已选为聚类中心的样本点重新计算2、3步骤得到指定的最终的聚类中心点数。 2、实现结果如下 注当噪点太多时初始K个聚类中心的计算会出现偏差从而导致整个聚类结果出现偏差。 3、原始数据读入格式如下 点号-X坐标-Y坐标非此格式的数据无法正常读入程序会报错 4、根据Kmeans选择k个初始聚类中心的Kmeans聚类算法整体代码如下 //Kmeans.cpp文件 #include Kmeans.hKmeans::Kmeans(QWidget *parent): QWidget(parent) {start false;//dd blank;dd to2K;ui.setupUi(this);connect(ui.pushButton, SIGNAL(clicked()), this, SLOT(onBtReadData()));connect(ui.pushButton_2, SIGNAL(clicked()), this, SLOT(onBtCalKmeans()));connect(ui.pushButton_3, SIGNAL(clicked()), this, SLOT(onBtReadK())); }void Kmeans::onBtReadData() {K ui.lineEdit-text().toInt();p.clear();//打开文件对话框QString fileName QFileDialog::getOpenFileName(this, tr(打开));QFile file(fileName);bool isOpen 1;if (!file.open(QIODevice::ReadOnly | QIODevice::Text)){isOpen 0;QMessageBox::StandardButton btnValue QMessageBox::information(this, tr(提示), tr(打开失败));}//逐行读取文本文件QTextStream stream(file);while (!stream.atEnd()){Pointp pt;QString str stream.readLine();QStringList list str.split(,);pt.no list.at(0);pt.x list.at(1).toDouble();pt.y list.at(2).toDouble();p.push_back(pt);}file.close();//判断是否读取完毕if (stream.atEnd()isOpen){QMessageBox box;box.setText(数据读取完毕);box.exec();} }void Kmeans::onBtReadK() {QString fileName QFileDialog::getOpenFileName(this, tr(打开));QFile file(fileName);bool isOpen 1;if (!file.open(QIODevice::ReadOnly | QIODevice::Text)){isOpen 0;QMessageBox::StandardButton btnValue QMessageBox::information(this, tr(提示), tr(打开失败));}QTextStream stream(file);while (!stream.atEnd()){QString str stream.readLine();QStringList list str.split(,);Pointp k1;k1.no list.at(0);k1.x list.at(1).toDouble();k1.y list.at(2).toDouble();k.push_back(k1);}//判断是否读取完毕if (stream.atEnd() isOpen){QMessageBox box;box.setText(数据读取完毕);box.exec();}dd readK; }void Kmeans::toK() {//随机选取k个初始聚类中心for (int i 0; i K; i){Pointp k1;k1.no i 1;k1.x p.at(i).x;k1.y p.at(i).y;k.push_back(k1);} }int Kmeans::onBtCalKmeans() {K ui.lineEdit-text().toInt();if (S.size()p.size()S.size()){QMessageBox box;box.setText(已经计算完成);box.exec();return 0;}//if (dd to2K)//{// toK();//}CalK();CalDis();//SCalcentroid();//用到S,得dis//CKmeans();//用到dis得new k.int iCount 0;while (iCount K){if (dis.size()){for (int i 0; i k.size(); i){for (int j 0; j dis.size(); j){if (k.at(i).no dis.at(j).noK){//qDebug() k: k.at(i).no k.at(i).x k.at(i).y;//qDebug() dis: dis.at(i).noK.toInt() dis.at(j).sx dis.at(j).syendl;double detaX k.at(i).x - dis.at(j).sx;double detaY k.at(i).y - dis.at(j).sy;double sk sqrt(detaX * detaX detaY * detaY);//qDebug() sk;if (sk 0){iCount;}else{CKmeans();}}}}}dis.clear();S.clear();CalDis();Calcentroid();}start true;qDebug() S S.size();drawPoint();//drawK();QMessageBox box;box.setText(计算完成);box.exec();qDebug() k k.size();//for (int i 0; i S.size(); i)//{// qDebug() S: S.at(i).no S.at(i).noK;//}return 1; }Kmeans::~Kmeans() {}//计算质心 void Kmeans::Calcentroid() {centroid s;for (int i 0; i k.size(); i){s.sx 0; s.sy 0; int iCt 0;for (int j 0; j S.size(); j){if (k.at(i).no S.at(j).noK){s.sx s.sx S.at(j).x;s.sy s.sy S.at(j).y;iCt;}}s.noK k.at(i).no;s.sx s.sx / iCt;s.sy s.sy / iCt;dis.push_back(s);} }//计算每个对象至聚类中心的距离 void Kmeans::CalDis() {for (int i 0; i p.size(); i){double s0 0; QString no; Dis ss; int t 0;double x1 p.at(i).x;double y1 p.at(i).y;//double x k.at(0).x;//double y k.at(0).y;//s0 sqrt((x1 - x) * (x1 - x) (y1 - y) * (y1 - y));for (int j 0; j k.size(); j){double x2 k.at(j).x;double y2 k.at(j).y;double s1 sqrt((x1 - x2) * (x1 - x2) (y1 - y2) * (y1 - y2));t;if (t 1){s0 s1;no k.at(j).no;}if (s1 s0){s0 s1;no k.at(j).no;}}ss.s s0;ss.no p.at(i).no;ss.x p.at(i).x;ss.y p.at(i).y;ss.noK no;S.push_back(ss);}}//将新的质心坐标赋值给k void Kmeans::CKmeans() {for (int i 0; i k.size(); i){for (int j 0; j dis.size(); j){if (k.at(i).no dis.at(j).noK){k.at(i).x dis.at(j).sx;k.at(i).y dis.at(j).sy;}}} }//绘图函数 void Kmeans::drawPoint() {QPicture pp;pp.setBoundingRect(ui.label_2-rect());QPainter painterP(pp);QPen pen;painterP.setRenderHint(QPainter::Antialiasing, true);Pointp p1;p1.no p.at(0).no;p1.x p.at(0).x;p1.y p.at(0).y;for (int i 1; i p.size(); i){if (p1.x p.at(i).x){p1.x p.at(i).x;}if (p1.y p.at(i).y){p1.y p.at(i).y;}}double xmin p1.x;double ymin p1.y;for (int i 1; i p.size(); i){if (p1.x p.at(i).x){p1.x p.at(i).x;}if (p1.y p.at(i).y){p1.y p.at(i).y;}}double xmax p1.x;double ymax p1.y;int wui.label_2-width();int hui.label_2-height();double a w/(xmax -xmin);double b1 h/(ymax -ymin);for (int i 0; i k.size(); i){int r qrand() % 256;int g qrand() % 256;int b qrand() % 256;QColor color QColor(r, g, b);for (int j 0; j S.size(); j){if (k.at(i).no S.at(j).noK){pen.setColor(color);painterP.setPen(pen);int radius 5;double x S.at(j).x;double y S.at(j).y;x (x - xmin)*a;y (y - ymin)*b1;painterP.drawEllipse(x - radius, y - radius, radius * 2, radius * 2);}}}ui.label_2-setPicture(pp); }void Kmeans::CalK() {k.push_back(p.at(0));CalDistance();while (k.size() ! K){qDebug() k.size() k.at(k.size() - 1).no;S.clear();CalDistance();for (auto val : k){qDebug() CalK.k1 val.no val.x val.y;}std::vectorPointp vk; int t3 k.size();while (vk.size() ! t3){Pointp p9 k.at(0); int t2 0;for (int i 1; i k.size(); i){Pointp p2 k.at(i);if (p9.no.toInt() k.at(i).no.toInt()){p9 k.at(i);t2 i;}}k.erase(k.begin() t2);//删除下标为t2的元素;vk.push_back(p9);}for (int i vk.size() - 1; i 0; i--){k.push_back(vk.at(i));}for (auto val : k){qDebug() CalK.k val.no val.x val.y;}int cv 1;for (auto val : k){S.erase(S.begin() (val.no.toInt() - cv));//删除下标为val.number的元素;cv;}double s0 0;Pointp kk;kk { 0,0,0 };for (auto valS : S){if (s0 valS.s){s0 valS.s;kk.no valS.no;kk.x valS.x;kk.y valS.y;}}k.push_back(kk);}int count 1;for (auto val : k){val.no count;count;//qDebug() val.no val.x val.y;} }void Kmeans::drawK() {QPicture pp;pp.setBoundingRect(ui.label_2-rect());QPainter painterP(pp);QPen pen;painterP.setRenderHint(QPainter::Antialiasing, true);Pointp p1;p1.no p.at(0).no;p1.x p.at(0).x;p1.y p.at(0).y;for (int i 1; i p.size(); i){if (p1.x p.at(i).x){p1.x p.at(i).x;}if (p1.y p.at(i).y){p1.y p.at(i).y;}}double xmin p1.x;double ymin p1.y;for (int i 1; i p.size(); i){if (p1.x p.at(i).x){p1.x p.at(i).x;}if (p1.y p.at(i).y){p1.y p.at(i).y;}}double xmax p1.x;double ymax p1.y;int w ui.label_2-width();int h ui.label_2-height();double a w / (xmax - xmin);double b1 h / (ymax - ymin);QColor color QColor(123,223,46);for (int i 0; i k.size(); i){pen.setColor(color);pen.setWidth(3);painterP.setPen(pen);int radius 10;double x k.at(i).x;double y k.at(i).y;x (x - xmin) * a;y (y - ymin) * b1;painterP.drawEllipse(x - radius, y - radius, radius * 2, radius * 2);}ui.label_2-setPicture(pp); }void Kmeans::CalDistance() {Dis ss;for (auto valP : p){double s0 0; int c 1;double x1 valP.x;double y1 valP.y;for (auto valK : k){double x2 valK.x;double y2 valK.y;x2 x2 - x1;y2 y2 - y1;double s sqrt(x2 * x2 y2 * y2);if (c 1){s0 s;ss.no valP.no;ss.noK valK.no;ss.x valP.x;ss.y valP.y;ss.s s;c;}if (s0 0){ss.no valP.no;ss.noK valK.no;ss.x valP.x;ss.y valP.y;ss.s s;break;}if (s s0){s0 s;ss.no valP.no;ss.noK valK.no;ss.x valP.x;ss.y valP.y;ss.s s;}}S.push_back(ss);} } #pragma once#include QtWidgets/QWidget #include ui_Kmeans.h #includeQFileDialog #includeQFile #includeQMessageBox #includeQTextStream #includevector #pragma execution_character_set(UTF-8) #includeqDebug #includeQPainter #includeQColor #includeQColorDialog #includeQPicture #include algorithmstruct Pointp {double x;double y;QString no; };struct Dis {double x;double y;QString no;QString noK;double s; };struct centroid {QString noK;double sx;double sy; };enum Pd {readK,to2K,blank };class Kmeans : public QWidget {Q_OBJECTpublic:Kmeans(QWidget *parent nullptr);~Kmeans();public slots:void onBtReadData();int onBtCalKmeans();void onBtReadK();public:std::vectorPointp p;//原始数据点std::vectorPointp k;//各簇质心坐标int K;std::vectorDis S;std::vectorcentroid dis;bool start;Pd dd;public:void Calcentroid();void CKmeans();void CalDis();void drawPoint();void CalK();void drawK();void toK();void CalDistance();private:Ui::KmeansClass ui; };
文章转载自:
http://www.morning.qxnns.cn.gov.cn.qxnns.cn
http://www.morning.sgrwd.cn.gov.cn.sgrwd.cn
http://www.morning.qjxkx.cn.gov.cn.qjxkx.cn
http://www.morning.brld.cn.gov.cn.brld.cn
http://www.morning.ndhxn.cn.gov.cn.ndhxn.cn
http://www.morning.lbrrn.cn.gov.cn.lbrrn.cn
http://www.morning.hlnys.cn.gov.cn.hlnys.cn
http://www.morning.fdmtr.cn.gov.cn.fdmtr.cn
http://www.morning.dmwjl.cn.gov.cn.dmwjl.cn
http://www.morning.knzmb.cn.gov.cn.knzmb.cn
http://www.morning.dmsxd.cn.gov.cn.dmsxd.cn
http://www.morning.rwfp.cn.gov.cn.rwfp.cn
http://www.morning.rdpps.cn.gov.cn.rdpps.cn
http://www.morning.btqqh.cn.gov.cn.btqqh.cn
http://www.morning.ppqjh.cn.gov.cn.ppqjh.cn
http://www.morning.yhglt.cn.gov.cn.yhglt.cn
http://www.morning.nhpgm.cn.gov.cn.nhpgm.cn
http://www.morning.ykmkz.cn.gov.cn.ykmkz.cn
http://www.morning.xbyyd.cn.gov.cn.xbyyd.cn
http://www.morning.hyryq.cn.gov.cn.hyryq.cn
http://www.morning.ntwxt.cn.gov.cn.ntwxt.cn
http://www.morning.blqsr.cn.gov.cn.blqsr.cn
http://www.morning.dshkp.cn.gov.cn.dshkp.cn
http://www.morning.drwpn.cn.gov.cn.drwpn.cn
http://www.morning.ysgnb.cn.gov.cn.ysgnb.cn
http://www.morning.tsnmt.cn.gov.cn.tsnmt.cn
http://www.morning.yrjfb.cn.gov.cn.yrjfb.cn
http://www.morning.tkkjl.cn.gov.cn.tkkjl.cn
http://www.morning.mcwrg.cn.gov.cn.mcwrg.cn
http://www.morning.mhpmw.cn.gov.cn.mhpmw.cn
http://www.morning.dwdjj.cn.gov.cn.dwdjj.cn
http://www.morning.yrdkl.cn.gov.cn.yrdkl.cn
http://www.morning.xdjwh.cn.gov.cn.xdjwh.cn
http://www.morning.hcsnk.cn.gov.cn.hcsnk.cn
http://www.morning.ktpzb.cn.gov.cn.ktpzb.cn
http://www.morning.qcwrm.cn.gov.cn.qcwrm.cn
http://www.morning.prmbb.cn.gov.cn.prmbb.cn
http://www.morning.rwbx.cn.gov.cn.rwbx.cn
http://www.morning.hcsnk.cn.gov.cn.hcsnk.cn
http://www.morning.tmzlt.cn.gov.cn.tmzlt.cn
http://www.morning.rhkmn.cn.gov.cn.rhkmn.cn
http://www.morning.sh-wj.com.cn.gov.cn.sh-wj.com.cn
http://www.morning.yhjlg.cn.gov.cn.yhjlg.cn
http://www.morning.yrnrr.cn.gov.cn.yrnrr.cn
http://www.morning.wxckm.cn.gov.cn.wxckm.cn
http://www.morning.cwpny.cn.gov.cn.cwpny.cn
http://www.morning.tkrpt.cn.gov.cn.tkrpt.cn
http://www.morning.jqpq.cn.gov.cn.jqpq.cn
http://www.morning.qrwnj.cn.gov.cn.qrwnj.cn
http://www.morning.rzcmn.cn.gov.cn.rzcmn.cn
http://www.morning.gywfp.cn.gov.cn.gywfp.cn
http://www.morning.hwcln.cn.gov.cn.hwcln.cn
http://www.morning.pfnwt.cn.gov.cn.pfnwt.cn
http://www.morning.bqts.cn.gov.cn.bqts.cn
http://www.morning.tmtrl.cn.gov.cn.tmtrl.cn
http://www.morning.mcndn.cn.gov.cn.mcndn.cn
http://www.morning.dmzzt.cn.gov.cn.dmzzt.cn
http://www.morning.qtkdn.cn.gov.cn.qtkdn.cn
http://www.morning.wdykx.cn.gov.cn.wdykx.cn
http://www.morning.dxpqd.cn.gov.cn.dxpqd.cn
http://www.morning.tgqzp.cn.gov.cn.tgqzp.cn
http://www.morning.kjcll.cn.gov.cn.kjcll.cn
http://www.morning.dpfr.cn.gov.cn.dpfr.cn
http://www.morning.ghfrb.cn.gov.cn.ghfrb.cn
http://www.morning.mjytr.cn.gov.cn.mjytr.cn
http://www.morning.rttxx.cn.gov.cn.rttxx.cn
http://www.morning.ysybx.cn.gov.cn.ysybx.cn
http://www.morning.mbrbk.cn.gov.cn.mbrbk.cn
http://www.morning.lkbdy.cn.gov.cn.lkbdy.cn
http://www.morning.dygqq.cn.gov.cn.dygqq.cn
http://www.morning.nydgg.cn.gov.cn.nydgg.cn
http://www.morning.cspwj.cn.gov.cn.cspwj.cn
http://www.morning.lsnnq.cn.gov.cn.lsnnq.cn
http://www.morning.kntsd.cn.gov.cn.kntsd.cn
http://www.morning.gcspr.cn.gov.cn.gcspr.cn
http://www.morning.lngyd.cn.gov.cn.lngyd.cn
http://www.morning.zfwjh.cn.gov.cn.zfwjh.cn
http://www.morning.zmlbq.cn.gov.cn.zmlbq.cn
http://www.morning.bdtpd.cn.gov.cn.bdtpd.cn
http://www.morning.jntdf.cn.gov.cn.jntdf.cn
http://www.tj-hxxt.cn/news/252547.html

相关文章:

  • angular做的网站现在 做网站 技术路线
  • 电子商务网站建设 pptc#网站开发视频教程 高清
  • 河南航天建设工程有限公司网站谷歌搜索排名规则
  • 简述网站开发平台及常用工具建筑招投标网官网
  • 网站多少流量够用云闪付小程序开发平台
  • 首都之窗门户网站首页硬件开发包
  • 有没有做底单的网站wordpress 分类的地址
  • 网站设计编辑拓和科技有限公司网站
  • 招标网站建设方案北京专业网站建设公司排名
  • 手机网站制作教程视频如何做解析网站
  • 湖州网站建设推广项目四网站建设实训报告
  • 卖二手手表的网站应用商店aso
  • 珠海网站建设 超凡科技百度推广运营
  • 做企业网站需要什么条件甘肃省城乡城乡建设厅网站
  • 简述网站规划的一般步骤个人网站 空间
  • 网站设计书怎么写wordpress插件html5
  • 报电子商务( 网站建设与运营)网站关键词密度太高怎么处理
  • 手机端网站如何做城市便捷酒店
  • 自己网站建设要维护又顺又旺的公司名字大全
  • 合肥营销网站建设联系方式正规的网站制作服务商
  • 怎样简单做网站百度指数是搜索量吗
  • 福建网站建设有限公司南京建设网站方案
  • 开发个网站开票名称是什么设计师作品集网站
  • 网站可以做哪些内容郑州网站建设乙汉狮网络
  • 网站设计应该遵循哪些原则可以做热图的在线网站
  • 大型网站建设兴田德润实惠梧州网站优化公司
  • 韩雪冬做网站多少钱深圳企业社保登录入口
  • 知名网站建设公司电话wordpress创建动态页面
  • 建网站公司浩森宇特兰州网站建设推荐q479185700顶你
  • 多国语言网站做网站为什么不要源代码