This repository has been archived by the owner on Nov 29, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #241 from h2oai/raji/shapley-rest-scorer
Added shapley values to rest scorer endpoint
- Loading branch information
Showing
17 changed files
with
810 additions
and
76 deletions.
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
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
32 changes: 32 additions & 0 deletions
32
...in/java/ai/h2o/mojos/deploy/common/transform/ContributionRequestToMojoFrameConverter.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,32 @@ | ||
package ai.h2o.mojos.deploy.common.transform; | ||
|
||
import ai.h2o.mojos.deploy.common.rest.model.ContributionRequest; | ||
import ai.h2o.mojos.deploy.common.rest.model.Row; | ||
import ai.h2o.mojos.runtime.frame.MojoFrame; | ||
import ai.h2o.mojos.runtime.frame.MojoFrameBuilder; | ||
import ai.h2o.mojos.runtime.frame.MojoRowBuilder; | ||
import java.util.List; | ||
import java.util.function.BiFunction; | ||
|
||
/** | ||
* Converts the original API request object | ||
* {@link ContributionRequest} into the input {@link MojoFrame}. | ||
*/ | ||
public class ContributionRequestToMojoFrameConverter | ||
implements BiFunction<ContributionRequest, MojoFrameBuilder, MojoFrame> { | ||
@Override | ||
public MojoFrame apply(ContributionRequest scoreRequest, MojoFrameBuilder frameBuilder) { | ||
List<String> fields = scoreRequest.getFields(); | ||
if (scoreRequest.getRows() != null) { | ||
for (Row row : scoreRequest.getRows()) { | ||
MojoRowBuilder rowBuilder = frameBuilder.getMojoRowBuilder(); | ||
for (int i = 0; i < row.size(); i++) { | ||
rowBuilder.setValue(fields.get(i), row.get(i)); | ||
} | ||
frameBuilder.addRow(rowBuilder); | ||
} | ||
} | ||
|
||
return frameBuilder.toMojoFrame(); | ||
} | ||
} |
Oops, something went wrong.