-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
49 additions
and
9 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,47 @@ | ||
# PaseStub | ||
Java client stub for a PASE server. | ||
|
||
Java client stub for a [PASE](https://github.com/aminfa/Pase) server. | ||
|
||
## Code Example | ||
|
||
Take a look at the code example section of the [PASE repository](https://github.com/aminfa/Pase). | ||
The same operations can execute using a `PaseInstance`: | ||
|
||
```java | ||
PaseInstance instance = new PaseInstance("localhost:5000"); // specify host | ||
|
||
Map<String, Object> parameters = new HashMap<String, Object>(); | ||
parameters.put("normalize", true); | ||
instance.create("sklearn.linear_model.LinearRegression", parameters); | ||
|
||
parameters.clear(); | ||
double[][] X = {{0,0}, {1,1}, {2,2}}; | ||
parameters.put("X", X); | ||
double [] y = {0,1,2}; | ||
parameters.put("y", y); | ||
instance.callFunction("fit", parameters); | ||
|
||
// You will have to know the structure of the return value: | ||
Map<String, Object> returnedMap = (Map<String,Object>) instance.getAttribute("coef_"); | ||
ArrayList<Double> coef_ = (ArrayList<Double>) returnedMap.get("values"); | ||
System.out.println("coef_: " + coef_); // coef_: [0.5, 0.5] | ||
|
||
parameters.clear(); | ||
double[][] X2 = {{0.5, 1}, {1, 0.5}}; | ||
parameters.put("X", X2); | ||
Map<String, Object> returnedMap2 = (Map<String,Object>) instance.callFunction("predict", parameters); | ||
ArrayList<Double> predictions = (ArrayList<Double>) returnedMap2.get("values"); | ||
System.out.println("predictions: " + predictions); // predictions: [0.75, 0.75] | ||
``` | ||
|
||
## Installation | ||
|
||
Clone this repository. Use the `makefile` in the `build/` folder to build this project: | ||
|
||
```bash | ||
cd build/ | ||
make | ||
``` | ||
|
||
`pasestub.jar` will afterwards lie in the root folder and the `resources` folder will contain all the dependecies needed to use this stub. | ||
You can alternatively then use maven to build this project too. |
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