Exemplo n.º 1
0
def test_categorical_to_numerical():
    block = preprocessing.CategoricalToNumerical()
    block.column_names = ['a']
    block.column_types = {'a': 'num'}
    utils.block_basic_exam(
        block,
        tf.keras.Input(shape=(1, ), dtype=tf.string),
        [],
    )
Exemplo n.º 2
0
 def build(self, hp, inputs=None):
     input_node = nest.flatten(inputs)[0]
     output_node = input_node
     if self.categorical_encoding:
         block = preprocessing.CategoricalToNumerical()
         block.column_types = self.column_types
         block.column_names = self.column_names
         output_node = block.build(hp, output_node)
     output_node = basic.DenseBlock().build(hp, output_node)
     return output_node
Exemplo n.º 3
0
 def build_categorical_encoding(self, hp, input_node):
     output_node = input_node
     categorical_encoding = self.categorical_encoding
     if categorical_encoding is None:
         categorical_encoding = hp.Choice('categorical_encoding',
                                          [True, False],
                                          default=True)
     if categorical_encoding:
         block = preprocessing.CategoricalToNumerical()
         block.column_types = self.column_types
         block.column_names = self.column_names
         output_node = block.build(hp, output_node)
     return output_node
Exemplo n.º 4
0
    def build(self, hp, inputs=None):
        input_node = nest.flatten(inputs)[0]
        output_node = input_node
        if self.categorical_encoding:
            block = preprocessing.CategoricalToNumerical()
            block.column_types = self.column_types
            block.column_names = self.column_names
            output_node = block.build(hp, output_node)

        if self.normalize is None and hp.Boolean(NORMALIZE):
            with hp.conditional_scope(NORMALIZE, [True]):
                output_node = preprocessing.Normalization().build(hp, output_node)
        elif self.normalize:
            output_node = preprocessing.Normalization().build(hp, output_node)

        output_node = basic.DenseBlock().build(hp, output_node)
        return output_node