Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

added dMethods to dependency testing #4

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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