title: How to make (yes/no or 1-0) decisions with random forest?
body: <p>This is the data set from Kaggle's Titanic competition (<a href="https://1drv.ms/u/s!Ar0y71vBm1oLeTNZl17c1l1bHrw" rel="nofollow noreferrer">train</a> and <a href="https://1drv.ms/u/s!Ar0y71vBm1oLeAGIr7o1s1BG5q4" rel="nofollow noreferrer">test</a> csv files). Each file has features of passengers such as ID, sex, age, etc. The train file has a "survived" column with 0 and 1 values. The test file is missing the survived column as it has to be predicted. 
  This is my simple code using random forest to give me a benchmark for the starter:</p>
  
  <pre><code>import pandas as pd
  import numpy as np
  from sklearn.preprocessing import LabelEncoder
  import random
  from sklearn.ensemble import RandomForestClassifier
  from sklearn.ensemble import GradientBoostingClassifier
  from sklearn.metrics import roc_curve, auc
  
  train=pd.read_csv('train.csv')
  test=pd.read_csv('test.csv')
  train['Type']='Train' #Create a flag for Train and Test Data set
  test['Type']='Test'
  fullData = pd.concat([train,test],axis=0) #Combined both Train and Test Data set
  
  ID_col = ['PassengerId']
  target_col = ["Survived"]
  cat_cols = ['Name','Ticket','Sex','Cabin','Embarked']
  num_cols= ['Pclass','Age','SibSp','Parch','Fare']
  other_col=['Type'] #Test and Train Data set identifier
  
  num_cat_cols = num_cols+cat_cols # Combined numerical and Categorical variables
  for var in num_cat_cols:
      if fullData[var].isnull().any()==True:
          fullData[var+'_NA']=fullData[var].isnull()*1 
  
  #Impute numerical missing values with mean
  fullData[num_cols] = fullData[num_cols].fillna(fullData[num_cols].mean(),inplace=True)
  #Impute categorical missing values with -9999
  fullData[cat_cols] = fullData[cat_cols].fillna(value = -9999)
  
  #create label encoders for categorical features
  for var in cat_cols:
   number = LabelEncoder()
   fullData[var] = number.fit_transform(fullData[var].astype('str'))
  
  train=fullData[fullData['Type']=='Train']
  test=fullData[fullData['Type']=='Test']
  
  train['is_train'] = np.random.uniform(0, 1, len(train)) &lt;= .75
  Train, Validate = train[train['is_train']==True], train[train['is_train']==False]
  
  features=list(set(list(fullData.columns))-set(ID_col)-set(target_col)-set(other_col))
  
  x_train = Train[list(features)].values
  y_train = Train["Survived"].values
  x_validate = Validate[list(features)].values
  y_validate = Validate["Survived"].values
  x_test=test[list(features)].values
  
  Train[list(features)]
  
  #*************************
  from sklearn import tree
  
  random.seed(100)
  rf = RandomForestClassifier(n_estimators=1000)
  rf.fit(x_train, y_train)
  
  status = rf.predict_proba(x_validate)
  fpr, tpr, _ = roc_curve(y_validate, status[:,1]) #metrics. added by me
  roc_auc = auc(fpr, tpr)
  print(roc_auc)
  
  final_status = rf.predict_proba(x_test)
  test["Survived2"]=final_status[:,1]
  
  test['my prediction']=np.where(test.Survived2 &gt; 0.6, 1, 0)
  
  test
  </code></pre>
  
  <p>As you can see, the final_status gives the probability of survival. I'm wondering how to get yes/no (1 or 0) answers from it. The easiest thing that I could think of was to say if probability is greater than 0.6 then the person survived and otherwise died ('my prediction' column) but once I submit the results, the predictions are not good at all.</p>
  
  <p>I appreciate any insights. Thanks</p>