-
Notifications
You must be signed in to change notification settings - Fork 54
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
Cannot run inference with Javascript API in the Node.js REPL #99
Comments
Hi, On my side, using node v18.19.1, both of the following setup works. Would you mind trying them? Download node Then run const ydf = await require("yggdrasil-decision-forests")();
const fs = require("node:fs");
let model = await ydf.loadModelFromZipBlob(fs.readFileSync("./model.zip"));
let examples = {
"age": [39, 40, 40, 35],
"workclass": ["State-gov", "Private", "Private", "Federal-gov"],
"fnlwgt": [77516, 121772, 193524, 76845],
"education": ["Bachelors", "Assoc-voc", "Doctorate", "9th"],
"education_num": ["13", "11", "16", "5"],
"marital_status": ["Never-married", "Married-civ-spouse", "Married-civ-spouse", "Married-civ-spouse"],
"occupation": ["Adm-clerical", "Craft-repair", "Prof-specialty", "Farming-fishing"],
"relationship": ["Not-in-family", "Husband", "Husband", "Husband"],
"race": ["White", "Asian-Pac-Islander", "White", "Black"],
"sex": ["Male", "Male", "Male", "Male"],
"capital_gain": [2174, 0, 0, 0],
"capital_loss": [0, 0, 0, 0],
"hours_per_week": [40, 40, 60, 40],
"native_country": ["United-States", null, "United-States", "United-States"]
};
model.predict(examples); Create a (async function (){
// Load the YDF library
const ydf = await require("yggdrasil-decision-forests")();
// Load the model
const fs = require("node:fs");
let model = await ydf.loadModelFromZipBlob(fs.readFileSync("./model.zip"));
// Create a batch of examples.
let examples = {
"age": [39, 40, 40, 35],
"workclass": ["State-gov", "Private", "Private", "Federal-gov"],
"fnlwgt": [77516, 121772, 193524, 76845],
"education": ["Bachelors", "Assoc-voc", "Doctorate", "9th"],
"education_num": ["13", "11", "16", "5"],
"marital_status": ["Never-married", "Married-civ-spouse", "Married-civ-spouse", "Married-civ-spouse"],
"occupation": ["Adm-clerical", "Craft-repair", "Prof-specialty", "Farming-fishing"],
"relationship": ["Not-in-family", "Husband", "Husband", "Husband"],
"race": ["White", "Asian-Pac-Islander", "White", "Black"],
"sex": ["Male", "Male", "Male", "Male"],
"capital_gain": [2174, 0, 0, 0],
"capital_loss": [0, 0, 0, 0],
"hours_per_week": [40, 40, 60, 40],
"native_country": ["United-States", null, "United-States", "United-States"]
};
// Make predictions
let predictions = model.predict(examples);
console.log("predictions:", predictions);
// Release model
model.unload();
}()) Then
If the above does not work Assuming your code does not have such a statement, YDF has one (injected by webassembly) which could be the cause of the issue. process["on"]("uncaughtException",function(ex){if(!(ex instanceof ExitStatus)){throw ex}}); It would be interesting to see if removing it manually / temporally solves your issue. |
Attempts to call
YggdrasilModel.predict
in a Node.js REPL yield this exception:[ERR_INVALID_REPL_INPUT]: Listeners for uncaughtException cannot be used in the REPL
. We're using version0.0.2
of the JS code published to NPM.The text was updated successfully, but these errors were encountered: