You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have a multi-class category task using RandomForestModel, and I'm trying to make predictions using the JS API.
For the Python API, I had to reverse engineer the fact (without the help of documentation!) that the prediction array contains probabilities for each of the label's possible categories, and more crucially, that the prediction array is ordered indexed the same as the category strings available in model.label_classes(). (The documentation needs to be improved here, but this is not the main point.)
Basically, I am doing something like this (to run my complete input dataset back through the model for some of my own diagnostics):
def pred():
raw_preds = model.predict(df)
preds = np.argmax(raw_preds, axis=1).tolist()
label_classes = model.label_classes()
cooked_preds = [ label_classes[p] for p in preds ]
# cooked_preds now contains the label strings for all the predictions for all the input samples
For the JavaScript API, I have no similar programmatic way of mapping the prediction array to the original label classes. I would have to first know the order provided by the model as seen by the Python API, then make the assumption that the prediction array is ordered the same using the JS API. This seems fragile since the ordering isn't specified anywhere and might be non-deterministic based on how the model was built. It seems to me that it minimally needs something similar to python's model.label_classes().
As far as I can see, using Object.getOwnPropertyNames(model), the JS model object has only the following properties, which are not terribly helpful. And TBH I'm not sure how predict() even works here:
I have a multi-class category task using RandomForestModel, and I'm trying to make predictions using the JS API.
For the Python API, I had to reverse engineer the fact (without the help of documentation!) that the prediction array contains probabilities for each of the label's possible categories, and more crucially, that the prediction array is ordered indexed the same as the category strings available in
model.label_classes()
. (The documentation needs to be improved here, but this is not the main point.)Basically, I am doing something like this (to run my complete input dataset back through the model for some of my own diagnostics):
For the JavaScript API, I have no similar programmatic way of mapping the prediction array to the original label classes. I would have to first know the order provided by the model as seen by the Python API, then make the assumption that the prediction array is ordered the same using the JS API. This seems fragile since the ordering isn't specified anywhere and might be non-deterministic based on how the model was built. It seems to me that it minimally needs something similar to python's
model.label_classes()
.As far as I can see, using
Object.getOwnPropertyNames(model)
, the JS model object has only the following properties, which are not terribly helpful. And TBH I'm not sure howpredict()
even works here:The text was updated successfully, but these errors were encountered: