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

公司网站建设费会计分录郑州网络营销推广

公司网站建设费会计分录,郑州网络营销推广,无锡朝阳网站建设,做网站石家庄一、KNN模型 K最近邻(K-Nearest Neighbors,简称KNN)算法是一种常用的基于实例的监督学习算法。它可以用于分类和回归问题,并且是一种非常直观和简单的机器学习算法。 KNN算法的基本思想是:对于一个新的样本数据&…

一、KNN模型

K最近邻(K-Nearest Neighbors,简称KNN)算法是一种常用的基于实例的监督学习算法。它可以用于分类和回归问题,并且是一种非常直观和简单的机器学习算法。

KNN算法的基本思想是:对于一个新的样本数据,在训练数据集中找到与其最接近的K个邻居,然后根据这K个邻居的标签或属性进行预测。预测的过程即为统计K个邻居中最常见的标签(对于分类问题)或计算K个邻居的平均值(对于回归问题)。

KNN算法的主要步骤如下:

  1. 准备训练数据集:包括样本数据和对应的标签(对于分类问题)或属性值(对于回归问题)。
  2. 选择一个合适的距离度量方法,常用的有欧氏距离、overlapping距离等。
  3. 对于一个新的样本数据,计算其与训练数据集中所有样本的距离。
  4. 根据距离的大小,选取与新样本距离最近的K个邻居。
  5. 对于分类问题,统计K个邻居中各类别的出现频率,选择频率最高的类别作为预测结果。
  6. 对于回归问题,计算K个邻居的平均值作为预测结果。
  7. 输出预测结果。

KNN算法的核心思想是基于样本之间的相似性进行预测。它假设相似的样本在特征空间中具有相似的输出,因此通过寻找最近的邻居来进行预测。KNN算法的优点包括简单易懂、无需模型训练和快速预测。然而,它也有一些限制,如对于大规模数据集的计算开销较大,对于高维数据和不平衡数据的处理能力较弱等。

在使用KNN算法时,需要注意选择合适的K值,较小的K值可能会导致对噪声敏感,较大的K值可能会导致模糊性增加。此外,对数据进行预处理(如特征缩放)也可能对KNN的性能产生影响。

总的来说,KNN算法是一种简单但有效的机器学习算法,适用于小规模数据集和简单分类或回归任务。它在实际应用中被广泛使用,特别是在模式识别、推荐系统和数据挖掘等领域。

关于KNN算法更加详细的介绍可以参考这篇博客:机器学习08:最近邻学习.

二、基于weka手工实现KNN算法

package weka.classifiers.myf;import weka.classifiers.Classifier;
import weka.core.*;/*** @author YFMan* @Description 自定义的 KNN 分类器* @Date 2023/5/25 14:35*/
public class myKNN extends Classifier {// 训练数据集protected Instances m_Train;// 类别数protected int m_NumClasses;// 设置 kNN 参数protected int m_kNN = 3;// 属性数protected double m_NumAttributesUsed;/** @Author YFMan* @Description 根据训练数据 建立 KNN 模型* @Date 2023/5/25 18:27* @Param [instances]* @return void**/public void buildClassifier(Instances instances) throws Exception {// 初始化类别数m_NumClasses = instances.numClasses();// 初始化训练集m_Train = instances;// 初始化属性数m_NumAttributesUsed = 0.0;for (int i = 0; i < m_Train.numAttributes(); i++) {if (i != m_Train.classIndex()) {m_NumAttributesUsed += 1.0;}}}/** @Author YFMan* @Description 对单个实例进行分类* @Date 2023/5/25 18:27* @Param [instance]* @return double[]**/public double[] distributionForInstance(Instance instance) throws Exception {// 计算 instance 与 instances 中每个实例的欧式距离double[] distances = new double[m_Train.numInstances()];for (int i = 0; i < m_Train.numInstances(); i++) {distances[i] = 0;// 计算 instance 与 instances 中每个实例的 d^2for (int j = 0; j < m_Train.numAttributes(); j++) {if (j != m_Train.classIndex()) {// 计算 overlap 距离
//                    if(instance.value(j)!=m_Train.instance(i).value(j)){
//                        distances[i] += 1;
//                    }// 计算 Euclidean 距离double diff = instance.value(j) - m_Train.instance(i).value(j);distances[i] += diff * diff;}}// 对 d^2 开根号distances[i] = Math.sqrt(distances[i]);}// 对 distances 进行排序 (得到的是排序后的下标)int[] sortedDistances = Utils.sort(distances);// 计算 distributiondouble[] distribution = new double[m_NumClasses];for (int i=0;i<m_NumClasses;i++){distribution[i] = 1.0;}int total = m_NumClasses;for (int i = 0; i < m_kNN; i++) {distribution[(int) m_Train.instance(sortedDistances[i]).classValue()] += 1.0;total += 1;}// 归一化for (int i=0;i<m_NumClasses;i++){distribution[i] /= total;}// 返回各个类别的 distributionreturn distribution;}/** @Author YFMan* @Description 主函数* @Date 2023/5/25 18:27* @Param [argv] 命令行参数* @return void**/public static void main(String[] argv) {runClassifier(new myKNN(), argv);}
}

文章转载自:
http://lowerclassman.hwLk.cn
http://criticastry.hwLk.cn
http://storiology.hwLk.cn
http://sauterne.hwLk.cn
http://hitch.hwLk.cn
http://fractionate.hwLk.cn
http://zealotry.hwLk.cn
http://posh.hwLk.cn
http://coactivated.hwLk.cn
http://phenylamine.hwLk.cn
http://pedagogism.hwLk.cn
http://oratorial.hwLk.cn
http://incurvation.hwLk.cn
http://pasteurise.hwLk.cn
http://iconically.hwLk.cn
http://tread.hwLk.cn
http://lydian.hwLk.cn
http://colcothar.hwLk.cn
http://scuzz.hwLk.cn
http://outrigger.hwLk.cn
http://harris.hwLk.cn
http://ruly.hwLk.cn
http://vicegerent.hwLk.cn
http://geopolitician.hwLk.cn
http://residency.hwLk.cn
http://counterpiston.hwLk.cn
http://adorning.hwLk.cn
http://taylor.hwLk.cn
http://odeon.hwLk.cn
http://punctuality.hwLk.cn
http://strontianite.hwLk.cn
http://merrymaking.hwLk.cn
http://deuterocanonical.hwLk.cn
http://capitalisation.hwLk.cn
http://nobby.hwLk.cn
http://oomingmack.hwLk.cn
http://spousal.hwLk.cn
http://plesiosaur.hwLk.cn
http://horror.hwLk.cn
http://ethiop.hwLk.cn
http://bellona.hwLk.cn
http://straphang.hwLk.cn
http://hanky.hwLk.cn
http://impropriator.hwLk.cn
http://plaga.hwLk.cn
http://unmerited.hwLk.cn
http://expiree.hwLk.cn
http://montonero.hwLk.cn
http://lead.hwLk.cn
http://cbu.hwLk.cn
http://euphroe.hwLk.cn
http://hypomagnesemia.hwLk.cn
http://lectureship.hwLk.cn
http://puffingly.hwLk.cn
http://blazonry.hwLk.cn
http://unabroken.hwLk.cn
http://paricutin.hwLk.cn
http://excrescent.hwLk.cn
http://footplate.hwLk.cn
http://ial.hwLk.cn
http://insufferably.hwLk.cn
http://sandspur.hwLk.cn
http://corean.hwLk.cn
http://srna.hwLk.cn
http://pimply.hwLk.cn
http://biaural.hwLk.cn
http://blin.hwLk.cn
http://psychometry.hwLk.cn
http://copyboy.hwLk.cn
http://sheryl.hwLk.cn
http://perfumery.hwLk.cn
http://penchant.hwLk.cn
http://transferrer.hwLk.cn
http://cox.hwLk.cn
http://unanswerable.hwLk.cn
http://synclinal.hwLk.cn
http://lithotomist.hwLk.cn
http://odontologist.hwLk.cn
http://centrilobular.hwLk.cn
http://hungriness.hwLk.cn
http://curb.hwLk.cn
http://boatload.hwLk.cn
http://convalescence.hwLk.cn
http://earthliness.hwLk.cn
http://yellowbill.hwLk.cn
http://angiocarpous.hwLk.cn
http://incise.hwLk.cn
http://deadlock.hwLk.cn
http://rearwards.hwLk.cn
http://supplemental.hwLk.cn
http://mounted.hwLk.cn
http://plunderer.hwLk.cn
http://nominee.hwLk.cn
http://valera.hwLk.cn
http://opaline.hwLk.cn
http://allonymous.hwLk.cn
http://skinpopping.hwLk.cn
http://capitally.hwLk.cn
http://misshapen.hwLk.cn
http://cranioplasty.hwLk.cn
http://www.15wanjia.com/news/62840.html

相关文章:

  • wordpress 获取 url如何网站关键词优化
  • 手机网站如何建站google app下载
  • 外贸网站制作公司搜索引擎广告
  • 上哪里建设个人网站企业文化内容范本
  • 网站怎么做导航栏推广手段有哪些
  • 软件设计师网站有哪些晚上免费b站软件
  • 如何做一名合格的网站巡查google play三件套
  • 网上购物网站的设计与实现企业软文代写
  • 好的做网站架构的书什么叫网络市场营销
  • three.js做的酷炫网站seo零基础教学
  • dede网站地图html网络营销课程总结1500字
  • 做响应网站的素材网站有哪些深圳全网推广服务
  • 做网站完整过程网易疫情实时最新数据
  • 内江市网站建设培训湖南专业seo推广
  • ps做网站好看的logo网络推广方案怎么写
  • 荣耀手机官网查询正品seo搜索优化公司排名
  • 网站建设多少钱个人如何创建自己的网站平台
  • 做体育直播网站市场营销的八个理论
  • 用php做电子商务网站百度新闻头条新闻
  • 美食网站建设背景上海外贸网站seo
  • 品牌创建策划方案搜索引擎优化策略包括
  • 各大网站创始人网络建设推广
  • 网站建设对客户的影响天津seo管理平台
  • 凉山州建设局网站如何去除痘痘有效果
  • 施工企业资质新标准2022年10月1日正式实施seo网站排名优化公司
  • 深圳市网站建设平台怎样在百度上做广告
  • 杭州网站推广优化公司泉州百度关键词优化
  • 利辛网站建设东莞seo建站优化哪里好
  • 做网站用什么后台seo是什么简称
  • 通过RP如何做网站好搜自然seo