⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 lookupservice.java

📁 为了下东西 随便发了个 datamining 的源代码
💻 JAVA
📖 第 1 页 / 共 4 页
字号:
          {
            String value = sap[i].getValue();
            sett.setCoef0( Double.parseDouble(value) );
          }
          else
          if (name.equals("svmType"))
          {
            String value = sap[i].getValue();
            sett.setSvmType( Integer.parseInt(value) );
          }
          else
          if (name.equals("kernelType"))
          {
            String value = sap[i].getValue();
            sett.setKernelType( Integer.parseInt(value) );
          }
          else
          if (name.equals("lossEpsilon"))
          {
            String value = sap[i].getValue();
            sett.setLossEpsilon( Double.parseDouble(value) );
          }
          else
          if (name.equals("nu"))
          {
            String value = sap[i].getValue();
            sett.setNu( Double.parseDouble(value) );
          }
        }
      }
      if (settings instanceof NeuralNetworkSettings) {
        NeuralNetworkSettings sett = (NeuralNetworkSettings)
            settings;
        for (int i = 0; i < sap.length; i++) {
          String name = sap[i].getName();
          if (name.equals("learningType"))
          {
            String value = sap[i].getValue();
            sett.setLearningType( Integer.parseInt(value) );
          }
          else
          if (name.equals("autoBuildNetwork"))
          {
            String value = sap[i].getValue();
            boolean bval = false;
            if (value.equals("true")) bval = true;
            sett.setAutoBuildNetwork( bval );
          }
          else
          if (name.equals("learningRate"))
          {
            String value = sap[i].getValue();
            sett.setLearningRate( Double.parseDouble(value) );
          }
          else
          if (name.equals("momentum"))
          {
            String value = sap[i].getValue();
            sett.setMomentum( Double.parseDouble(value) );
          }
          else
          if (name.equals("maxNumberOfIterations"))
          {
            String value = sap[i].getValue();
            sett.setMaxNumberOfIterations( Integer.parseInt(value) );
          }
          else
          if (name.equals("maxError"))
          {
            String value = sap[i].getValue();
            sett.setMaxError ( Double.parseDouble(value) );
          }
        }
      }
      if (settings instanceof TimeSeriesMiningSettings) {
          TimeSeriesMiningSettings sett = (TimeSeriesMiningSettings)
              settings;
          for (int i = 0; i < sap.length; i++) {
            String name = sap[i].getName();
            if (name.equals("embeddingDimension"))
            {
              String value = sap[i].getValue();
              sett.setEmbeddingDimension( Integer.parseInt(value) );
            }
            else
            if (name.equals("stepSize"))
            {
              String value = sap[i].getValue();
              sett.setStepSize( Integer.parseInt(value) );
            }
            else
            if (name.equals("singleApproximator"))
            {
              String value = sap[i].getValue();
              boolean bval = false;
              if (value.equals("true")) bval = true;
              sett.setSingleApproximator( bval );
            }
          };
      }
      if (settings instanceof StatisticsSettings) {
        StatisticsSettings sett = (StatisticsSettings)
            settings;
        for (int i = 0; i < sap.length; i++) {
          String name = sap[i].getName();
          if (name.equals("grouping"))
          {
            @SuppressWarnings("unused") String value = sap[i].getValue();
            sett.setGrouping( new java.util.Vector() );
          }
          else
          if (name.equals("UnivariateTargetName"))
          {
            String value = sap[i].getValue();
            sett.setUnivariateTarget( metaData.getMiningAttribute(value) );
          }
          else
          if (name.equals("multivariateTarget1Name"))
          {
            String value = sap[i].getValue();
            sett.setMultivariateTarget1( metaData.getMiningAttribute(value) );
          }
          else
          if (name.equals("multivariateTarget2Name"))
          {
            String value = sap[i].getValue();
            sett.setMultivariateTarget2( metaData.getMiningAttribute(value) );
          }
        };
      }
      if (settings instanceof ClusteringSettings) {
        ClusteringSettings sett = (ClusteringSettings)
            settings;
        for (int i = 0; i < sap.length; i++) {
          String name = sap[i].getName();
          if (name.equals("clusterIdAttributeName"))
          {
            String value = sap[i].getValue();
            sett.setClusterIdAttributeName( value );
          }
          else
          if (name.equals("maxNumberOfClusters"))
          {
            String value = sap[i].getValue();
            sett.setMaxNumberOfClusters( Integer.parseInt(value) );
          }
          else
          if (name.equals("distance"))
          {
            @SuppressWarnings("unused") String value = sap[i].getValue();

            /*-----------------------------------------------------------------*/
            // Get distance object:
            com.prudsys.pdm.Models.Clustering.Distance distance =
              new com.prudsys.pdm.Models.Clustering.Distance();
            if (settings instanceof HierarchicalClusteringSettings)
              distance = new com.prudsys.pdm.Models.Clustering.Hierarchical.ClusterDistance();

            for (int j = 0; j < sap.length; j++) {
              String dname = sap[j].getName();

              if (dname.equals("type"))
              {
                String val = sap[j].getValue();
                distance.setType( Integer.parseInt(val) );
              }
              else
              if (dname.equals("measureType"))
              {
                String val = sap[j].getValue();
                distance.setMeasureType( Integer.parseInt(val) );
              }
              else
              if (dname.equals("compareFunction"))
              {
                String val = sap[j].getValue();
                distance.setCompareFunction( Integer.parseInt(val) );
              }
              else
              if (dname.equals("normalized"))
              {
                String val = sap[j].getValue();
                boolean bval = false;
                if (val.equals("true")) bval = true;
                distance.setNormalized(bval);
              }
              else
              if (dname.equals("simMeasNormConst"))
              {
                String val = sap[j].getValue();
                distance.setSimMeasNormConst( Double.parseDouble(val) );
              }
              else
              if (dname.equals("minkPar"))
              {
                String val = sap[j].getValue();
                distance.setMinkPar( Double.parseDouble(val) );
              }
              else
              if (dname.equals("minCompareFunction"))
              {
                String val = sap[j].getValue();
                distance.setMinCompareFunction( Double.parseDouble(val) );
              }
              else
              if (dname.equals("maxCompareFunction"))
              {
                String val = sap[j].getValue();
                distance.setMaxCompareFunction( Double.parseDouble(val) );
              }
              else
              if (dname.equals("clustDistType"))
              {
                String val = sap[j].getValue();
                ((com.prudsys.pdm.Models.Clustering.Hierarchical.ClusterDistance)
                 distance).setClustDistType( Integer.parseInt(val) );
              }
            }
            /*-----------------------------------------------------------------*/

            sett.setDistance(distance);
          }
        }
      }
      if (settings instanceof CDBasedClusteringSettings) {
          @SuppressWarnings("unused") CDBasedClusteringSettings sett = (CDBasedClusteringSettings)
              settings;
          for (int i = 0; i < sap.length; i++) {
            @SuppressWarnings("unused") String name = sap[i].getName();
          };
      }
      if (settings instanceof HierarchicalClusteringSettings) {
          @SuppressWarnings("unused") HierarchicalClusteringSettings sett = (HierarchicalClusteringSettings)
              settings;
          for (int i = 0; i < sap.length; i++) {
            @SuppressWarnings("unused") String name = sap[i].getName();
          };
      }
      if (settings instanceof PartitioningClusteringSettings) {
        PartitioningClusteringSettings sett = (PartitioningClusteringSettings)
            settings;
        for (int i = 0; i < sap.length; i++) {
          String name = sap[i].getName();
          if (name.equals("linkage"))
          {
            String value = sap[i].getValue();
            sett.setLinkage( Integer.parseInt(value) );
          }
          else
          if (name.equals("threshold"))
          {
            String value = sap[i].getValue();
            sett.setThreshold( Double.parseDouble(value) );
          }
        }
      }

//    throw new MiningException("unknown class of mining settings");
    }
    catch (Exception ex) {
      throw new MiningException("can't build mining settings: " + ex);
    };
  }

  /**
   * Search algorithm parameter with given name and set its value.
   *
   * @param sap array of service algorithm parameters
   * @param name name of algorithm parameter to set
   * @param value new value of algorithm parameter
   * @return true if name found and value set, otherwise false
   */
  public static boolean setSAPValue(ServiceAlgorithmParameter[] sap, String name, String value) {

    int nSap = 0;
    if (sap != null) nSap = sap.length;
    for (int i = 0; i < nSap; i++)
      if ( sap[i].getName().equals( name ) ) {
        sap[i].setValue(value);
        return true;
      };

    return false;
  }

  /**
   * Read model type from PMML document and returns the corresponding
   * model class. Then the readPmml method of this class reads
   * the model.
   *
   * We suppose that there is only one (root) model in the PMML document.
   *
   * @param reader reader for PMML access
   * @return mining model of corresponding type
   * @throws MiningException if can't read model from the pmml source
   */
  public static MiningModel readPmmlModelFactory( Reader reader )
      throws MiningException {

    MiningModel model = null;

//    com.borland.xml.toolkit.XmlUtil.setEncoding( "UTF-8" );
    com.prudsys.pdm.Adapters.PmmlVersion20.PMML pmml =
        com.prudsys.pdm.Adapters.PmmlVersion20.PMML.unmarshal( reader );

      if (pmml.getAssociationModelCount() > 0) {
        model = new com.prudsys.pdm.Models.AssociationRules.AssociationRulesMiningModel();
      }
      else if (pmml.getSequenceModelCount() > 0) {
        model = new com.prudsys.pdm.Models.Sequential.SequentialMiningModel();
        com.prudsys.pdm.Adapters.PmmlVersion20.SequenceModel smodel = pmml.getSequenceModel(0);
        if (smodel.getAlgorithmName().equals( MiningModel.SEQUENTIAL_BASKET_ANALYSIS_ALGORITHM ))
          model = new com.prudsys.pdm.Models.CustomerSeq.CustomerSequentialMiningModel();
      }
      else if (pmml.getTreeModelCount() > 0) {
        model = new com.prudsys.pdm.Models.Classification.DecisionTree.DecisionTreeMiningModel();
      }
      else if (pmml.getSupportVectorMachineModelCount() > 0) {
        model = new com.prudsys.pdm.Models.Regression.SVM.SupportVectorMiningModel();
      }
      else if (pmml.getSparseGridModelCount() > 0) {
        model = new com.prudsys.pdm.Models.Regression.SparseGrids.SparseGridsMiningModel();
      }
      else if (pmml.getClusteringModelCount() > 0) {
        model = new com.prudsys.pdm.Models.Clustering.CDBased.CDBasedClusteringMiningModel();
      }
      else
        throw new MiningException( "No mining model supported by XELOPES found. ");

    return model;
  }

  /**
   * Read mining model from PMML document.
   *
   * We suppose that there is only one (root) model in the PMML document.
   *
   * @param reader reader for PMML access
   * @return mining model of read from PMML document
   * @throws MiningException if can't read model from the pmml source,
   * mainly because reset method not supported by reader
   */
  public static MiningModel readPmmlModel( Reader reader )
      throws MiningException {

    MiningModel model = null;
    try {
      model = readPmmlModelFactory(reader);
      reader.reset();
      model.readPmml(reader);
    }
    catch (Exception ex) {
      throw new MiningException("reset method not supported by reader");
    }

    return model;
  }

}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -