def _get_summary_struct(self):
        """
        Returns a structured description of the model, including (where relevant)
        the schema of the training data, description of the training data,
        training statistics, and model hyperparameters.

        Returns
        -------
        sections : list (of list of tuples)
            A list of summary sections.
              Each section is a list.
                Each item in a section list is a tuple of the form:
                  ('<label>','<field>')
        section_titles: list
            A list of section titles.
              The order matches that of the 'sections' object.
        """
        _features = _precomputed_field(
            _internal_utils.pretty_print_list(self.get('features')))
        _exclude = _precomputed_field(
            _internal_utils.pretty_print_list(self.get('excluded_features')))
        _stopwords = _precomputed_field(
            _internal_utils.pretty_print_list(self.get('stopwords')))

        fields = [("Features", _features), ("Excluded features", _exclude),
                  ("Output column name", 'output_column_prefix'),
                  ("Word count threshold", 'threshold'),
                  ("Manually specified stopwords", _stopwords),
                  ("Whether to convert to lowercase", "to_lower"),
                  ("Delimiters", "delimiters")]
        section_titles = ['Model fields']

        return ([fields], section_titles)
Пример #2
0
    def _get_summary_struct(self):
        """
        Returns a structured description of the model, including (where relevant)
        the schema of the training data, description of the training data,
        training statistics, and model hyperparameters.

        Returns
        -------
        sections : list (of list of tuples)
            A list of summary sections.
              Each section is a list.
                Each item in a section list is a tuple of the form:
                  ('<label>','<field>')
        section_titles: list
            A list of section titles.
              The order matches that of the 'sections' object.
        """
        _features = _precomputed_field(
            _internal_utils.pretty_print_list(self.get('features')))
        _exclude = _precomputed_field(
            _internal_utils.pretty_print_list(self.get('excluded_features')))
        fields = [("Features", _features), ("Excluded features", _exclude),
                  ("Output column name", 'output_column_name'),
                  ("Number of bits", 'num_bits')]
        section_titles = ['Model fields']

        return ([fields], section_titles)
    def _get_summary_struct(self):
        """
        Returns a structured description of the model, including (where relevant)
        the schema of the training data, description of the training data,
        training statistics, and model hyperparameters.

        Returns
        -------
        sections : list (of list of tuples)
            A list of summary sections.
              Each section is a list.
                Each item in a section list is a tuple of the form:
                  ('<label>','<field>')
        section_titles: list
            A list of section titles.
              The order matches that of the 'sections' object.
        """
        _features = _precomputed_field(
                _internal_utils.pretty_print_list(self.get('features')))
        _exclude = _precomputed_field(
            _internal_utils.pretty_print_list(self.get('excluded_features')))
        fields = [
            ("Features", _features),
            ("Excluded features", _exclude),
            ("Output column name", 'output_column_name'),
            ("Max categories per column", 'max_categories'),
        ]
        section_titles = ['Model fields']

        return ([fields], section_titles)
Пример #4
0
    def _get_summary_struct(self):
        """
        Returns a structured description of the model, including (where relevant)
        the schema of the training data, description of the training data,
        training statistics, and model hyperparameters.

        Returns
        -------
        sections : list (of list of tuples)
            A list of summary sections.
              Each section is a list.
                Each item in a section list is a tuple of the form:
                  ('<label>','<field>')
        section_titles: list
            A list of section titles.
              The order matches that of the 'sections' object.
        """
        section_titles = ["Schema", "Settings"]

        vocab_length = len(self.get("vocabulary"))
        num_topics = len(self.get("topics"))
        verbose = self.get("verbose") == 1

        sections = [
            [("Vocabulary Size", _precomputed_field(vocab_length)), ("Topic Size", _precomputed_field(num_topics))],
            [
                ("Number of Topics", "num_topics"),
                ("alpha", "alpha"),
                ("beta", "beta"),
                ("Iterations", "num_iterations"),
                ("Training time", "training_time"),
                ("Verbose", _precomputed_field(verbose)),
            ],
        ]
        return (sections, section_titles)
    def _get_summary_struct(self):
        """
        Returns a structured description of the model, including (where relevant)
        the schema of the training data, description of the training data,
        training statistics, and model hyperparameters.

        Returns
        -------
        sections : list (of list of tuples)
            A list of summary sections.
              Each section is a list.
                Each item in a section list is a tuple of the form:
                  ('<label>','<field>')
        section_titles: list
            A list of section titles.
              The order matches that of the 'sections' object.
        """
        _features = _precomputed_field(
            _internal_utils.pretty_print_list(self.get('features')))
        _exclude = _precomputed_field(
            _internal_utils.pretty_print_list(self.get('excluded_features')))
        fields = [
            ("Target", "target"),
            ("Features", _features),
            ("Excluded features", _exclude),
            ("Number of bits", 'num_bits'),
            ("Random seed", 'random_seed'),
            ("Laplace Smearing", 'laplace_smearing'),
            ("Count Column Prefix", 'count_column_prefix'),
            ("Probability Column Prefix", 'prob_column_prefix')
            ]
        section_titles = [ 'Model fields' ]
        return ([fields], section_titles)
 def _get_summary_struct(self):
     _features = _precomputed_field(
         _internal_utils.pretty_print_list(self.get('features')))
     _exclude = _precomputed_field(
         _internal_utils.pretty_print_list(self.get('excluded_features')))
     fields = [
         ("Features", _features),
         ("Excluded features", _exclude),
     ]
     section_titles = ['Model fields']
     return ([fields], section_titles)
 def _get_summary_struct(self):
     _features = _precomputed_field(
         _internal_utils.pretty_print_list(self.get('features')))
     _exclude = _precomputed_field(
         _internal_utils.pretty_print_list(self.get('excluded_features')))
     fields = [
         ("Features", _features),
         ("Excluded features", _exclude),
     ]
     section_titles = ['Model fields']
     return ([fields], section_titles)
Пример #8
0
 def _get_summary_struct(self):
     _features = _precomputed_field(
         _internal_utils.pretty_print_list(self.get('features')))
     _exclude = _precomputed_field(
         _internal_utils.pretty_print_list(self.get('excluded_features')))
     fields = [
         ("Features", _features),
         ("Excluded_features", _exclude),
         ("Separator", "separator"),
         ("None Tag", "none_tag"),
         ("Output Column Prefix", 'output_column_prefix')
     ]
         
     section_titles = ['Model fields']
     return ([fields], section_titles)
Пример #9
0
    def _get_summary_struct(self):
        _features = _precomputed_field(
            _internal_utils.pretty_print_list(self.get('features')))
        _exclude = _precomputed_field(
            _internal_utils.pretty_print_list(self.get('excluded_features')))

        fields = [
            ("Features", _features),
            ("Excluded_features", _exclude),
            ("Chosen parts of speech", 'chosen_pos'),
            ("Output column prefix", 'output_column_prefix'),
        ]
        section_titles = ['Model fields']

        return ([fields], section_titles)
Пример #10
0
 def __repr__(steps):
     for name, tr in self._transformers:
         model_fields.append(
             (name, _precomputed_field(self._compact_class_repr(tr))))
     return _toolkit_repr_print(steps, [model_fields],
                                width=8,
                                section_titles=['Steps'])
Пример #11
0
    def _get_summary_struct(self):
        """
        Returns a structured description of the model, including (where relevant)
        the schema of the training data, description of the training data,
        training statistics, and model hyperparameters.

        Returns
        -------
        sections : list (of list of tuples)
            A list of summary sections.
              Each section is a list.
                Each item in a section list is a tuple of the form:
                  ('<feature>','<field>')
        section_titles: list
            A list of section titles.
              The order matches that of the 'sections' object.
        """
        _reference_features = _precomputed_field(
            _internal_utils.pretty_print_list(self.get('reference_features')))

        fields = [
            ("reference_features", _reference_features),
            ("Column to impute", 'feature')
        ]
        section_titles = ['Model fields']

        return ([fields], section_titles)
    def _get_summary_struct(self):
        """
        Returns a structured description of the model, including (where relevant)
        the schema of the training data, description of the training data,
        training statistics, and model hyperparameters.

        Returns
        -------
        sections : list (of list of tuples)
            A list of summary sections.
              Each section is a list.
                Each item in a section list is a tuple of the form:
                  ('<label>','<field>')
        section_titles: list
            A list of section titles.
              The order matches that of the 'sections' object.
        """
        fields = [
            ("Min support", 'min_support'),
            ("Max patterns", 'max_patterns'),
            ("Min pattern length", 'min_length'),
        ]

        patterns_sf = self.get('frequent_patterns').topk('support')
        patterns = [(p['pattern'], _precomputed_field(p['support']))
                    for p in patterns_sf]
        section_titles = ['Model fields', 'Most frequent patterns']
        return ([fields, patterns], section_titles)
Пример #13
0
    def _get_summary_struct(self):
        model_fields = []
        for attr in self.__dict__:
            if not attr.startswith('_'):
                model_fields.append((attr, _precomputed_field(getattr(self, attr))))

        return ([model_fields], ['Attributes'] )
Пример #14
0
    def _get_summary_struct(self):
        """
        Returns a structured description of the model, including (where relevant)
        the schema of the training data, description of the training data,
        training statistics, and model hyperparameters.

        Returns
        -------
        sections : list (of list of tuples)
            A list of summary sections.
              Each section is a list.
                Each item in a section list is a tuple of the form:
                  ('<feature>','<field>')
        section_titles: list
            A list of section titles.
              The order matches that of the 'sections' object.
        """
        _reference_features = _precomputed_field(
            _internal_utils.pretty_print_list(self.get('reference_features')))

        fields = [("reference_features", _reference_features),
                  ("Column to impute", 'feature')]
        section_titles = ['Model fields']

        return ([fields], section_titles)
Пример #15
0
    def _get_summary_struct(self):
        """
        Returns a structured description of the model, including (where relevant)
        the schema of the training data, description of the training data,
        training statistics, and model hyperparameters.

        Returns
        -------
        sections : list (of list of tuples)
            A list of summary sections.
              Each section is a list.
                Each item in a section list is a tuple of the form:
                  ('<label>','<field>')
        section_titles: list
            A list of section titles.
              The order matches that of the 'sections' object.
        """
        fields = [
            ("Min support", 'min_support'),
            ("Max patterns", 'max_patterns'),
            ("Min pattern length", 'min_length'),
        ]

        patterns_sf = self.get('frequent_patterns').topk('support')
        patterns = [(p['pattern'], _precomputed_field(p['support']))
                    for p in patterns_sf]
        section_titles = ['Model fields', 'Most frequent patterns']
        return ([fields, patterns], section_titles)
Пример #16
0
    def _get_summary_struct(self):
        """
        Returns a structured description of the model, including (where relevant)
        the schema of the training data, description of the training data,
        training statistics, and model hyperparameters.

        Returns
        -------
        sections : list (of list of tuples)
            A list of summary sections.
              Each section is a list.
                Each item in a section list is a tuple of the form:
                  ('<label>','<field>')
        section_titles: list
            A list of section titles.
              The order matches that of the 'sections' object.
        """
        _features = _precomputed_field(_internal_utils.pretty_print_list(self.get("features")))

        fields = [
            ("Features", _features),
            ("Convert strings to lower case", "to_lower"),
            ("Delimiters", "delimiters"),
            ("Output column prefix", "output_column_prefix"),
        ]
        section_titles = ["Model fields"]

        return ([fields], section_titles)
Пример #17
0
    def _get_summary_struct(self):
        model_fields = []
        for attr in self.__dict__:
            if not attr.startswith('_'):
                model_fields.append(
                    (attr, _precomputed_field(getattr(self, attr))))

        return ([model_fields], ['Attributes'])
Пример #18
0
 def _get_summary_struct(self):
     _features = _precomputed_field(
         _internal_utils.pretty_print_list(self.get('features')))
     fields = [("Features", _features),
               ("Convert strings to lower case", 'to_lower'),
               ("Delimiters", "delimiters"),
               ("Output column prefix", 'output_column_prefix')]
     section_titles = ['Model fields']
     return ([fields], section_titles)
    def _get_summary_struct(self):
        """
        Returns a structured description of the model, including (where relevant)
        the schema of the training data, description of the training data,
        training statistics, and model hyperparameters.

        Returns
        -------
        sections : list (of list of tuples)
            A list of summary sections.
              Each section is a list.
                Each item in a section list is a tuple of the form:
                  ('<label>','<field>')
        section_titles: list
            A list of section titles.
              The order matches that of the 'sections' object.
        """
        g = self['graph']

        section_titles = ['Graph']

        graph_summary = [(k, _precomputed_field(v))
                         for k, v in six.iteritems(g.summary())]

        sections = [graph_summary]

        # collect other sections
        results = [(k, _precomputed_field(v))
                   for k, v in six.iteritems(self._result_fields())]
        methods = [(k, _precomputed_field(v))
                   for k, v in six.iteritems(self._method_fields())]
        settings = [(k, v) for k, v in six.iteritems(self._setting_fields())]
        metrics = [(k, v) for k, v in six.iteritems(self._metric_fields())]

        optional_sections = [('Results', results), ('Settings', settings), \
                                ('Metrics', metrics), ('Methods', methods)]

        # if section is not empty, append to summary structure
        for (title, section) in optional_sections:
            if len(section) > 0:
                section_titles.append(title)
                sections.append(section)

        return (sections, section_titles)
Пример #20
0
    def _get_struct_summary(self):
        model_fields = []
        for name, tr in self._transformers:
            model_fields.append((name,
                         _precomputed_field(self._compact_class_repr(tr))))

        sections = [model_fields]
        section_titles = ['Steps']

        return (sections, section_titles)
Пример #21
0
 def _get_summary_struct(self):
     _features = _precomputed_field(_internal_utils.pretty_print_list(self.get("features")))
     fields = [
         ("Features", _features),
         ("Minimimum Document Frequency", "min_document_frequency"),
         ("Maximimum Document Frequency", "max_document_frequency"),
         ("Output Column Name", "output_column_name"),
     ]
     section_titles = ["Model fields"]
     return ([fields], section_titles)
Пример #22
0
    def _get_struct_summary(self):
        model_fields = []
        for name, tr in self._transformers:
            model_fields.append(
                (name, _precomputed_field(self._compact_class_repr(tr))))

        sections = [model_fields]
        section_titles = ['Steps']

        return (sections, section_titles)
 def _get_summary_struct(self):
     _features = _precomputed_field(
         _internal_utils.pretty_print_list(self.get('features')))
     fields = [
         ("Features", _features),
         ("Convert strings to lower case", 'to_lower'),
         ("Delimiters", "delimiters"),
         ("Output column prefix", 'output_column_prefix')
     ]
     section_titles = ['Model fields']
     return ([fields], section_titles)
 def _get_summary_struct(self):
     _features = _precomputed_field(
         _internal_utils.pretty_print_list(self.get('features')))
     fields = [
         ("Features", _features),
         ("Minimimum Document Frequency", 'min_document_frequency'),
         ("Maximimum Document Frequency", 'max_document_frequency'),
         ("Output Column Prefix", 'output_column_prefix')
     ]
     section_titles = ['Model fields']
     return ([fields], section_titles)
Пример #25
0
    def _get_summary_struct(self):
        """
        Returns a structured description of the model, including (where relevant)
        the schema of the training data, description of the training data,
        training statistics, and model hyperparameters.

        Returns
        -------
        sections : list (of list of tuples)
            A list of summary sections.
              Each section is a list.
                Each item in a section list is a tuple of the form:
                  ('<label>','<field>')
        section_titles: list
            A list of section titles.
              The order matches that of the 'sections' object.
        """
        g = self['graph']

        section_titles = ['Graph']

        graph_summary = [(k, _precomputed_field(v)) for k, v in g.summary().iteritems()]

        sections = [graph_summary]

        # collect other sections
        results = [(k, _precomputed_field(v)) for k, v in self._result_fields().iteritems()]
        methods = [(k, _precomputed_field(v)) for k, v in self._method_fields().iteritems()]
        settings = [(k, v) for k, v in self._setting_fields().iteritems()]
        metrics = [(k, v) for k, v in self._metric_fields().iteritems()]

        optional_sections = [('Results', results), ('Settings', settings), \
                                ('Metrics', metrics), ('Methods', methods)]

        # if section is not empty, append to summary structure
        for (title, section) in optional_sections:
            if len(section) > 0:
                section_titles.append(title)
                sections.append(section)

        return (sections, section_titles)
Пример #26
0
    def __repr__(self):

        descriptions = [(k, _precomputed_field(v)) for k, v in self._describe_fields().iteritems()]

        (sections, section_titles) = self._get_summary_struct()
        non_empty_sections = [s for s in sections if len(s) > 0]
        non_empty_section_titles = [section_titles[i] for i in range(len(sections)) if len(sections[i]) > 0]

        non_empty_section_titles.append('Queryable Fields')
        non_empty_sections.append(descriptions)

        return _toolkit_repr_print(self, non_empty_sections, non_empty_section_titles, width=40)
Пример #27
0
    def _get_summary_struct(self):
        """
        Returns a structured description of the model, including (where relevant)
        the schema of the training data, description of the training data,
        training statistics, and model hyperparameters.

        Returns
        -------
        sections : list (of list of tuples)
            A list of summary sections.
              Each section is a list.
                Each item in a section list is a tuple of the form:
                  ('<label>','<field>')
        section_titles: list
            A list of section titles.
              The order matches that of the 'sections' object.
        """
        section_titles=['Schema','Settings']

        vocab_length = len(self.get('vocabulary'))
        num_topics = len(self.get('topics'))
        verbose = self.get('verbose') == 1

        sections=[
                    [
                        ('Vocabulary Size',_precomputed_field(vocab_length)),
                        ('Topic Size', _precomputed_field(num_topics))
                    ],
                    [
                        ('Number of Topics', 'num_topics'),
                        ('alpha','alpha'),
                        ('beta','beta'),
                        ('Iterations', 'num_iterations'),
                        ('Training time', 'training_time'),
                        ('Verbose', _precomputed_field(verbose))
                    ]
                ]
        return (sections, section_titles)
Пример #28
0
 def _get_summary_struct(self):
     _features = _precomputed_field(
         _internal_utils.pretty_print_list(self.get('features')))
     fields = [
         ("Features", _features),
         ("query", 'query'),
         ("k1", 'k1'),
         ("b", 'b'),
         ("Minimimum Document Frequency", 'min_document_frequency'),
         ("Maximimum Document Frequency", 'max_document_frequency'),
         ("Output Column Name", 'output_column_name')
     ]
     section_titles = ['Model fields']
     return ([fields], section_titles)
 def _get_summary_struct(self):
     _features = _precomputed_field(
         _internal_utils.pretty_print_list(self.get('features')))
     fields = [
         ("NGram length", 'n'),
         ("NGram type (word or character)", 'ngram_type'),
         ("Convert strings to lower case", 'to_lower'),
         ("Ignore punctuation in character ngram", 'ignore_punct'),
         ("Ignore space in character ngram", 'ignore_space'),
         ("Delimiters", "delimiters"),
         ("Features", _features),
         ("Output column prefix", 'output_column_prefix')
     ]
     section_titles = ['Model fields']
     return ([fields], section_titles)
    def _get_summary_struct(self):
        """
        Returns a structured description of the model, including (where relevant)
        the schema of the training data, description of the training data,
        training statistics, and model hyperparameters.

        Returns
        -------
        sections : list (of list of tuples)
            A list of summary sections.
              Each section is a list.
                Each item in a section list is a tuple of the form:
                  ('<label>','<field>')
        section_titles: list
            A list of section titles.
              The order matches that of the 'sections' object.
        """
        section_titles=['Schema','Settings']

        vocab_length = len(self.get('vocabulary'))
        verbose = self.get('verbose') == 1

        sections=[
                    [
                        ('Vocabulary Size',_precomputed_field(vocab_length))
                    ],
                    [
                        ('Number of Topics', 'num_topics'),
                        ('alpha','alpha'),
                        ('beta','beta'),
                        ('Iterations', 'num_iterations'),
                        ('Training time', 'training_time'),
                        ('Verbose', _precomputed_field(verbose))
                    ]
                ]
        return (sections, section_titles)
Пример #31
0
 def _get_summary_struct(self):
     _features = _precomputed_field(
         _internal_utils.pretty_print_list(self.get('features')))
     fields = [
         ("NGram length", 'n'),
         ("NGram type (word or character)", 'ngram_type'),
         ("Convert strings to lower case", 'to_lower'),
         ("Ignore punctuation in character ngram", 'ignore_punct'),
         ("Ignore space in character ngram", 'ignore_space'),
         ("Delimiters", "delimiters"),
         ("Features", _features),
         ("Output column prefix", 'output_column_prefix')
     ]
     section_titles = ['Model fields']
     return ([fields], section_titles)
    def __repr__(self):

        descriptions = [(k, _precomputed_field(v))
                        for k, v in six.iteritems(self._describe_fields())]

        (sections, section_titles) = self._get_summary_struct()
        non_empty_sections = [s for s in sections if len(s) > 0]
        non_empty_section_titles = [
            section_titles[i] for i in range(len(sections))
            if len(sections[i]) > 0
        ]

        non_empty_section_titles.append('Queryable Fields')
        non_empty_sections.append(descriptions)

        return _toolkit_repr_print(self,
                                   non_empty_sections,
                                   non_empty_section_titles,
                                   width=40)
Пример #33
0
 def __repr__(steps):
     for name, tr in self._transformers:
         model_fields.append((name,
                      _precomputed_field(self._compact_class_repr(tr))))
     return _toolkit_repr_print(steps, [model_fields], width=8,
                                    section_titles = ['Steps'])
Пример #34
0
    def _get_summary_struct(self):
        """
        Returns a structured description of the model, including (where relevant)
        the schema of the training data, description of the training data,
        training statistics, and model hyperparameters.

        Returns
        -------
        sections : list (of list of tuples)
            A list of summary sections.
              Each section is a list.
                Each item in a section list is a tuple of the form:
                  ('<feature>','<field>')
        section_titles: list
            A list of section titles.
              The order matches that of the 'sections' object.
        """

        sections = []
        fields = []

        _features = _precomputed_field(
            _internal_utils.pretty_print_list(self.features))
        _exclude = _precomputed_field(
            _internal_utils.pretty_print_list(self.excluded_features))

        header_fields = [("Features", "features"),
                         ("Excluded Features", "excluded_features")]

        sections.append("Model Fields")
        fields.append(header_fields)

        if self.user_column_interpretations:
            sections.append("User Specified Interpretations")
            fields.append(
                list(sorted(self.get("user_column_interpretations").items())))

        column_interpretations = self.get("column_interpretations")
        features = self.get("features")

        if self.get("fitted") and features is not None:

            n_rows = len(features)
            transform_info = [None] * n_rows

            for i, f in enumerate(features):
                interpretation = column_interpretations[f]
                input_type = self.input_types[f]
                description, output_type = _get_interpretation_description_and_output_type(
                    interpretation, input_type)

                transform_info[i] = (f, input_type.__name__, interpretation,
                                     description, output_type.__name__)

            transform_table = _SFrame()
            transform_table["Column"] = [t[0] for t in transform_info]
            transform_table["Type"] = [t[1] for t in transform_info]
            transform_table["Interpretation"] = [t[2] for t in transform_info]
            transform_table["Transforms"] = [t[3] for t in transform_info]
            transform_table["Output Type"] = [t[4] for t in transform_info]

            fields[-1].append(transform_table)

        return fields, sections