chaquo / chaquopy

Chaquopy: the Python SDK for Android
https://chaquo.com/chaquopy/
MIT License
748 stars 127 forks source link

AttributeError: 'HalfBinomialLoss' object has no attribute 'get_init_raw_predictions' #1167

Closed FishWaterUnder closed 2 weeks ago

FishWaterUnder commented 4 weeks ago

Chaquopy version

Version 3.9

Devices or emulators where the issue happens

TECHNO KI5K phone

Relevant parts of your code

import numpy as np
import pandas as pd
from os.path import dirname, join
from landmarkers import landmarkers
import pickle
import sklearn

def henllo(lk):
    filename = join(dirname(__file__), "bicep_Curls.pk1")
    with open(filename, 'rb') as f:
        model = pickle.load(f)

    row =[lk.get(i) for i in range(lk.size())]
    X = pd.DataFrame([row], columns = landmarkers)
    bodylang_class = model.predict(X)[0]
    print(bodylang_class)

Describe your issue

I tried to run a machine learning algorithm using a pickle file but it gave me this error

JNI DETECTED ERROR IN APPLICATION: JNI GetObjectClass called with pending exception java.lang.IllegalStateException: com.chaquo.python.PyException: AttributeError: 'HalfBinomialLoss' object has no attribute 'get_init_raw_predictions'

I followed this person in #160 but theirs work I believe when my doesn't

mhsmith commented 3 weeks ago

If you search for this error, you'll find https://github.com/scikit-learn/scikit-learn/issues/14076, which says:

While models saved using one version of scikit-learn might load in other versions, this is entirely unsupported and inadvisable.

So you'll have to either:

mhsmith commented 3 weeks ago

There may still be a Chaquopy bug here, because it should have produced a regular Java exception rather than a JNI error. But I have no other reports of this happening, so in order to look into it, I would need a complete and self-contained example.

FishWaterUnder commented 2 weeks ago

Thank You! It worked