From 011fc6a8a43b4699a191156eb858f6eebabe66f8 Mon Sep 17 00:00:00 2001 From: Arun Gaonkar Date: Thu, 23 Jun 2022 14:52:59 -0400 Subject: [PATCH] added dMethods to dependency testing --- Probability.ecl | 8 ++++---- Types.ecl | 2 +- internal/ProbSpace.ecl | 4 ++-- internal/cModel.ecl | 4 ++-- 4 files changed, 9 insertions(+), 9 deletions(-) diff --git a/Probability.ecl b/Probability.ecl index b46bc8b..52f09f1 100644 --- a/Probability.ecl +++ b/Probability.ecl @@ -106,9 +106,9 @@ EXPORT Probability(DATASET(NumericField) ds, SET OF STRING varNames) := MODULE * Values less than .5 indicate probable independence. * Values greater than .5 indicate probable dependence */ - EXPORT DATASET(NumericField) Dependence(DATASET(ProbQuery) queries) := FUNCTION + EXPORT DATASET(NumericField) Dependence(DATASET(ProbQuery) queries, STRING dMethod='prob') := FUNCTION queries_D := DISTRIBUTE(queries, id); - deps := ProbSpace.Dependence(queries_D, PS); + deps := ProbSpace.Dependence(queries_D, dMethod, PS); deps_S := SORT(deps, id); RETURN deps_S; END; @@ -125,9 +125,9 @@ EXPORT Probability(DATASET(NumericField) ds, SET OF STRING varNames) := MODULE * targets are most likely independent. 0 indicates probable dependence. * */ - EXPORT DATASET(NumericField) isIndependent(DATASET(ProbQuery) queries) := FUNCTION + EXPORT DATASET(NumericField) isIndependent(DATASET(ProbQuery) queries, STRING dMethod='prob') := FUNCTION queries_D := DISTRIBUTE(queries, id); - deps := ProbSpace.Dependence(queries_D, PS); + deps := ProbSpace.Dependence(queries_D, dMethod, PS); deps_B := PROJECT(deps, TRANSFORM(RECORDOF(LEFT), SELF.value := IF(LEFT.value > .5, 0, 1), SELF := LEFT), LOCAL); diff --git a/Types.ecl b/Types.ecl index bc03527..1617350 100644 --- a/Types.ecl +++ b/Types.ecl @@ -136,7 +136,7 @@ EXPORT Types := MODULE */ EXPORT RV := RECORD STRING Name; - SET OF STRING Parents; + SET OF STRING Parents := []; BOOLEAN isObserved := TRUE; DatTypeEnum DataType := DatTypeEnum.None; END; diff --git a/internal/ProbSpace.ecl b/internal/ProbSpace.ecl index 9713dbd..1e809c1 100644 --- a/internal/ProbSpace.ecl +++ b/internal/ProbSpace.ecl @@ -223,7 +223,7 @@ EXPORT ProbSpace := MODULE * */ - EXPORT STREAMED DATASET(NumericField) Dependence(STREAMED DATASET(ProbQuery) queries, UNSIGNED ps) := + EXPORT STREAMED DATASET(NumericField) Dependence(STREAMED DATASET(ProbQuery) queries, STRING dmethod, UNSIGNED ps) := EMBED(Python: globalscope(globalScope), persist('query'), activity) assert 'PS' in globals(), 'ProbSpace.Dependence: PS is not initialized.' try: @@ -247,7 +247,7 @@ EXPORT ProbSpace := MODULE else: condition = cVar conditions.append(condition) - result = PS.dependence(v1, v2, conditions) + result = PS.dependence(v1, v2, conditions, dMethod=dmethod) results.append((1, id, 1, result)) return results except: diff --git a/internal/cModel.ecl b/internal/cModel.ecl index 60ba13f..a77c19a 100644 --- a/internal/cModel.ecl +++ b/internal/cModel.ecl @@ -76,11 +76,11 @@ EXPORT cModel := MODULE pyrv = pyrvs[i] rvName = pyrv[0] rvParents = pyrv[1] - rvIsDiscrete = pyrv[2] + rvIsObserved = pyrv[2] rvType = pyrv[3] DS[rvName] = [] varMap[i+1] = rvName - newrv = rv.RV(rvName, rvParents, rvIsDiscrete, rvType) + newrv = rv.RV(rvName, rvParents, rvIsObserved, rvType) RVs.append(newrv) ids = [] lastId = None