Add predict_proba with tensors

This commit is contained in:
2024-07-12 12:54:30 +02:00
parent c5ff1a0b2b
commit 37716a57f4
6 changed files with 66 additions and 9 deletions

View File

@@ -222,11 +222,19 @@ namespace pywrap {
errorAbort(e.what());
}
}
PyObject* PyWrap::predict_proba(const clfId_t id, CPyObject& X)
{
return predict_method("predict_proba", id, X);
}
PyObject* PyWrap::predict(const clfId_t id, CPyObject& X)
{
return predict_method("predict", id, X);
}
PyObject* PyWrap::predict_method(const std::string name, const clfId_t id, CPyObject& X)
{
PyObject* instance = getClass(id);
PyObject* result;
CPyObject method = PyUnicode_FromString("predict");
CPyObject method = PyUnicode_FromString(name.c_str());
try {
if (!(result = PyObject_CallMethodObjArgs(instance, method.getObject(), X.getObject(), NULL)))
errorAbort("Couldn't call method predict");