-
Notifications
You must be signed in to change notification settings - Fork 123
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
Running using Databricks Connect #582 #583
Merged
Merged
Changes from all commits
Commits
Show all changes
25 commits
Select commit
Hold shift + click to select a range
e54046d
using dbfs
vikasgupta78 64f7a06
refactor labeller to move common methods to training helper
vikasgupta78 681465e
supporting both normal and data bricks connect client
vikasgupta78 e0371aa
getting spark session thru new method in client
vikasgupta78 3eab8d7
getting spark session thru new method in client
vikasgupta78 99e9ca1
getting spark session thru new method in client
vikasgupta78 fe01f2c
getting spark session and JVM thru new method in client
vikasgupta78 6764867
label updater should overwrite and not append
vikasgupta78 4051246
Running using Databricks Connect
vikasgupta78 7097759
indentation issue
vikasgupta78 f23c1b2
util method to write using pandas df
vikasgupta78 645b03d
Merge pull request #1 from zinggAI/0.3.5
vikasgupta78 48b2134
refactor view and model into separate classes 1st cut
vikasgupta78 36878b7
extra null check removed
vikasgupta78 552d091
constant QUIT_LABELING = 9 defined
vikasgupta78 ea7e8f4
constant INCREMENT = 1 defined
vikasgupta78 47b493a
refactoring
vikasgupta78 18f9c77
lazy initialization
vikasgupta78 40b817a
compile error
vikasgupta78 26f1135
label update methods and refactoring
vikasgupta78 2df6704
validity check added
vikasgupta78 c5abe56
compile issues resolved
vikasgupta78 53ae447
DB Connect check added
vikasgupta78 880b4f6
syntax issues
vikasgupta78 a3ddd46
shell script changes
vikasgupta78 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
28 changes: 28 additions & 0 deletions
28
common/client/src/main/java/zingg/common/client/ILabelDataViewHelper.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
package zingg.common.client; | ||
|
||
import java.util.List; | ||
|
||
public interface ILabelDataViewHelper<S, D, R, C> { | ||
|
||
ZFrame<D, R, C> getClusterIdsFrame(ZFrame<D, R, C> lines); | ||
|
||
List<R> getClusterIds(ZFrame<D, R, C> lines); | ||
|
||
List<C> getDisplayColumns(ZFrame<D, R, C> lines, Arguments args); | ||
|
||
ZFrame<D, R, C> getCurrentPair(ZFrame<D, R, C> lines, int index, List<R> clusterIds, ZFrame<D, R, C> clusterLines); | ||
|
||
double getScore(ZFrame<D, R, C> currentPair); | ||
|
||
double getPrediction(ZFrame<D, R, C> currentPair); | ||
|
||
String getMsg1(int index, int totalPairs); | ||
|
||
String getMsg2(double prediction, double score); | ||
|
||
void displayRecords(ZFrame<D, R, C> records, String preMessage, String postMessage); | ||
|
||
void printMarkedRecordsStat(long positivePairsCount, long negativePairsCount, long notSurePairsCount, | ||
long totalCount); | ||
|
||
} |
26 changes: 26 additions & 0 deletions
26
common/client/src/main/java/zingg/common/client/ITrainingDataModel.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
package zingg.common.client; | ||
|
||
import zingg.common.client.pipe.Pipe; | ||
|
||
public interface ITrainingDataModel<S, D, R, C> { | ||
|
||
public void setMarkedRecordsStat(ZFrame<D, R, C> markedRecords); | ||
|
||
public ZFrame<D, R, C> updateRecords(int matchValue, ZFrame<D, R, C> newRecords, ZFrame<D, R, C> updatedRecords); | ||
|
||
public void updateLabellerStat(int selected_option, int increment); | ||
|
||
public void writeLabelledOutput(ZFrame<D, R, C> records, Arguments args) throws ZinggClientException; | ||
|
||
public void writeLabelledOutput(ZFrame<D,R,C> records, Arguments args, Pipe p) throws ZinggClientException; | ||
|
||
public long getPositivePairsCount(); | ||
|
||
public long getNegativePairsCount(); | ||
|
||
public long getNotSurePairsCount() ; | ||
|
||
public long getTotalCount(); | ||
|
||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
131 changes: 131 additions & 0 deletions
131
common/core/src/main/java/zingg/common/core/executor/LabelDataViewHelper.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,131 @@ | ||
package zingg.common.core.executor; | ||
|
||
import java.util.List; | ||
|
||
import org.apache.commons.logging.Log; | ||
import org.apache.commons.logging.LogFactory; | ||
|
||
import zingg.common.client.Arguments; | ||
import zingg.common.client.ClientOptions; | ||
import zingg.common.client.ILabelDataViewHelper; | ||
import zingg.common.client.ZFrame; | ||
import zingg.common.client.ZinggClientException; | ||
import zingg.common.client.ZinggOptions; | ||
import zingg.common.client.util.ColName; | ||
import zingg.common.client.util.ColValues; | ||
import zingg.common.core.Context; | ||
import zingg.common.core.util.LabelMatchType; | ||
|
||
public class LabelDataViewHelper<S,D,R,C,T> extends ZinggBase<S, D, R, C, T> implements ILabelDataViewHelper<S, D, R, C> { | ||
|
||
private static final long serialVersionUID = 1L; | ||
public static final Log LOG = LogFactory.getLog(LabelDataViewHelper.class); | ||
|
||
public LabelDataViewHelper(Context<S,D,R,C,T> context, ZinggOptions zinggOptions, ClientOptions clientOptions) { | ||
setContext(context); | ||
setZinggOptions(zinggOptions); | ||
setClientOptions(clientOptions); | ||
setName(this.getClass().getName()); | ||
} | ||
|
||
@Override | ||
public ZFrame<D,R,C> getClusterIdsFrame(ZFrame<D,R,C> lines) { | ||
return lines.select(ColName.CLUSTER_COLUMN).distinct(); | ||
} | ||
|
||
|
||
@Override | ||
public List<R> getClusterIds(ZFrame<D,R,C> lines) { | ||
return lines.collectAsList(); | ||
} | ||
|
||
|
||
@Override | ||
public List<C> getDisplayColumns(ZFrame<D,R,C> lines, Arguments args) { | ||
return getDSUtil().getFieldDefColumns(lines, args, false, args.getShowConcise()); | ||
} | ||
|
||
|
||
@Override | ||
public ZFrame<D,R,C> getCurrentPair(ZFrame<D,R,C> lines, int index, List<R> clusterIds, ZFrame<D,R,C> clusterLines) { | ||
return lines.filter(lines.equalTo(ColName.CLUSTER_COLUMN, | ||
clusterLines.getAsString(clusterIds.get(index), ColName.CLUSTER_COLUMN))).cache(); | ||
} | ||
|
||
|
||
@Override | ||
public double getScore(ZFrame<D,R,C> currentPair) { | ||
return currentPair.getAsDouble(currentPair.head(),ColName.SCORE_COL); | ||
} | ||
|
||
|
||
@Override | ||
public double getPrediction(ZFrame<D,R,C> currentPair) { | ||
return currentPair.getAsDouble(currentPair.head(), ColName.PREDICTION_COL); | ||
} | ||
|
||
|
||
@Override | ||
public String getMsg1(int index, int totalPairs) { | ||
return String.format("\tCurrent labelling round : %d/%d pairs labelled\n", index, totalPairs); | ||
} | ||
|
||
|
||
@Override | ||
public String getMsg2(double prediction, double score) { | ||
String msg2 = ""; | ||
String matchType = LabelMatchType.get(prediction).msg; | ||
if (prediction == ColValues.IS_NOT_KNOWN_PREDICTION) { | ||
msg2 = String.format( | ||
"\tZingg does not do any prediction for the above pairs as Zingg is still collecting training data to build the preliminary models."); | ||
} else { | ||
msg2 = String.format("\tZingg predicts the above records %s with a similarity score of %.2f", | ||
matchType, Math.floor(score * 100) * 0.01); | ||
} | ||
return msg2; | ||
} | ||
|
||
|
||
@Override | ||
public void displayRecords(ZFrame<D, R, C> records, String preMessage, String postMessage) { | ||
//System.out.println(); | ||
System.out.println(preMessage); | ||
records.show(false); | ||
System.out.println(postMessage); | ||
System.out.println("\tWhat do you think? Your choices are: "); | ||
System.out.println(); | ||
|
||
System.out.println("\tNo, they do not match : 0"); | ||
System.out.println("\tYes, they match : 1"); | ||
System.out.println("\tNot sure : 2"); | ||
System.out.println(); | ||
System.out.println("\tTo exit : 9"); | ||
System.out.println(); | ||
System.out.print("\tPlease enter your choice [0,1,2 or 9]: "); | ||
} | ||
|
||
@Override | ||
public void printMarkedRecordsStat(long positivePairsCount,long negativePairsCount,long notSurePairsCount,long totalCount) { | ||
String msg = String.format( | ||
"\tLabelled pairs so far : %d/%d MATCH, %d/%d DO NOT MATCH, %d/%d NOT SURE", positivePairsCount, totalCount, | ||
negativePairsCount, totalCount, notSurePairsCount, totalCount); | ||
|
||
System.out.println(); | ||
System.out.println(); | ||
System.out.println(); | ||
System.out.println(msg); | ||
} | ||
|
||
|
||
|
||
@Override | ||
public void execute() throws ZinggClientException { | ||
throw new UnsupportedOperationException(); | ||
} | ||
|
||
@Override | ||
public ILabelDataViewHelper<S, D, R, C> getLabelDataViewHelper() throws UnsupportedOperationException { | ||
return this; | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why do we need to return a zframe here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is done so that writing of labelled output happens in a a separate method. This is needed for python api to work.