当前位置: 首页>>代码示例>>Java>>正文


Java LinearRegression.coefficients方法代码示例

本文整理汇总了Java中weka.classifiers.functions.LinearRegression.coefficients方法的典型用法代码示例。如果您正苦于以下问题:Java LinearRegression.coefficients方法的具体用法?Java LinearRegression.coefficients怎么用?Java LinearRegression.coefficients使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在weka.classifiers.functions.LinearRegression的用法示例。


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

示例1: buildLinearModel

import weka.classifiers.functions.LinearRegression; //导入方法依赖的package包/类
/**
 * Build a linear model for this node using those attributes specified in
 * indices.
 * 
 * @param indices an array of attribute indices to include in the linear model
 * @throws Exception if something goes wrong
 */
private void buildLinearModel(int[] indices) throws Exception {
  // copy the training instances and remove all but the tested
  // attributes
  Instances reducedInst = new Instances(m_instances);
  Remove attributeFilter = new Remove();

  attributeFilter.setInvertSelection(true);
  attributeFilter.setAttributeIndicesArray(indices);
  attributeFilter.setInputFormat(reducedInst);

  reducedInst = Filter.useFilter(reducedInst, attributeFilter);

  // build a linear regression for the training data using the
  // tested attributes
  LinearRegression temp = new LinearRegression();
  temp.buildClassifier(reducedInst);

  double[] lmCoeffs = temp.coefficients();
  double[] coeffs = new double[m_instances.numAttributes()];

  for (int i = 0; i < lmCoeffs.length - 1; i++) {
    if (indices[i] != m_classIndex) {
      coeffs[indices[i]] = lmCoeffs[i];
    }
  }
  m_nodeModel = new PreConstructedLinearModel(coeffs,
    lmCoeffs[lmCoeffs.length - 1]);
  m_nodeModel.buildClassifier(m_instances);
}
 
开发者ID:mydzigear,项目名称:repo.kmeanspp.silhouette_score,代码行数:37,代码来源:RuleNode.java

示例2: buildLinearModel

import weka.classifiers.functions.LinearRegression; //导入方法依赖的package包/类
/**
  * Build a linear model for this node using those attributes
  * specified in indices.
  *
  * @param indices an array of attribute indices to include in the linear
  * model
  * @throws Exception if something goes wrong
  */
 private void buildLinearModel(int [] indices) throws Exception {
   // copy the training instances and remove all but the tested
   // attributes
   Instances reducedInst = new Instances(m_instances);
   Remove attributeFilter = new Remove();
   
   attributeFilter.setInvertSelection(true);
   attributeFilter.setAttributeIndicesArray(indices);
   attributeFilter.setInputFormat(reducedInst);

   reducedInst = Filter.useFilter(reducedInst, attributeFilter);
   
   // build a linear regression for the training data using the
   // tested attributes
   LinearRegression temp = new LinearRegression();
   temp.buildClassifier(reducedInst);

   double [] lmCoeffs = temp.coefficients();
   double [] coeffs = new double [m_instances.numAttributes()];

   for (int i = 0; i < lmCoeffs.length - 1; i++) {
     if (indices[i] != m_classIndex) {
coeffs[indices[i]] = lmCoeffs[i];
     }
   }
   m_nodeModel = new PreConstructedLinearModel(coeffs, lmCoeffs[lmCoeffs.length - 1]);
   m_nodeModel.buildClassifier(m_instances);
 }
 
开发者ID:dsibournemouth,项目名称:autoweka,代码行数:37,代码来源:RuleNode.java


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