• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java DistanceFunction类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中weka.core.DistanceFunction的典型用法代码示例。如果您正苦于以下问题:Java DistanceFunction类的具体用法?Java DistanceFunction怎么用?Java DistanceFunction使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



DistanceFunction类属于weka.core包,在下文中一共展示了DistanceFunction类的16个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: setOptions

import weka.core.DistanceFunction; //导入依赖的package包/类
/**
 * Parses a given list of options. Valid options are:
 * 
 * <!-- options-start --> <!-- options-end -->
 * 
 * @param options the list of options as an array of strings
 * @throws Exception if an option is not supported
 */
@Override
public void setOptions(String[] options) throws Exception {
  String nnSearchClass = Utils.getOption('A', options);
  if (nnSearchClass.length() != 0) {
    String nnSearchClassSpec[] = Utils.splitOptions(nnSearchClass);
    if (nnSearchClassSpec.length == 0) {
      throw new Exception("Invalid DistanceFunction specification string.");
    }
    String className = nnSearchClassSpec[0];
    nnSearchClassSpec[0] = "";

    setDistanceFunction((DistanceFunction) Utils.forName(
      DistanceFunction.class, className, nnSearchClassSpec));
  } else {
    setDistanceFunction(new EuclideanDistance());
  }

  setMeasurePerformance(Utils.getFlag('P', options));
}
 
开发者ID:mydzigear,项目名称:repo.kmeanspp.silhouette_score,代码行数:28,代码来源:NearestNeighbourSearch.java


示例2: setOptions

import weka.core.DistanceFunction; //导入依赖的package包/类
/**
 * Parses a given list of options. Valid options are:
 *
 <!-- options-start -->
 <!-- options-end -->
 *
 * @param options 	the list of options as an array of strings
 * @throws Exception 	if an option is not supported
 */
public void setOptions(String[] options) throws Exception {
  String nnSearchClass = Utils.getOption('A', options);
  if(nnSearchClass.length() != 0) {
    String nnSearchClassSpec[] = Utils.splitOptions(nnSearchClass);
    if(nnSearchClassSpec.length == 0) { 
      throw new Exception("Invalid DistanceFunction specification string."); 
    }
    String className = nnSearchClassSpec[0];
    nnSearchClassSpec[0] = "";

    setDistanceFunction( (DistanceFunction)
                          Utils.forName( DistanceFunction.class, 
                                         className, nnSearchClassSpec) );
  }
  else {
    setDistanceFunction(new EuclideanDistance());
  }
  
  setMeasurePerformance(Utils.getFlag('P',options));
}
 
开发者ID:dsibournemouth,项目名称:autoweka,代码行数:30,代码来源:NearestNeighbourSearch.java


示例3: useCosine

import weka.core.DistanceFunction; //导入依赖的package包/类
private IBk useCosine() {
	IBk ibk = new IBk();
	Instances data = ClassificationModel.getInstance().getInstances();
	Normalize normalizer = new Normalize(); 
	
	try {
		normalizer.setInputFormat(data);

		// Euclidean Distance working over normalized instances = Cosine Similarity according to Foundations of Statistical Natural Processing Language p.301
		// As long as attribute normalization is disabled.
		Instances normalizedInstances; 
		normalizedInstances = Filter.useFilter(data, normalizer); 
		ClassificationModel.getInstance().setInstances(normalizedInstances);
		DistanceFunction df = new EuclideanDistance(); 
		((EuclideanDistance) df).setDontNormalize(true); 		                        
		ibk.getNearestNeighbourSearchAlgorithm().setDistanceFunction(df); 
	} catch (Exception e) {
		// TODO Auto-generated catch block
		e.printStackTrace();
	}
	
	return ibk;
}
 
开发者ID:a-n-d-r-e-i,项目名称:seagull,代码行数:24,代码来源:Classification.java


示例4: setDistanceFunction

import weka.core.DistanceFunction; //导入依赖的package包/类
/**
 * sets the distance function to use for instance comparison.
 * 
 * @param df the new distance function to use
 * @throws Exception if instances cannot be processed
 */
public void setDistanceFunction(DistanceFunction df) throws Exception {
  if (!(df instanceof EuclideanDistance)
    && !(df instanceof ManhattanDistance)) {
    throw new Exception(
      "SimpleKMeans currently only supports the Euclidean and Manhattan distances.");
  }
  m_DistanceFunction = df;
}
 
开发者ID:mydzigear,项目名称:repo.kmeanspp.silhouette_score,代码行数:15,代码来源:SimpleKMeans.java


示例5: setDistanceFunction

import weka.core.DistanceFunction; //导入依赖的package包/类
/**
 * sets the distance function to use for instance comparison.
 * 
 * @param df the new distance function to use
 * @throws Exception if instances cannot be processed
 */
public void setDistanceFunction(DistanceFunction df) throws Exception {
  if (!(df instanceof EuclideanDistance)
    && !(df instanceof ManhattanDistance)) {
    throw new Exception(
      "KMeansPlusPlus only supports the Euclidean and Manhattan distances.");
  }
  m_DistanceFunction = df;
}
 
开发者ID:mydzigear,项目名称:repo.kmeanspp.silhouette_score,代码行数:15,代码来源:KMeansPlusPlusSC.java


示例6: getDistanceSpec

import weka.core.DistanceFunction; //导入依赖的package包/类
/**
  * Gets the distance specification string, which contains the class name of
  * the distance and any options to the distance
  *
  * @return the distance string.
  */
 protected String getDistanceSpec() {
   
   DistanceFunction c = getDistance();
   if (c instanceof OptionHandler) {
     return c.getClass().getName() + " "
+ Utils.joinOptions(((OptionHandler)c).getOptions());
   }
   return c.getClass().getName();
 }
 
开发者ID:mydzigear,项目名称:repo.kmeanspp.silhouette_score,代码行数:16,代码来源:FilteredDistance.java


示例7: setDistanceFunction

import weka.core.DistanceFunction; //导入依赖的package包/类
/**
 * Sets the distance function to use for nearest neighbour search. Currently
 * only EuclideanDistance is supported.
 * 
 * @param df the distance function to use
 * @throws Exception if not EuclideanDistance
 */
@Override
public void setDistanceFunction(DistanceFunction df) throws Exception {
  if (!(df instanceof EuclideanDistance)) {
    throw new Exception("CoverTree currently only works with "
      + "EuclideanDistanceFunction.");
  }
  m_DistanceFunction = m_EuclideanDistance = (EuclideanDistance) df;
}
 
开发者ID:mydzigear,项目名称:repo.kmeanspp.silhouette_score,代码行数:16,代码来源:CoverTree.java


示例8: setDistanceFunction

import weka.core.DistanceFunction; //导入依赖的package包/类
/**
 * sets the distance function to use for nearest neighbour search.
 * 
 * @param df		the distance function to use
 * @throws Exception	if not EuclideanDistance
 */
public void setDistanceFunction(DistanceFunction df) throws Exception {
  if (!(df instanceof EuclideanDistance))
    throw new Exception("KDTree currently only works with "
        + "EuclideanDistanceFunction.");
  m_DistanceFunction = m_EuclideanDistance = (EuclideanDistance) df;
}
 
开发者ID:mydzigear,项目名称:repo.kmeanspp.silhouette_score,代码行数:13,代码来源:KDTree.java


示例9: setDistanceFunction

import weka.core.DistanceFunction; //导入依赖的package包/类
/**
  * sets the distance function to use for instance comparison.
  * 
  * @param df the new distance function to use
  * @throws Exception if instances cannot be processed
  */
 public void setDistanceFunction(DistanceFunction df) throws Exception {
   if (!(df instanceof EuclideanDistance) && 
!(df instanceof ManhattanDistance))      {
     throw new Exception("SimpleKMeans currently only supports the Euclidean and Manhattan distances.");
   }
   m_DistanceFunction = df;
 }
 
开发者ID:guojiasheng,项目名称:LibD3C-1.1,代码行数:14,代码来源:SimpleKMeans.java


示例10: getDistanceFSpec

import weka.core.DistanceFunction; //导入依赖的package包/类
/**
  * Gets the distance function specification string, which contains the 
  * class name of the distance function class and any options to it.
  *
  * @return the distance function specification string
  */
 protected String getDistanceFSpec() {
   
   DistanceFunction d = getDistanceF();
   if (d instanceof OptionHandler) {
     return d.getClass().getName() + " "
+ Utils.joinOptions(((OptionHandler) d).getOptions());
   }
   return d.getClass().getName();
 }
 
开发者ID:williamClanton,项目名称:jbossBA,代码行数:16,代码来源:XMeans.java


示例11: getDistanceFunction

import weka.core.DistanceFunction; //导入依赖的package包/类
public DistanceFunction getDistanceFunction() {
  return m_DistanceFunction;
}
 
开发者ID:mydzigear,项目名称:repo.kmeanspp.silhouette_score,代码行数:4,代码来源:HierarchicalClusterer.java


示例12: setDistanceFunction

import weka.core.DistanceFunction; //导入依赖的package包/类
public void setDistanceFunction(DistanceFunction distanceFunction) {
  m_DistanceFunction = distanceFunction;
}
 
开发者ID:mydzigear,项目名称:repo.kmeanspp.silhouette_score,代码行数:4,代码来源:HierarchicalClusterer.java


示例13: setOptions

import weka.core.DistanceFunction; //导入依赖的package包/类
/**
 * Parses a given list of options.
 * <p/>
 * 
 * <!-- options-start --> Valid options are:
 * <p/>
 * 
 * <!-- options-end -->
 * 
 * @param options the list of options as an array of strings
 * @throws Exception if an option is not supported
 */
@Override
public void setOptions(String[] options) throws Exception {
  m_bPrintNewick = Utils.getFlag('P', options);

  String optionString = Utils.getOption('N', options);
  if (optionString.length() != 0) {
    Integer temp = new Integer(optionString);
    setNumClusters(temp);
  } else {
    setNumClusters(2);
  }

  setDistanceIsBranchLength(Utils.getFlag('B', options));

  String sLinkType = Utils.getOption('L', options);

  if (sLinkType.compareTo("SINGLE") == 0) {
    setLinkType(new SelectedTag(SINGLE, TAGS_LINK_TYPE));
  }
  if (sLinkType.compareTo("COMPLETE") == 0) {
    setLinkType(new SelectedTag(COMPLETE, TAGS_LINK_TYPE));
  }
  if (sLinkType.compareTo("AVERAGE") == 0) {
    setLinkType(new SelectedTag(AVERAGE, TAGS_LINK_TYPE));
  }
  if (sLinkType.compareTo("MEAN") == 0) {
    setLinkType(new SelectedTag(MEAN, TAGS_LINK_TYPE));
  }
  if (sLinkType.compareTo("CENTROID") == 0) {
    setLinkType(new SelectedTag(CENTROID, TAGS_LINK_TYPE));
  }
  if (sLinkType.compareTo("WARD") == 0) {
    setLinkType(new SelectedTag(WARD, TAGS_LINK_TYPE));
  }
  if (sLinkType.compareTo("ADJCOMPLETE") == 0) {
    setLinkType(new SelectedTag(ADJCOMPLETE, TAGS_LINK_TYPE));
  }
  if (sLinkType.compareTo("NEIGHBOR_JOINING") == 0) {
    setLinkType(new SelectedTag(NEIGHBOR_JOINING, TAGS_LINK_TYPE));
  }

  String nnSearchClass = Utils.getOption('A', options);
  if (nnSearchClass.length() != 0) {
    String nnSearchClassSpec[] = Utils.splitOptions(nnSearchClass);
    if (nnSearchClassSpec.length == 0) {
      throw new Exception("Invalid DistanceFunction specification string.");
    }
    String className = nnSearchClassSpec[0];
    nnSearchClassSpec[0] = "";

    setDistanceFunction((DistanceFunction) Utils.forName(
      DistanceFunction.class, className, nnSearchClassSpec));
  } else {
    setDistanceFunction(new EuclideanDistance());
  }

  super.setOptions(options);

  Utils.checkForRemainingOptions(options);
}
 
开发者ID:mydzigear,项目名称:repo.kmeanspp.silhouette_score,代码行数:73,代码来源:HierarchicalClusterer.java


示例14: calcRadius

import weka.core.DistanceFunction; //导入依赖的package包/类
/**
 * Calculates the radius of a node.
 * 
 * @param start The start index of the portion in indices array 
 * that belongs to the node.
 * @param end The end index of the portion in indices array 
 * that belongs to the node. 
 * @param instList The indices array holding indices of 
 * instances. 
 * @param insts The actual instances. instList points to 
 * instances in this object. 
 * @param pivot The centre/pivot of the node. 
 * @param distanceFunction The distance function to use to 
 * calculate the radius. 
 * @return The radius of the node. 
 * @throws Exception If there is some problem calculating the 
 * radius. 
 */
public static double calcRadius(int start, int end, int[] instList, 
                               Instances insts, Instance pivot, 
                               DistanceFunction distanceFunction) 
                                                           throws Exception {
  double radius = Double.NEGATIVE_INFINITY;
  
  for(int i=start; i<=end; i++) {
    double dist = distanceFunction.distance(pivot, 
                                            insts.instance(instList[i]), Double.POSITIVE_INFINITY);
    
    if(dist>radius)
      radius = dist;
  }
  return Math.sqrt(radius);
}
 
开发者ID:mydzigear,项目名称:repo.kmeanspp.silhouette_score,代码行数:34,代码来源:BallNode.java


示例15: setOptions

import weka.core.DistanceFunction; //导入依赖的package包/类
/**
 * Parses a given list of options. <p/>
 *
  <!-- options-start -->
 * Valid options are: <p/>
 * 
  <!-- options-end -->
 *
 * @param options the list of options as an array of strings
 * @throws Exception if an option is not supported
 */
public void setOptions(String[] options) throws Exception {
  m_bPrintNewick = Utils.getFlag('P', options);

  String optionString = Utils.getOption('N', options); 
  if (optionString.length() != 0) {
    Integer temp = new Integer(optionString);
    setNumClusters(temp);
  }
  else {
    setNumClusters(2);
  }

  setDebug(Utils.getFlag('D', options));
  setDistanceIsBranchLength(Utils.getFlag('B', options));

  String sLinkType = Utils.getOption('L', options);


  if (sLinkType.compareTo("SINGLE") == 0) {setLinkType(new SelectedTag(SINGLE, TAGS_LINK_TYPE));}
  if (sLinkType.compareTo("COMPLETE") == 0) {setLinkType(new SelectedTag(COMPLETE, TAGS_LINK_TYPE));}
  if (sLinkType.compareTo("AVERAGE") == 0) {setLinkType(new SelectedTag(AVERAGE, TAGS_LINK_TYPE));}
  if (sLinkType.compareTo("MEAN") == 0) {setLinkType(new SelectedTag(MEAN, TAGS_LINK_TYPE));}
  if (sLinkType.compareTo("CENTROID") == 0) {setLinkType(new SelectedTag(CENTROID, TAGS_LINK_TYPE));}
  if (sLinkType.compareTo("WARD") == 0) {setLinkType(new SelectedTag(WARD, TAGS_LINK_TYPE));}
  if (sLinkType.compareTo("ADJCOMLPETE") == 0) {setLinkType(new SelectedTag(ADJCOMLPETE, TAGS_LINK_TYPE));}
  if (sLinkType.compareTo("NEIGHBOR_JOINING") == 0) {setLinkType(new SelectedTag(NEIGHBOR_JOINING, TAGS_LINK_TYPE));}

  String nnSearchClass = Utils.getOption('A', options);
  if(nnSearchClass.length() != 0) {
    String nnSearchClassSpec[] = Utils.splitOptions(nnSearchClass);
    if(nnSearchClassSpec.length == 0) { 
      throw new Exception("Invalid DistanceFunction specification string."); 
    }
    String className = nnSearchClassSpec[0];
    nnSearchClassSpec[0] = "";

    setDistanceFunction( (DistanceFunction)
        Utils.forName( DistanceFunction.class, 
            className, nnSearchClassSpec) );
  }
  else {
    setDistanceFunction(new EuclideanDistance());
  }

  Utils.checkForRemainingOptions(options);
}
 
开发者ID:dsibournemouth,项目名称:autoweka,代码行数:58,代码来源:HierarchicalClusterer.java


示例16: setDistanceFunction

import weka.core.DistanceFunction; //导入依赖的package包/类
/**
 * Sets the distance function to use for nearest neighbour search.
 * Currently only EuclideanDistance is supported.
 * 
 * @param df 		the distance function to use 
 * @throws Exception 	if not EuclideanDistance
 */
public void setDistanceFunction(DistanceFunction df) throws Exception {
  if (!(df instanceof EuclideanDistance))
    throw new Exception("CoverTree currently only works with "
 + "EuclideanDistanceFunction.");
  m_DistanceFunction = m_EuclideanDistance = (EuclideanDistance) df;
}
 
开发者ID:dsibournemouth,项目名称:autoweka,代码行数:14,代码来源:CoverTree.java



注:本文中的weka.core.DistanceFunction类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java ContextBase类代码示例发布时间:2022-05-22
下一篇:
Java Collection类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap