title: Python: Evaluating an Isolation Forest
body: <p>I am doing isolation forest clustering on the the mulcross database with 2 classes. I divide my data into training and test set and try to calculate the accuracy score, the roc_auc_score and the confusion_matrix on my test set. But there are two problems: The first one is that in a clustering method i should not use the labels in the training phase, it means that <em>"y_train"</em> should not be mentioned, but i did not find another solution to evaluate my model. More over the results i found are wrong. 
  <strong>My problem is how to evaluate a clustering model like isolation forest.</strong>
  Here is my code:</p>
  
  <pre><code>df = pd.read_csv('db.csv')
  y_true=df['Target']
  df_data=df.drop('Target',1)
  
  X_train, X_test, y_train, y_test = train_test_split(df_data, y_true, test_size=0.3, random_state=42)
  
  alg=IsolationForest(n_estimators=100, max_samples= 256 , contamination=0.1, max_features=1.0, bootstrap=False, n_jobs=-1, random_state=42, verbose=0, behaviour="new")
  model = alg.fit(X_train, y_train)
  preds = alg.predict(X_test)
  
  print("#############################\n#############################")
  print(accuracy_score(y_test, preds))
  print(roc_auc_score(y_test, preds))
  cm = confusion_matrix(y_test, preds)
  print(cm)
  print("#############################\n#############################")
  </code></pre>