Open rajitsri opened 1 year ago
from sklearn.ensemble import IsolationForest ifc=IsolationForest(max_samples=len(X_train), contamination=outlier_fraction,random_state=1) ifc.fit(X_train) scores_pred = ifc.decision_function(X_train) y_pred = ifc.predict(X_test)
y_pred[y_pred == 1] = 0 y_pred[y_pred == -1] = 1
n_errors = (y_pred != Y_test).sum()
This unformatted code doesn't appear to have anything to do with hyperas.
Building another model/classifier ISOLATION FOREST
from sklearn.ensemble import IsolationForest ifc=IsolationForest(max_samples=len(X_train), contamination=outlier_fraction,random_state=1) ifc.fit(X_train) scores_pred = ifc.decision_function(X_train) y_pred = ifc.predict(X_test)
Reshape the prediction values to 0 for valid, 1 for fraud.
y_pred[y_pred == 1] = 0 y_pred[y_pred == -1] = 1
n_errors = (y_pred != Y_test).sum()