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

Java DerivedField类代码示例

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

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



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

示例1: getDerivedFields

import org.dmg.pmml.DerivedField; //导入依赖的package包/类
public static String getDerivedFields(String fieldName, List<DerivedField> allDerivedFields, List<DerivedField>
        derivedFields) {
    // trace back all derived fields until we must arrive at an actual data field. This unfortunately means we have to
    // loop over dervived fields as often as we find one..
    DerivedField lastFoundDerivedField;
    String lastFieldName = fieldName;

    do {
        lastFoundDerivedField = null;
        for (DerivedField derivedField : allDerivedFields) {
            if (derivedField.getName().getValue().equals(lastFieldName)) {
                lastFoundDerivedField = derivedField;
                derivedFields.add(derivedField);
                // now get the next fieldname this field references
                // this is tricky, because this information can be anywhere...
                lastFieldName = getReferencedFieldName(derivedField);
                lastFoundDerivedField = derivedField;
            }
        }
    } while (lastFoundDerivedField != null);
    return lastFieldName;
}
 
开发者ID:brwe,项目名称:es-token-plugin,代码行数:23,代码来源:ProcessPMMLHelper.java


示例2: getFieldValuesList

import org.dmg.pmml.DerivedField; //导入依赖的package包/类
protected static List<VectorRange> getFieldValuesList(TreeModel treeModel, DataDictionary dataDictionary,
                                                      TransformationDictionary transformationDictionary) {
    // walk the tree model and gather all the field name
    Set<String> fieldNames = new HashSet<>();
    Node startNode = treeModel.getNode();
    getFieldNamesFromNode(fieldNames, startNode);
    // create the actual VectorRange objects, copy paste much from GLMHelper
    List<VectorRange> fieldsToValues = new ArrayList<>();
    List<DerivedField> allDerivedFields = ProcessPMMLHelper.getAllDerivedFields(treeModel, transformationDictionary);
    for(String fieldName : fieldNames) {
        List<DerivedField> derivedFields = new ArrayList<>();
        String rawFieldName = ProcessPMMLHelper.getDerivedFields(fieldName, allDerivedFields, derivedFields);
        DataField rawField = ProcessPMMLHelper.getRawDataField(dataDictionary, rawFieldName);
        MiningField miningField = ProcessPMMLHelper.getMiningField(treeModel, rawFieldName);
        fieldsToValues.add(new PMMLVectorRange.FieldToValue(rawField, miningField, derivedFields.toArray(new
                DerivedField[derivedFields.size()])));
    }
    return fieldsToValues;
}
 
开发者ID:brwe,项目名称:es-token-plugin,代码行数:20,代码来源:TreeModelFactory.java


示例3: fillPreProcessingSteps

import org.dmg.pmml.DerivedField; //导入依赖的package包/类
protected void fillPreProcessingSteps(DerivedField[] derivedFields) {

        int derivedFieldIndex = derivedFields.length - 1;
        // don't start at the beginning, we might have a pre processing step there already from the mining field
        for (int preProcessingStepIndex = preProcessingSteps.length - derivedFields.length; preProcessingStepIndex < preProcessingSteps
                .length;
             preProcessingStepIndex++) {
            DerivedField derivedField = derivedFields[derivedFieldIndex];
            if (derivedField.getExpression() != null) {
                handleExpression(preProcessingStepIndex, derivedField);

            } else {
                throw new UnsupportedOperationException("So far only Apply implemented.");
            }
            derivedFieldIndex--;
        }
    }
 
开发者ID:brwe,项目名称:es-token-plugin,代码行数:18,代码来源:PMMLVectorRange.java


示例4: handleExpression

import org.dmg.pmml.DerivedField; //导入依赖的package包/类
private void handleExpression(int preProcessingStepIndex, DerivedField derivedField) {
    if (derivedField.getExpression() instanceof Apply) {
        for (Expression expression : ((Apply) derivedField.getExpression()).getExpressions()) {
            if (expression instanceof Apply) {
                if (((Apply) expression).getFunction().equals("isMissing")) {
                    // now find the value that is supposed to replace the missing value

                    for (Expression expression2 : ((Apply) derivedField.getExpression()).getExpressions()) {
                        if (expression2 instanceof Constant) {
                            String missingValue = ((Constant) expression2).getValue();
                            preProcessingSteps[preProcessingStepIndex] = new MissingValuePreProcess(derivedField, missingValue);
                            break;
                        }
                    }
                } else {
                    throw new UnsupportedOperationException("So far only if isMissing implemented.");
                }
            }
        }
    } else if (derivedField.getExpression() instanceof NormContinuous) {
        preProcessingSteps[preProcessingStepIndex] = new NormContinousPreProcess((NormContinuous) derivedField
                .getExpression(), derivedField.getName().getValue());
    } else {
        throw new UnsupportedOperationException("So far only Apply expression implemented.");
    }
}
 
开发者ID:brwe,项目名称:es-token-plugin,代码行数:27,代码来源:PMMLVectorRange.java


示例5: toContinuousFeature

import org.dmg.pmml.DerivedField; //导入依赖的package包/类
@Override
public ContinuousFeature toContinuousFeature(){
	PMMLEncoder encoder = ensureEncoder();

	List<? extends Feature> features = getFeatures();

	DerivedField derivedField = encoder.getDerivedField(getName());
	if(derivedField == null){
		Apply apply = PMMLUtil.createApply("*", ((features.get(0)).toContinuousFeature()).ref(), ((features.get(1)).toContinuousFeature()).ref());

		for(int i = 2; i < features.size(); i++){
			apply = PMMLUtil.createApply("*", apply, ((features.get(i)).toContinuousFeature()).ref());
		}

		derivedField = encoder.createDerivedField(getName(), OpType.CONTINUOUS, DataType.DOUBLE, apply);
	}

	return new ContinuousFeature(encoder, derivedField);
}
 
开发者ID:jpmml,项目名称:jpmml-converter,代码行数:20,代码来源:InteractionFeature.java


示例6: createRegressionNeuralOutputs

import org.dmg.pmml.DerivedField; //导入依赖的package包/类
static
public NeuralOutputs createRegressionNeuralOutputs(List<? extends Entity> entities, ContinuousLabel continuousLabel){

	if(entities.size() != 1){
		throw new IllegalArgumentException();
	}

	Entity entity = Iterables.getOnlyElement(entities);

	DerivedField derivedField = new DerivedField(OpType.CONTINUOUS, continuousLabel.getDataType())
		.setExpression(new FieldRef(continuousLabel.getName()));

	NeuralOutput neuralOutput = new NeuralOutput()
		.setOutputNeuron(entity.getId())
		.setDerivedField(derivedField);

	NeuralOutputs neuralOutputs = new NeuralOutputs()
		.addNeuralOutputs(neuralOutput);

	return neuralOutputs;
}
 
开发者ID:jpmml,项目名称:jpmml-converter,代码行数:22,代码来源:NeuralNetworkUtil.java


示例7: createClassificationNeuralOutputs

import org.dmg.pmml.DerivedField; //导入依赖的package包/类
static
public NeuralOutputs createClassificationNeuralOutputs(List<? extends Entity> entities, CategoricalLabel categoricalLabel){

	if(entities.size() != categoricalLabel.size()){
		throw new IllegalArgumentException();
	}

	NeuralOutputs neuralOutputs = new NeuralOutputs();

	for(int i = 0; i < categoricalLabel.size(); i++){
		Entity entity = entities.get(i);

		DerivedField derivedField = new DerivedField(OpType.CATEGORICAL, categoricalLabel.getDataType())
			.setExpression(new NormDiscrete(categoricalLabel.getName(), categoricalLabel.getValue(i)));

		NeuralOutput neuralOutput = new NeuralOutput()
			.setOutputNeuron(entity.getId())
			.setDerivedField(derivedField);

		neuralOutputs.addNeuralOutputs(neuralOutput);
	}

	return neuralOutputs;
}
 
开发者ID:jpmml,项目名称:jpmml-converter,代码行数:25,代码来源:NeuralNetworkUtil.java


示例8: toContinuousFeature

import org.dmg.pmml.DerivedField; //导入依赖的package包/类
public ContinuousFeature toContinuousFeature(DataType dataType){
	ContinuousFeature continuousFeature = toContinuousFeature();

	if((dataType).equals(continuousFeature.getDataType())){
		return continuousFeature;
	}

	PMMLEncoder encoder = ensureEncoder();

	FieldName name = FieldName.create((dataType.name()).toLowerCase() + "(" + (continuousFeature.getName()).getValue() + ")");

	DerivedField derivedField = encoder.getDerivedField(name);
	if(derivedField == null){
		derivedField = encoder.createDerivedField(name, OpType.CONTINUOUS, dataType, continuousFeature.ref());
	}

	return new ContinuousFeature(encoder, derivedField);
}
 
开发者ID:jpmml,项目名称:jpmml-converter,代码行数:19,代码来源:Feature.java


示例9: filter

import org.dmg.pmml.DerivedField; //导入依赖的package包/类
private Schema filter(Schema schema){
	Function<Feature, Feature> function = new Function<Feature, Feature>(){

		@Override
		public Feature apply(Feature feature){
			Expression expression = encodeExpression(feature);

			if(expression == null){
				return feature;
			}

			DerivedField derivedField = createDerivedField(FeatureUtil.createName("preProcess", feature), OpType.CONTINUOUS, DataType.DOUBLE, expression);

			return new ContinuousFeature(PreProcessEncoder.this, derivedField);
		}
	};

	return schema.toTransformedSchema(function);
}
 
开发者ID:jpmml,项目名称:jpmml-r,代码行数:20,代码来源:PreProcessEncoder.java


示例10: prepareInputField

import org.dmg.pmml.DerivedField; //导入依赖的package包/类
static
private FieldName prepareInputField(FunctionExpression.Argument argument, OpType opType, DataType dataType, RExpEncoder encoder){
	Expression expression = argument.getExpression();

	if(expression instanceof FieldRef){
		FieldRef fieldRef = (FieldRef)expression;

		return fieldRef.getField();
	} else

	if(expression instanceof Apply){
		Apply apply = (Apply)expression;

		DerivedField derivedField = encoder.createDerivedField(FieldName.create((argument.formatExpression()).trim()), opType, dataType, apply);

		return derivedField.getName();
	} else

	{
		throw new IllegalArgumentException();
	}
}
 
开发者ID:jpmml,项目名称:jpmml-r,代码行数:23,代码来源:FormulaUtil.java


示例11: resolveField

import org.dmg.pmml.DerivedField; //导入依赖的package包/类
static
private Field resolveField(FieldName name, MiningModelEvaluationContext context){

	while(context != null){
		OutputField outputField = context.getOutputField(name);
		if(outputField != null){
			return outputField;
		}

		DerivedField localDerivedField = context.getLocalDerivedField(name);
		if(localDerivedField != null){
			return localDerivedField;
		}

		context = context.getParent();
	}

	return null;
}
 
开发者ID:jpmml,项目名称:jpmml-evaluator,代码行数:20,代码来源:ModelEvaluationContext.java


示例12: encodeFeatures

import org.dmg.pmml.DerivedField; //导入依赖的package包/类
@Override
public List<Feature> encodeFeatures(SparkMLEncoder encoder){
	PCAModel transformer = getTransformer();

	List<Feature> features = encoder.getFeatures(transformer.getInputCol());

	DenseMatrix pc = transformer.pc();
	if(pc.numRows() != features.size()){
		throw new IllegalArgumentException();
	}

	List<Feature> result = new ArrayList<>();

	for(int i = 0; i < transformer.getK(); i++){
		Apply apply = new Apply("sum");

		for(int j = 0; j < features.size(); j++){
			Feature feature = features.get(j);

			ContinuousFeature continuousFeature = feature.toContinuousFeature();

			Expression expression = continuousFeature.ref();

			Double coefficient = pc.apply(j, i);
			if(!ValueUtil.isOne(coefficient)){
				expression = PMMLUtil.createApply("*", expression, PMMLUtil.createConstant(coefficient));
			}

			apply.addExpressions(expression);
		}

		DerivedField derivedField = encoder.createDerivedField(formatName(transformer, i), OpType.CONTINUOUS, DataType.DOUBLE, apply);

		result.add(new ContinuousFeature(encoder, derivedField));
	}

	return result;
}
 
开发者ID:jpmml,项目名称:jpmml-sparkml,代码行数:39,代码来源:PCAModelConverter.java


示例13: toContinuousFeature

import org.dmg.pmml.DerivedField; //导入依赖的package包/类
@Override
public ContinuousFeature toContinuousFeature(){
	PMMLEncoder encoder = ensureEncoder();

	DerivedField derivedField = encoder.getDerivedField(getName());
	if(derivedField == null){
		Apply apply = createApply();

		derivedField = encoder.createDerivedField(getName(), OpType.CONTINUOUS, getDataType(), apply);
	}

	return new ContinuousFeature(encoder, derivedField);
}
 
开发者ID:jpmml,项目名称:jpmml-sparkml,代码行数:14,代码来源:TermFeature.java


示例14: getReferencedFieldName

import org.dmg.pmml.DerivedField; //导入依赖的package包/类
private static String getReferencedFieldName(DerivedField derivedField) {
    String referencedField = null;
    if (derivedField.getExpression() != null) {
        if (derivedField.getExpression() instanceof Apply) {
            // TODO throw uoe in case the function is not "if missing" - much more to implement!
            for (Expression expression : ((Apply) derivedField.getExpression()).getExpressions()) {
                if (expression instanceof FieldRef) {
                    referencedField = ((FieldRef) expression).getField().getValue();
                }
            }
        } else if (derivedField.getExpression() instanceof NormContinuous) {
            referencedField = ((NormContinuous) derivedField.getExpression()).getField().getValue();
        } else {
            throw new UnsupportedOperationException("So far only Apply expression implemented.");
        }
    } else {
        // there is a million ways in which derived fields can reference other fields.
        // need to implement them all!
        throw new UnsupportedOperationException("So far only implemented if function for derived fields.");
    }

    if (referencedField == null) {
        throw new UnsupportedOperationException("could not find raw field name. Maybe this derived field references another derived " +
                "field? Did not implement that yet.");
    }
    return referencedField;
}
 
开发者ID:brwe,项目名称:es-token-plugin,代码行数:28,代码来源:ProcessPMMLHelper.java


示例15: getAllDerivedFields

import org.dmg.pmml.DerivedField; //导入依赖的package包/类
public static List<DerivedField> getAllDerivedFields(Model model, TransformationDictionary transformationDictionary) {
    List<DerivedField> allDerivedFields = new ArrayList<>();
    if (transformationDictionary != null) {
        allDerivedFields.addAll(transformationDictionary.getDerivedFields());
    }
    if (model.getLocalTransformations() != null) {
        allDerivedFields.addAll(model.getLocalTransformations().getDerivedFields());
    }
    return allDerivedFields;
}
 
开发者ID:brwe,项目名称:es-token-plugin,代码行数:11,代码来源:ProcessPMMLHelper.java


示例16: extractVectorRange

import org.dmg.pmml.DerivedField; //导入依赖的package包/类
public static PMMLVectorRange extractVectorRange(Model model, DataDictionary dataDictionary,
                                           TransformationDictionary transformationDictionary,
                                           String fieldName, Provider<Collection<String>> categories,
                                           int position, Map<String, OpType> types) {
    List<DerivedField> allDerivedFields = ProcessPMMLHelper.getAllDerivedFields(model, transformationDictionary);
    List<DerivedField> derivedFields = new ArrayList<>();
    String rawFieldName = ProcessPMMLHelper.getDerivedFields(fieldName, allDerivedFields, derivedFields);
    DataField rawField = ProcessPMMLHelper.getRawDataField(dataDictionary, rawFieldName);
    MiningField miningField = ProcessPMMLHelper.getMiningField(model, rawFieldName);
    PMMLVectorRange featureEntries = getFieldVector(position, derivedFields, rawField, miningField, categories, types);
    return featureEntries;
}
 
开发者ID:brwe,项目名称:es-token-plugin,代码行数:13,代码来源:ProcessPMMLHelper.java


示例17: getFieldVector

import org.dmg.pmml.DerivedField; //导入依赖的package包/类
public static PMMLVectorRange getFieldVector(int indexCounter, List<DerivedField> derivedFields,
                                       DataField rawField, MiningField miningField,
                                       Provider<Collection<String>> categories,
                                       Map<String, OpType> types) {
    PMMLVectorRange featureEntries;
    OpType opType;
    if (derivedFields.size() == 0) {
        opType = rawField.getOpType();
    } else {
        opType = derivedFields.get(0).getOpType();
    }

    if (opType.equals(OpType.CONTINUOUS)) {
        featureEntries = new PMMLVectorRange.ContinousSingleEntryVectorRange(rawField, miningField,
                derivedFields.toArray(new DerivedField[derivedFields.size()]));
        featureEntries.addVectorEntry(indexCounter, "dummyValue");
    } else if (opType.equals(OpType.CATEGORICAL)) {
        featureEntries = new PMMLVectorRange.SparseCategoricalVectorRange(rawField, miningField,
                derivedFields.toArray(new DerivedField[derivedFields.size()]));
        for (String value : categories.get()) {
            featureEntries.addVectorEntry(indexCounter, value);
            indexCounter++;
        }
    } else {
        throw new UnsupportedOperationException("Only implemented continuous and categorical variables so far.");
    }
    if(types != null) {
        types.put(featureEntries.getLastDerivedFieldName(), opType);
    }
    return featureEntries;
}
 
开发者ID:brwe,项目名称:es-token-plugin,代码行数:32,代码来源:ProcessPMMLHelper.java


示例18: PMMLVectorRange

import org.dmg.pmml.DerivedField; //导入依赖的package包/类
public PMMLVectorRange(DataField dataField, MiningField miningField, DerivedField[] derivedFields) {
    super(dataField.getName().getValue(),
            derivedFields.length == 0 ? dataField.getName().getValue() : derivedFields[derivedFields.length - 1].getName().getValue(),
            derivedFields.length == 0 ? dataField.getDataType().value() : derivedFields[derivedFields.length - 1].getDataType().value
                    ());
    this.field = dataField.getName().getValue();
    if (miningField.getMissingValueReplacement() != null) {
        preProcessingSteps = new PreProcessingStep[derivedFields.length + 1];
        preProcessingSteps[0] = new MissingValuePreProcess(dataField, miningField.getMissingValueReplacement());
    } else {
        preProcessingSteps = new PreProcessingStep[derivedFields.length];
    }
    fillPreProcessingSteps(derivedFields);
}
 
开发者ID:brwe,项目名称:es-token-plugin,代码行数:15,代码来源:PMMLVectorRange.java


示例19: toContinuousFeature

import org.dmg.pmml.DerivedField; //导入依赖的package包/类
@Override
public ContinuousFeature toContinuousFeature(){
	PMMLEncoder encoder = ensureEncoder();

	FieldName derivedName = getDerivedName();

	DerivedField derivedField = encoder.getDerivedField(derivedName);
	if(derivedField == null){
		Apply apply = PMMLUtil.createApply("pow", new FieldRef(getName()), PMMLUtil.createConstant(getPower()));

		derivedField = encoder.createDerivedField(derivedName, OpType.CONTINUOUS, DataType.DOUBLE, apply);
	}

	return new ContinuousFeature(encoder, derivedField);
}
 
开发者ID:jpmml,项目名称:jpmml-converter,代码行数:16,代码来源:PowerFeature.java


示例20: toContinuousFeature

import org.dmg.pmml.DerivedField; //导入依赖的package包/类
@Override
public ContinuousFeature toContinuousFeature(){
	PMMLEncoder encoder = ensureEncoder();

	FieldName derivedName = getDerivedName();

	DerivedField derivedField = encoder.getDerivedField(derivedName);
	if(derivedField == null){
		NormDiscrete normDiscrete = new NormDiscrete(getName(), getValue());

		derivedField = encoder.createDerivedField(derivedName, OpType.CONTINUOUS, DataType.DOUBLE, normDiscrete);
	}

	return new ContinuousFeature(encoder, derivedField);
}
 
开发者ID:jpmml,项目名称:jpmml-converter,代码行数:16,代码来源:BinaryFeature.java



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
Java SimpleTcpServer类代码示例发布时间:2022-05-22
下一篇:
Java PopulatorFlower类代码示例发布时间: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