code: def predict_survival(
      passenger_class, is_male, age, company, fare, embark_point
  ):
      if passenger_class is None or embark_point is None:
          return None
      df = pd.DataFrame.from_dict(
          {
              "Pclass": [passenger_class + 1],
              "Sex": [0 if is_male else 1],
              "Age": [age],
              "Fare": [fare],
              "Embarked": [embark_point + 1],
              "Company": [
                  (1 if "Sibling" in company else 0)
                  + (2 if "Child" in company else 0)
              ],
          }
      )
      df = encode_age(df)
      df = encode_fare(df)
      pred = clf.predict_proba(df)[0]
      return {"Perishes": float(pred[0]), "Survives": float(pred[1])}
  
file_path: gradio/demo/titanic_survival/run.py
imports: import os
  import pandas
  from sklearn.ensemble import RandomForestClassifier
  from sklearn.model_selection import train_test_split
  import gradio
label_desc: Use image node_id 4 for calling a global function with example usage: predict_survival(passenger_class, is_male, age, company, fare, embark_point) and returns: dict, None