static private Map<String, List<PCell>> parseParamMatrix(GeneralRegressionModel generalRegressionModel){ ParamMatrix paramMatrix = generalRegressionModel.getParamMatrix(); ListMultimap<String, PCell> targetCategoryCells = groupByTargetCategory(paramMatrix.getPCells()); return asMap(targetCategoryCells); }
private <V extends Number> Value<V> computeDotProduct(ValueFactory<V> valueFactory, EvaluationContext context){ GeneralRegressionModel generalRegressionModel = getModel(); Map<String, Map<String, Row>> ppMatrixMap = getPPMatrixMap(); Map<String, Row> parameterPredictorRows; if(ppMatrixMap.isEmpty()){ parameterPredictorRows = Collections.emptyMap(); } else { parameterPredictorRows = ppMatrixMap.get(null); if(parameterPredictorRows == null){ PPMatrix ppMatrix = generalRegressionModel.getPPMatrix(); throw new InvalidElementException(ppMatrix); } } Map<String, List<PCell>> paramMatrixMap = getParamMatrixMap(); List<PCell> parameterCells = paramMatrixMap.get(null); if(paramMatrixMap.size() != 1 || parameterCells == null){ ParamMatrix paramMatrix = generalRegressionModel.getParamMatrix(); throw new InvalidElementException(paramMatrix); } return computeDotProduct(valueFactory, parameterCells, parameterPredictorRows, context); }
ParamMatrix paramMatrix = generalRegressionModel.getParamMatrix();
private <V extends Number> Value<V> computeReferencePoint(ValueFactory<V> valueFactory){ GeneralRegressionModel generalRegressionModel = getModel(); BiMap<String, Parameter> parameters = getParameterRegistry(); Map<String, List<PCell>> paramMatrixMap = getParamMatrixMap(); Iterable<PCell> parameterCells = paramMatrixMap.get(null); if(paramMatrixMap.size() != 1 || parameterCells == null){ ParamMatrix paramMatrix = generalRegressionModel.getParamMatrix(); throw new InvalidElementException(paramMatrix); } Value<V> result = null; for(PCell parameterCell : parameterCells){ Parameter parameter = parameters.get(parameterCell.getParameterName()); if(result == null){ result = valueFactory.newValue(); } // End if if(parameter != null){ result.add(parameterCell.getBeta(), parameter.getReferencePoint()); } else { return null; } } return result; }
public GeneralRegressionModelEvaluator(PMML pmml, GeneralRegressionModel generalRegressionModel){ super(pmml, generalRegressionModel); GeneralRegressionModel.ModelType modelType = generalRegressionModel.getModelType(); if(modelType == null){ throw new MissingAttributeException(generalRegressionModel, PMMLAttributes.GENERALREGRESSIONMODEL_MODELTYPE); } ParameterList parameterList = generalRegressionModel.getParameterList(); if(parameterList == null){ throw new MissingElementException(generalRegressionModel, PMMLElements.GENERALREGRESSIONMODEL_PARAMETERLIST); } PPMatrix ppMatrix = generalRegressionModel.getPPMatrix(); if(ppMatrix == null){ throw new MissingElementException(generalRegressionModel, PMMLElements.GENERALREGRESSIONMODEL_PPMATRIX); } ParamMatrix paramMatrix = generalRegressionModel.getParamMatrix(); if(paramMatrix == null){ throw new MissingElementException(generalRegressionModel, PMMLElements.GENERALREGRESSIONMODEL_PARAMMATRIX); } }
ParamMatrix paramMatrix = generalRegressionModel.getParamMatrix(); ParamMatrix paramMatrix = generalRegressionModel.getParamMatrix(); ParamMatrix paramMatrix = generalRegressionModel.getParamMatrix();
@Override public VisitorAction accept(Visitor visitor) { VisitorAction status = visitor.visit(this); if (status == VisitorAction.CONTINUE) { visitor.pushParent(this); if ((status == VisitorAction.CONTINUE)&&hasExtensions()) { status = PMMLObject.traverse(visitor, getExtensions()); } if (status == VisitorAction.CONTINUE) { status = PMMLObject.traverse(visitor, getMiningSchema(), getOutput(), getModelStats(), getModelExplanation(), getTargets(), getLocalTransformations(), getParameterList(), getFactorList(), getCovariateList(), getPPMatrix(), getPCovMatrix(), getParamMatrix(), getEventValues(), getBaseCumHazardTables(), getModelVerification()); } visitor.popParent(); } if (status == VisitorAction.TERMINATE) { return VisitorAction.TERMINATE; } return VisitorAction.CONTINUE; }
@Override public VisitorAction accept(Visitor visitor) { VisitorAction status = visitor.visit(this); if (status == VisitorAction.CONTINUE) { visitor.pushParent(this); if ((status == VisitorAction.CONTINUE)&&hasExtensions()) { status = PMMLObject.traverse(visitor, getExtensions()); } if (status == VisitorAction.CONTINUE) { status = PMMLObject.traverse(visitor, getMiningSchema(), getOutput(), getModelStats(), getModelExplanation(), getTargets(), getLocalTransformations(), getParameterList(), getFactorList(), getCovariateList(), getPPMatrix(), getPCovMatrix(), getParamMatrix(), getEventValues(), getBaseCumHazardTables(), getModelVerification()); } visitor.popParent(); } if (status == VisitorAction.TERMINATE) { return VisitorAction.TERMINATE; } return VisitorAction.CONTINUE; }