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

易优cms仿站教程中国正国级名单

易优cms仿站教程,中国正国级名单,电子商务网站建设的期中考试,网站不收录是什么原因代码来自闵老师”日撸 Java 三百行#xff08;61-70天#xff09; 日撸 Java 三百行#xff08;61-70天#xff0c;决策树与集成学习#xff09;_闵帆的博客-CSDN博客 学习过程中理解算法参考了#xff1a;#xff08;十三#xff09;通俗易懂理解——Adaboost算法原… 代码来自闵老师”日撸 Java 三百行61-70天 日撸 Java 三百行61-70天决策树与集成学习_闵帆的博客-CSDN博客 学习过程中理解算法参考了十三通俗易懂理解——Adaboost算法原理 - 知乎 (zhihu.com) 今天的代码的核心是方法adjustWeights(boolean[] paraCorrectArray, double paraAlpha)。分类正确的实例权重调整为原值除以Math.exp(paraAlpha)分类错误的调整为原值乘以Math.exp(paraAlpha)。 测试方法里之所以for循环到tempCorrectArray长度的一半仅仅是为了测试。相当于设置弱分类器分类正确了一半。 package machinelearning.adaboosting;import java.io.FileReader; import java.util.Arrays;import weka.core.Instances;/*** Weighted instances.br* * author WX873**/ public class WeightedInstances extends Instances{/*** Just the requirement of some classes, any number is ok.*/private static final long serialVersionUID 11087456L;/*** Weights*/private double[] weights;/*** *************************************************** The first constructor.* * param paraFileReader The given reader to read data from file.* throws Exception* ***************************************************/public WeightedInstances(FileReader paraFileReader) throws Exception{// TODO Auto-generated constructor stubsuper(paraFileReader);setClassIndex(numAttributes() - 1);// Initialize weightsweights new double[numInstances()];double tempAverage 1.0/numInstances();for (int i 0; i weights.length; i) {weights[i] tempAverage;}//of for iSystem.out.println(Instances weights are: Arrays.toString(weights));}//of the first constructor/*** *********************************************************** The second constructor.* * param paraInstances* ***********************************************************/public WeightedInstances(Instances paraInstances) {// TODO Auto-generated constructor stubsuper(paraInstances);setClassIndex(numAttributes() - 1);//Initialize weightsweights new double[numInstances()];double tempAverage 1.0/numInstances();for (int i 0; i weights.length; i) {weights[i] tempAverage;}//of for iSystem.out.println(Instances weights are: Arrays.toString(weights));}//of the second constructor/*** **************************************************** Getter.* * param paraIndex The given index.* return The weight of the given index.* ****************************************************/public double getWeight(int paraIndex) {return weights[paraIndex];}//of getWeight/*** ****************************************************** Adjust the weights.* * param paraCorrectArray Indicate which instances have been correctly classified.* param paraAlpha The weight of the last classifier.* ******************************************************/public void adjustWeights(boolean[] paraCorrectArray, double paraAlpha) {//Step 1. Calculate alpha.double tempIncrease Math.exp(paraAlpha);//Step 2. Adjust.double tempWeightsSum 0; // For normalization.for (int i 0; i weights.length; i) {if (paraCorrectArray[i]) {weights[i] / tempIncrease;} else {weights[i] * tempIncrease;}//of iftempWeightsSum weights[i];}//of for i// Step 3. Normalize.for (int i 0; i weights.length; i) {weights[i] / tempWeightsSum;}//of for iSystem.out.println(After adjusting, instances weights are: Arrays.toString(weights));}//of adjustWeights/*** ********************************************** Test the method.* **********************************************/public void adjustWeightsTest() {boolean[] tempCorrectArray new boolean[numInstances()];for (int i 0; i tempCorrectArray.length / 2; i) { //仅仅是测试adjustWeights方法,因为还没有分类器设置分类正确了一半tempCorrectArray[i] true;}//of for idouble tempWeightedError 0.3;adjustWeights(tempCorrectArray, tempWeightedError); //仅仅是测试adjustWeights方法,因为还没有分类器System.out.println(After adjusting);System.out.println(toString());}//of adjustWeightsTest/*** ********************************************************* For display.* *********************************************************/public String toString() {String resultString I am a weighted Instances object.\r\n I have numInstances() instances and (numAttributes() - 1) conditional attributes.\r\n My weights are: Arrays.toString(weights) \r\n My data are: \r\n super.toString();return resultString;}//of toString/*** ************************************************************ The entrance of the program.* * param args* ************************************************************/public static void main(String args[]) {WeightedInstances tempWeightedInstances null;String tempFilename E:/Datasets/UCIdatasets/其他数据集/iris.arff;try {FileReader tempFileReader new FileReader(tempFilename);tempWeightedInstances new WeightedInstances(tempFileReader);tempFileReader.close();} catch (Exception exception1) {// TODO: handle exceptionSystem.out.println(Cannot read the file: tempFilename \r\n exception1);System.exit(0);}//of trySystem.out.println(tempWeightedInstances.toString());tempWeightedInstances.adjustWeightsTest();}//of main}//of WeightedInstances
http://www.w-s-a.com/news/201814/

相关文章:

  • 网络公司除了做网站产品设计作品
  • dede网站模板替换湘潭建设路街道网站
  • 东莞网站优化效果如何网络设计工作
  • 网站备案系统验证码出错的解决方案任丘建设银行网站
  • 个人博客建站wordpress叮当app制作
  • 网站式的公司记录怎么做二手书网站策划书
  • 营销型网站的建设重点是什么帝国程序和WordPress
  • 正能量网站推荐不需要下载巴中网站建设开发公司
  • 学生模拟网站开发西安seo平台
  • 免费的app推广平台免费网站seo
  • 建一个个人网站网站建设中小企业广西
  • 优惠券网站做淘客违规吗个人建网站运营.
  • 旅游网站制作建设华大基因 网站建设
  • sem推广竞价托管南京seo网站优化
  • 网站优化网站建站教程网站建设 成都
  • 网站 配色表html代码在线
  • 城乡和建设部建造师网站众筹平台网站建设
  • 外贸网站模板免费下载微网站制作软件
  • 一个新的网站怎么做宣传技术先进的网站建
  • 福建网站建设有限公司需求网站
  • 生物科技企业网站做的比较好的企业培训网站模板
  • 南京 高端网站建设网站备案密码怎么找回
  • 蛋糕店网站模板建设电子商务系统网站
  • 海口网站建设优化公司网站开发要加班吗
  • 建设一个网站需要注意哪些要求群晖的网站开发
  • 精通网站开发阅读网页视频下载慢怎么办
  • 网站标题的选择巴音郭楞库尔勒网站建设
  • 成都市网站建设服务商怎么进网站后台管理系统
  • 企业网站站内优化30岁做网站编辑
  • 与安网站建设网站建设征求意见稿