akusok / scikit-elm

Extreme Learning Machine (ELM) with Scikit-Learn compatibility
MIT License
30 stars 12 forks source link

predict_proba() doesn't match predict() in binary classification #8

Open prmtsari opened 2 years ago

prmtsari commented 2 years ago

Hi, I'm running the code that prints the model.predict, model.predict_proba in binary classification. The problem is the probabilities from predict_proba() don't appear to match the predicted class from predict(). See the sample of the code and the printout below:

df = pd.read_excel (r'D:\elm\heartlog.xlsx',header=None)
X,y=df.iloc[:,:-1],df.iloc[:,-1]
X_train, X_test, y_train, y_test = train_test_split(X, y, stratify=y, test_size=0.02)
clf=ELMClassifier(n_neurons=10, ufunc='sigm')
clf.fit(X_train,y_train)
y_pred=clf.predict(X_test)
y_proba=clf.predict_proba(X_test)
print("pred",y_pred)
print("proba",y_proba)

Result : pred [1 1 2 1 1 1] proba [[0.39689426 0.60310574] [0.39158382 0.60841618] [0.33327835 0.66672165] [0.39609943 0.60390057] [0.39689428 0.60310572] [0.39689424 0.60310576]]

It shows all test data having the highest probability to the second class. I did try to do it on other dataset with binary class (livers disorder and HCC survival from UCI), but almost all of predict_proba result was having the highest probability to the second class and it didnt match with model.predict results.

I also tried to do it on dataset with multi class datasets (iris, dermatology, and breast tissue from UCI), the results of predict is matching with predict_proba. So i think the problem is only occurs on binary classification.

How can i get predict results that match with predict_proba in binary classification?

Abdou24MR commented 2 years ago

here a proposal for predict_proba(): https://github.com/dclambert/Python-ELM/issues/4 I insert it in the code source. it does well.