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

getUnmarkedRecords() - updated to the version with correct functionality and fixed its name #372

Merged
merged 2 commits into from
Jul 5, 2022
Merged
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
4 changes: 2 additions & 2 deletions client/src/main/java/zingg/client/Client.java
Original file line number Diff line number Diff line change
Expand Up @@ -253,8 +253,8 @@ public Dataset<Row> getMarkedRecords() {
return zingg.getMarkedRecords();
}

public Dataset<Row> getUnMarkedRecords() {
return zingg.getUnMarkedRecords();
public Dataset<Row> getUnmarkedRecords() {
return zingg.getUnmarkedRecords();
}

}
2 changes: 1 addition & 1 deletion client/src/main/java/zingg/client/IZingg.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public void init(Arguments args, String license)

public Dataset<Row> getMarkedRecords();

public Dataset<Row> getUnMarkedRecords();
public Dataset<Row> getUnmarkedRecords();

public Long getMarkedRecordsStat(Dataset<Row> markedRecords, long value);

Expand Down
33 changes: 7 additions & 26 deletions core/src/main/java/zingg/Labeller.java
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ public Labeller() {
public void execute() throws ZinggClientException {
try {
LOG.info("Reading inputs for labelling phase ...");
getMarkedRecordsStat(getMarkedRecords());
Dataset<Row> unmarkedRecords = getUnmarkedRecords();
processRecordsCli(unmarkedRecords);
LOG.info("Finished labelling phase");
Expand All @@ -42,33 +43,13 @@ public void execute() throws ZinggClientException {
}
}

public Dataset<Row> getUnmarkedRecords() throws ZinggClientException {
Dataset<Row> unmarkedRecords = null;
Dataset<Row> markedRecords = null;
try {
unmarkedRecords = PipeUtil.read(spark, false, false, PipeUtil.getTrainingDataUnmarkedPipe(args));
markedRecords = getMarkedRecords();
if (markedRecords != null ) {
unmarkedRecords = unmarkedRecords.join(markedRecords,
unmarkedRecords.col(ColName.CLUSTER_COLUMN).equalTo(markedRecords.col(ColName.CLUSTER_COLUMN)),
"left_anti");
getMarkedRecordsStat(markedRecords);
}
} catch (ZinggClientException e) {
LOG.warn("No unmarked record for labelling");
}
return unmarkedRecords;
}





protected void getMarkedRecordsStat(Dataset<Row> markedRecords) {
positivePairsCount = getMatchedMarkedRecordsStat(markedRecords);
negativePairsCount = getUnmatchedMarkedRecordsStat(markedRecords);
notSurePairsCount = getUnsureMarkedRecordsStat(markedRecords);
totalCount = markedRecords.count() / 2;
if (markedRecords != null ) {
positivePairsCount = getMatchedMarkedRecordsStat(markedRecords);
negativePairsCount = getUnmatchedMarkedRecordsStat(markedRecords);
notSurePairsCount = getUnsureMarkedRecordsStat(markedRecords);
totalCount = markedRecords.count() / 2;
}
}

public void processRecordsCli(Dataset<Row> lines) throws ZinggClientException {
Expand Down
14 changes: 11 additions & 3 deletions core/src/main/java/zingg/ZinggBase.java
Original file line number Diff line number Diff line change
Expand Up @@ -191,13 +191,21 @@ public Dataset<Row> getMarkedRecords() {
return null;
}

public Dataset<Row> getUnMarkedRecords() {
public Dataset<Row> getUnmarkedRecords() {
Dataset<Row> unmarkedRecords = null;
Dataset<Row> markedRecords = null;
try {
return PipeUtil.read(spark, false, false, PipeUtil.getTrainingDataUnmarkedPipe(args));
unmarkedRecords = PipeUtil.read(spark, false, false, PipeUtil.getTrainingDataUnmarkedPipe(args));
markedRecords = getMarkedRecords();
if (markedRecords != null ) {
unmarkedRecords = unmarkedRecords.join(markedRecords,
unmarkedRecords.col(ColName.CLUSTER_COLUMN).equalTo(markedRecords.col(ColName.CLUSTER_COLUMN)),
"left_anti");
}
} catch (ZinggClientException e) {
LOG.warn("No unmarked record");
}
return null;
return unmarkedRecords;
}

public Long getMarkedRecordsStat(Dataset<Row> markedRecords, long value) {
Expand Down
6 changes: 3 additions & 3 deletions python/phases/assessModel.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,17 +19,17 @@ def main():
client.initAndExecute()

pMarkedDF = client.getPandasDfFromDs(client.getMarkedRecords())
pUnMarkedDF = client.getPandasDfFromDs(client.getUnMarkedRecords())
pUnmarkedDF = client.getPandasDfFromDs(client.getUnmarkedRecords())

total_marked = pMarkedDF.shape[0]
total_unmarked = pUnMarkedDF.shape[0]
total_unmarked = pUnmarkedDF.shape[0]
matched_marked = client.getMatchedMarkedRecordsStat()
unmatched_marked = client.getUnmatchedMarkedRecordsStat()
unsure_marked = client.getUnsureMarkedRecordsStat()

LOG.info("")
LOG.info("No. of Records Marked : %d", total_marked)
LOG.info("No. of Records UnMarked : %d", total_unmarked)
LOG.info("No. of Records Unmarked : %d", total_unmarked)
LOG.info("No. of Matches : %d", matched_marked)
LOG.info("No. of Non-Matches : %d", unmatched_marked)
LOG.info("No. of Not Sure : %d", unsure_marked)
Expand Down
4 changes: 2 additions & 2 deletions python/zingg/zingg.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@ def initAndExecute(self):
self.client.execute()
def getMarkedRecords(self):
return self.client.getMarkedRecords()
def getUnMarkedRecords(self):
return self.client.getUnMarkedRecords()
def getUnmarkedRecords(self):
return self.client.getUnmarkedRecords()
def setArguments(self, args):
self.client.setArguments()
def getArguments(self):
Expand Down