# Calculating accuracy score of isolation forest model returning error

My code is as follows:

import joblib as jl

contamination = input(":")
labelEncoder(_data)
model = IsolationForest(contamination=float(contamination), n_estimators=1000, verbose=1)
model.fit(_data)
jl.dump(model, 'file.joblib')


this trains the model and dumps it to joblib file. After that i use the joblib to test data further as follows:

_data = pd.read_csv(ifile.csv)
predictions = model.predict(_data)
_data[anomaly] = pd.Series(model.predict(_data))
predictions = np.where(predictions == 1, 0, 1) #Mapping 1->0 and -1->1
acc = accuracy_score(_data, predictions)


This however return the following error:

raise ValueError("Classification metrics can't handle a mix of {0}
ValueError: Classification metrics can't handle a mix of continuous-multioutput and binary targets


Can someone tell me what am i doing wrong? I have tried converting both "_data" and "predictions" to numpy arrays, but it still returns the same error.

Thank you

accuracy_score needs y_test not the x_test . You have passed x_test