Skip to content

Commit

Permalink
added dMethods to dependency testing
Browse files Browse the repository at this point in the history
  • Loading branch information
ArunGaonkar committed Jun 27, 2022
1 parent 0e89aaf commit 011fc6a
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 9 deletions.
8 changes: 4 additions & 4 deletions Probability.ecl
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion Types.ecl
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
4 changes: 2 additions & 2 deletions internal/ProbSpace.ecl
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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:
Expand Down
4 changes: 2 additions & 2 deletions internal/cModel.ecl
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 011fc6a

Please sign in to comment.