We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
Multi-label classification `predict` method return probabilities rather than calibrated labels.
### Bug Description
<!---
A clear and concise description of what the bug is.
-->

Multi-label classification `predict()` method return probabilities rather than calibrated labels.


### Bug Reproduction
https://github.com/datamllab/automl-in-action-notebooks/blob/master/3.3.4-Task-API-Multi-label.ipynb


### Setup Details
Include the details about the versions of:
 - OS type and version:
 - Python: 
 - autokeras: 1.0.2
 - keras-tuner:
 - scikit-learn:
 - numpy:
 - pandas:
 - tensorflow: 2.1.0



--- END ISSUE ---

Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
--- BEGIN FILES ---
Path: `autokeras/adapters/output_adapter.py`
Content:
```
1 import numpy as np
2 import pandas as pd
3 import tensorflow as tf
4 
5 from autokeras import encoders
6 from autokeras.engine import adapter as adapter_module
7 from autokeras.utils import data_utils
8 
9 
10 class HeadAdapter(adapter_module.Adapter):
11 
12     def __init__(self, name, **kwargs):
13         super().__init__(**kwargs)
14         self.name = name
15 
16     def check(self, dataset):
17         supported_types = (tf.data.Dataset, np.ndarray, pd.DataFrame, pd.Series)
18         if not isinstance(dataset, supported_types):
19             raise TypeError('Expect the target data of {name} to be tf.data.Dataset,'
20                             ' np.ndarray, pd.DataFrame or pd.Series, but got {type}.'
21                             .format(name=self.name, type=type(dataset)))
22 
23     def convert_to_dataset(self, dataset):
24         if isinstance(dataset, np.ndarray):
25             if len(dataset.shape) == 1:
26                 dataset = dataset.reshape(-1, 1)
27         if isinstance(dataset, pd.DataFrame):
28             dataset = dataset.values
29         if isinstance(dataset, pd.Series):
30             dataset = dataset.values.reshape(-1, 1)
31         return super().convert_to_dataset(dataset)
32 
33     def postprocess(self, y):
34         """Postprocess the output of the Keras Model."""
35         return y
36 
37     def get_config(self):
38         config = super().get_config()
39         config.update({
40             'name': self.name,
41         })
42         return config
43 
44 
45 class ClassificationHeadAdapter(HeadAdapter):
46 
47     def __init__(self,
48                  num_classes=None,
49                  multi_label=False,
50                  **kwargs):
51         super().__init__(**kwargs)
52         self.num_classes = num_classes
53         self.label_encoder = None
54         self.multi_label = multi_label
55 
56     def get_config(self):
57         config = super().get_config()
58         config.update({
59             'encoder': encoders.serialize(self.label_encoder),
60         })
61         return config
62 
63     @classmethod
64     def from_config(cls, config):
65         obj = super().from_config(config)
66         obj.label_encoder = encoders.deserialize(config['encoder'])
67 
68     def fit_before_convert(self, dataset):
69         """Fit the encoder."""
70         # If in tf.data.Dataset, must be encoded already.
71         if isinstance(dataset, tf.data.Dataset):
72             return
73 
74         # Convert the data to np.ndarray.
75         if isinstance(dataset, pd.DataFrame):
76             dataset = dataset.values
77         if isinstance(dataset, pd.Series):
78             dataset = dataset.values.reshape(-1, 1)
79 
80         # If encoded.
81         if len(dataset.flatten()) != len(dataset):
82             if self.num_classes:
83                 self._check_data_shape(dataset.shape[1:])
84             return
85 
86         # Fit encoder.
87         labels = set(dataset.flatten())
88         if len(labels) < 2:
89             raise ValueError('Expect the target data for {name} to have '
90                              'at least 2 classes, but got {num_classes}.'
91                              .format(name=self.name, num_classes=self.num_classes))
92         if len(labels) == 2 and not self.multi_label:
93             self.label_encoder = encoders.LabelEncoder()
94         else:
95             self.label_encoder = encoders.OneHotEncoder()
96         self.label_encoder.fit(dataset)
97 
98     def convert_to_dataset(self, dataset):
99         if self.label_encoder:
100             dataset = self.label_encoder.encode(dataset)
101         return super().convert_to_dataset(dataset)
102 
103     def fit(self, dataset):
104         super().fit(dataset)
105         shape = tuple(data_utils.dataset_shape(dataset).as_list()[1:])
106         # Infer the num_classes.
107         if not self.num_classes:
108             # Single column with 0s and 1s.
109             if shape == (1,):
110                 self.num_classes = 2
111             else:
112                 self.num_classes = shape[0]
113             return
114 
115         # Compute expected shape from num_classes.
116         if self.num_classes == 2 and not self.multi_label:
117             expected = (1,)
118         else:
119             expected = (self.num_classes,)
120 
121         # Check shape equals expected shape.
122         if shape != expected:
123             raise ValueError('Expect the target data for {name} to have '
124                              'shape {expected}, but got {actual}.'
125                              .format(name=self.name, expected=expected,
126                                      actual=shape))
127 
128     def postprocess(self, y):
129         if self.label_encoder:
130             y = self.label_encoder.decode(y)
131         return y
132 
133 
134 class RegressionHeadAdapter(HeadAdapter):
135     pass
136 
137 
138 class SegmentationHeadAdapter(ClassificationHeadAdapter):
139     pass
140
```
--- END FILES ---

Please first localize the bug based on the issue statement, and then generate a patch according to the `git diff` format fenced by three backticks.

Here is an example:

```diff
diff --git a/examples/server_async.py b/examples/server_async.py
--- a/examples/server_async.py
+++ b/examples/server_async.py
@@ -313,4 +313,4 @@
 
 
 if __name__ == "__main__":
-    asyncio.run(run_async_server("."), debug=True)
+    asyncio.run(run_async_server(), debug=True)
diff --git a/examples/server_sync.py b/examples/server_sync.py
--- a/examples/server_sync.py
+++ b/examples/server_sync.py
@@ -313,5 +313,5 @@
 
 
 if __name__ == "__main__":
-    server = run_sync_server(".")
+    server = run_sync_server()
     server.shutdown()

```

diff --git a/autokeras/adapters/output_adapter.py b/autokeras/adapters/output_adapter.py
--- a/autokeras/adapters/output_adapter.py
+++ b/autokeras/adapters/output_adapter.py
@@ -78,6 +78,7 @@
             dataset = dataset.values.reshape(-1, 1)
 
         # If encoded.
+        # TODO: support raw string labels for multi-label.
         if len(dataset.flatten()) != len(dataset):
             if self.num_classes:
                 self._check_data_shape(dataset.shape[1:])
@@ -126,6 +127,9 @@
                                      actual=shape))
 
     def postprocess(self, y):
+        if self.multi_label:
+            y[y < 0.5] = 0
+            y[y > 0.5] = 1
         if self.label_encoder:
             y = self.label_encoder.decode(y)
         return y

{"golden_diff": "diff --git a/autokeras/adapters/output_adapter.py b/autokeras/adapters/output_adapter.py\n--- a/autokeras/adapters/output_adapter.py\n+++ b/autokeras/adapters/output_adapter.py\n@@ -78,6 +78,7 @@\n             dataset = dataset.values.reshape(-1, 1)\n \n         # If encoded.\n+        # TODO: support raw string labels for multi-label.\n         if len(dataset.flatten()) != len(dataset):\n             if self.num_classes:\n                 self._check_data_shape(dataset.shape[1:])\n@@ -126,6 +127,9 @@\n                                      actual=shape))\n \n     def postprocess(self, y):\n+        if self.multi_label:\n+            y[y < 0.5] = 0\n+            y[y > 0.5] = 1\n         if self.label_encoder:\n             y = self.label_encoder.decode(y)\n         return y\n", "issue": "Multi-label classification `predict` method return probabilities rather than calibrated labels.\n### Bug Description\r\n<!---\r\nA clear and concise description of what the bug is.\r\n-->\r\n\r\nMulti-label classification `predict()` method return probabilities rather than calibrated labels.\r\n\r\n\r\n### Bug Reproduction\r\nhttps://github.com/datamllab/automl-in-action-notebooks/blob/master/3.3.4-Task-API-Multi-label.ipynb\r\n\r\n\r\n### Setup Details\r\nInclude the details about the versions of:\r\n - OS type and version:\r\n - Python: \r\n - autokeras: 1.0.2\r\n - keras-tuner:\r\n - scikit-learn:\r\n - numpy:\r\n - pandas:\r\n - tensorflow: 2.1.0\r\n\r\n\n", "before_files": [{"content": "import numpy as np\nimport pandas as pd\nimport tensorflow as tf\n\nfrom autokeras import encoders\nfrom autokeras.engine import adapter as adapter_module\nfrom autokeras.utils import data_utils\n\n\nclass HeadAdapter(adapter_module.Adapter):\n\n    def __init__(self, name, **kwargs):\n        super().__init__(**kwargs)\n        self.name = name\n\n    def check(self, dataset):\n        supported_types = (tf.data.Dataset, np.ndarray, pd.DataFrame, pd.Series)\n        if not isinstance(dataset, supported_types):\n            raise TypeError('Expect the target data of {name} to be tf.data.Dataset,'\n                            ' np.ndarray, pd.DataFrame or pd.Series, but got {type}.'\n                            .format(name=self.name, type=type(dataset)))\n\n    def convert_to_dataset(self, dataset):\n        if isinstance(dataset, np.ndarray):\n            if len(dataset.shape) == 1:\n                dataset = dataset.reshape(-1, 1)\n        if isinstance(dataset, pd.DataFrame):\n            dataset = dataset.values\n        if isinstance(dataset, pd.Series):\n            dataset = dataset.values.reshape(-1, 1)\n        return super().convert_to_dataset(dataset)\n\n    def postprocess(self, y):\n        \"\"\"Postprocess the output of the Keras Model.\"\"\"\n        return y\n\n    def get_config(self):\n        config = super().get_config()\n        config.update({\n            'name': self.name,\n        })\n        return config\n\n\nclass ClassificationHeadAdapter(HeadAdapter):\n\n    def __init__(self,\n                 num_classes=None,\n                 multi_label=False,\n                 **kwargs):\n        super().__init__(**kwargs)\n        self.num_classes = num_classes\n        self.label_encoder = None\n        self.multi_label = multi_label\n\n    def get_config(self):\n        config = super().get_config()\n        config.update({\n            'encoder': encoders.serialize(self.label_encoder),\n        })\n        return config\n\n    @classmethod\n    def from_config(cls, config):\n        obj = super().from_config(config)\n        obj.label_encoder = encoders.deserialize(config['encoder'])\n\n    def fit_before_convert(self, dataset):\n        \"\"\"Fit the encoder.\"\"\"\n        # If in tf.data.Dataset, must be encoded already.\n        if isinstance(dataset, tf.data.Dataset):\n            return\n\n        # Convert the data to np.ndarray.\n        if isinstance(dataset, pd.DataFrame):\n            dataset = dataset.values\n        if isinstance(dataset, pd.Series):\n            dataset = dataset.values.reshape(-1, 1)\n\n        # If encoded.\n        if len(dataset.flatten()) != len(dataset):\n            if self.num_classes:\n                self._check_data_shape(dataset.shape[1:])\n            return\n\n        # Fit encoder.\n        labels = set(dataset.flatten())\n        if len(labels) < 2:\n            raise ValueError('Expect the target data for {name} to have '\n                             'at least 2 classes, but got {num_classes}.'\n                             .format(name=self.name, num_classes=self.num_classes))\n        if len(labels) == 2 and not self.multi_label:\n            self.label_encoder = encoders.LabelEncoder()\n        else:\n            self.label_encoder = encoders.OneHotEncoder()\n        self.label_encoder.fit(dataset)\n\n    def convert_to_dataset(self, dataset):\n        if self.label_encoder:\n            dataset = self.label_encoder.encode(dataset)\n        return super().convert_to_dataset(dataset)\n\n    def fit(self, dataset):\n        super().fit(dataset)\n        shape = tuple(data_utils.dataset_shape(dataset).as_list()[1:])\n        # Infer the num_classes.\n        if not self.num_classes:\n            # Single column with 0s and 1s.\n            if shape == (1,):\n                self.num_classes = 2\n            else:\n                self.num_classes = shape[0]\n            return\n\n        # Compute expected shape from num_classes.\n        if self.num_classes == 2 and not self.multi_label:\n            expected = (1,)\n        else:\n            expected = (self.num_classes,)\n\n        # Check shape equals expected shape.\n        if shape != expected:\n            raise ValueError('Expect the target data for {name} to have '\n                             'shape {expected}, but got {actual}.'\n                             .format(name=self.name, expected=expected,\n                                     actual=shape))\n\n    def postprocess(self, y):\n        if self.label_encoder:\n            y = self.label_encoder.decode(y)\n        return y\n\n\nclass RegressionHeadAdapter(HeadAdapter):\n    pass\n\n\nclass SegmentationHeadAdapter(ClassificationHeadAdapter):\n    pass\n", "path": "autokeras/adapters/output_adapter.py"}], "after_files": [{"content": "import numpy as np\nimport pandas as pd\nimport tensorflow as tf\n\nfrom autokeras import encoders\nfrom autokeras.engine import adapter as adapter_module\nfrom autokeras.utils import data_utils\n\n\nclass HeadAdapter(adapter_module.Adapter):\n\n    def __init__(self, name, **kwargs):\n        super().__init__(**kwargs)\n        self.name = name\n\n    def check(self, dataset):\n        supported_types = (tf.data.Dataset, np.ndarray, pd.DataFrame, pd.Series)\n        if not isinstance(dataset, supported_types):\n            raise TypeError('Expect the target data of {name} to be tf.data.Dataset,'\n                            ' np.ndarray, pd.DataFrame or pd.Series, but got {type}.'\n                            .format(name=self.name, type=type(dataset)))\n\n    def convert_to_dataset(self, dataset):\n        if isinstance(dataset, np.ndarray):\n            if len(dataset.shape) == 1:\n                dataset = dataset.reshape(-1, 1)\n        if isinstance(dataset, pd.DataFrame):\n            dataset = dataset.values\n        if isinstance(dataset, pd.Series):\n            dataset = dataset.values.reshape(-1, 1)\n        return super().convert_to_dataset(dataset)\n\n    def postprocess(self, y):\n        \"\"\"Postprocess the output of the Keras Model.\"\"\"\n        return y\n\n    def get_config(self):\n        config = super().get_config()\n        config.update({\n            'name': self.name,\n        })\n        return config\n\n\nclass ClassificationHeadAdapter(HeadAdapter):\n\n    def __init__(self,\n                 num_classes=None,\n                 multi_label=False,\n                 **kwargs):\n        super().__init__(**kwargs)\n        self.num_classes = num_classes\n        self.label_encoder = None\n        self.multi_label = multi_label\n\n    def get_config(self):\n        config = super().get_config()\n        config.update({\n            'encoder': encoders.serialize(self.label_encoder),\n        })\n        return config\n\n    @classmethod\n    def from_config(cls, config):\n        obj = super().from_config(config)\n        obj.label_encoder = encoders.deserialize(config['encoder'])\n\n    def fit_before_convert(self, dataset):\n        \"\"\"Fit the encoder.\"\"\"\n        # If in tf.data.Dataset, must be encoded already.\n        if isinstance(dataset, tf.data.Dataset):\n            return\n\n        # Convert the data to np.ndarray.\n        if isinstance(dataset, pd.DataFrame):\n            dataset = dataset.values\n        if isinstance(dataset, pd.Series):\n            dataset = dataset.values.reshape(-1, 1)\n\n        # If encoded.\n        # TODO: support raw string labels for multi-label.\n        if len(dataset.flatten()) != len(dataset):\n            if self.num_classes:\n                self._check_data_shape(dataset.shape[1:])\n            return\n\n        # Fit encoder.\n        labels = set(dataset.flatten())\n        if len(labels) < 2:\n            raise ValueError('Expect the target data for {name} to have '\n                             'at least 2 classes, but got {num_classes}.'\n                             .format(name=self.name, num_classes=self.num_classes))\n        if len(labels) == 2 and not self.multi_label:\n            self.label_encoder = encoders.LabelEncoder()\n        else:\n            self.label_encoder = encoders.OneHotEncoder()\n        self.label_encoder.fit(dataset)\n\n    def convert_to_dataset(self, dataset):\n        if self.label_encoder:\n            dataset = self.label_encoder.encode(dataset)\n        return super().convert_to_dataset(dataset)\n\n    def fit(self, dataset):\n        super().fit(dataset)\n        shape = tuple(data_utils.dataset_shape(dataset).as_list()[1:])\n        # Infer the num_classes.\n        if not self.num_classes:\n            # Single column with 0s and 1s.\n            if shape == (1,):\n                self.num_classes = 2\n            else:\n                self.num_classes = shape[0]\n            return\n\n        # Compute expected shape from num_classes.\n        if self.num_classes == 2 and not self.multi_label:\n            expected = (1,)\n        else:\n            expected = (self.num_classes,)\n\n        # Check shape equals expected shape.\n        if shape != expected:\n            raise ValueError('Expect the target data for {name} to have '\n                             'shape {expected}, but got {actual}.'\n                             .format(name=self.name, expected=expected,\n                                     actual=shape))\n\n    def postprocess(self, y):\n        if self.multi_label:\n            y[y < 0.5] = 0\n            y[y > 0.5] = 1\n        if self.label_encoder:\n            y = self.label_encoder.decode(y)\n        return y\n\n\nclass RegressionHeadAdapter(HeadAdapter):\n    pass\n\n\nclass SegmentationHeadAdapter(ClassificationHeadAdapter):\n    pass\n", "path": "autokeras/adapters/output_adapter.py"}]}