Ejemplo n.º 1
0
  @Override
  protected AnalyzerOutPutDataBaseUpdate doPredict(
      DataBaseAnalyticSource source, PredictorConfig config) throws AnalysisException {
    DataSet dataSet = null;
    try {
      dataSet = getDataSet(source, source.getAnalyticConfig());
      config.getTrainedModel().getModel().apply(dataSet);
    } catch (Exception e) {
      logger.error(e);
      if (e instanceof WrongUsedException) {
        throw new AnalysisError(this, (WrongUsedException) e);
      } else if (e instanceof AnalysisError) {
        throw (AnalysisError) e;
      } else {
        throw new AnalysisException(e);
      }
    }
    AnalyzerOutPutDataBaseUpdate result = new AnalyzerOutPutDataBaseUpdate();

    result.setDataset(dataSet);

    //		 set url user pwd ,schema, table
    fillDBInfo(result, (DataBaseAnalyticSource) source);

    Model model = config.getTrainedModel().getModel();
    result.setUpdatedColumns(((NBModel) model).getUpdateColumns());
    // good, bad ,

    result.setAnalyticNodeMetaInfo(createNodeMetaInfo(config.getLocale()));
    return result;
  }
Ejemplo n.º 2
0
  @Override
  protected AnalyzerOutPutObject doValidate(DataBaseAnalyticSource source, EvaluatorConfig config)
      throws AnalysisException {

    DoubleListData result = null;
    List<DoubleListData> resultList = new ArrayList<DoubleListData>();

    try {
      DataSet dataSet = getDataSet(source, source.getAnalyticConfig());
      //			dataSet.recalculateAllcolumnStatistics();
      Operator operator = OperatorUtil.createOperator(LiftDataGeneratorGeneral.class);
      EvaluatorParameter parameter = new EvaluatorParameter();
      if (config.getUseModel() != null) {
        //				operator.setParameter(LiftDataGeneratorGeneral.PARAMETER_USE_MODEL,
        // config.getUseModel());
        parameter.setUseModel(Boolean.parseBoolean(config.getUseModel()));
      }
      if (config.getColumnValue() != null) {
        //				operator.setParameter(LiftDataGeneratorGeneral.PARAMETER_TARGET_CLASS,
        // config.getColumnValue());
        parameter.setColumnValue(config.getColumnValue());
      }
      operator.setParameter(parameter);
      if (config.getUseModel().equals("true")) {
        List<EngineModel> models = config.getTrainedModel();
        Model model = null;
        for (int i = 0; i < models.size(); i++) {
          Container container = new Container();
          model = models.get(i).getModel();
          container = container.append(dataSet);
          container = container.append(model);
          Container resultContainer = operator.apply(container);
          result = resultContainer.get(DoubleListData.class);
          result.setSourceName(models.get(i).getName());
          resultList.add(result);
        }
      } else {
        Container container = new Container();
        String targetClass = config.getColumnValue();
        Column confidence =
            dataSet.getColumns().get(Column.CONFIDENCE_NAME + "(" + targetClass + ")");
        dataSet
            .getColumns()
            .setSpecialColumn(confidence, Column.CONFIDENCE_NAME + "_" + targetClass);
        container = container.append(dataSet);
        Container resultContainer = operator.apply(container);
        result = resultContainer.get(DoubleListData.class);
        result.setSourceName(getName());
        resultList.add(result);
      }

    } catch (Exception e) {
      logger.error(e);
      if (e instanceof WrongUsedException) {
        throw new AnalysisError(this, (WrongUsedException) e);
      } else if (e instanceof AnalysisError) {
        throw (AnalysisError) e;
      } else {
        throw new AnalysisException(e);
      }
    }
    AnalyzerOutPutObject out = new AnalyzerOutPutObject(resultList);
    out.setAnalyticNodeMetaInfo(createNodeMetaInfo(config.getLocale()));
    return out;
  }