示例#1
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.
        """
        model_fields = [
            ("Number of coefficients", "num_coefficients"),
            ("Number of examples", "num_examples"),
            ("Number of feature columns", "num_features"),
            ("Number of unpacked features", "num_unpacked_features"),
        ]

        hyperparam_fields = [("L1 penalty", "l1_penalty"),
                             ("L2 penalty", "l2_penalty")]

        solver_fields = [
            ("Solver", "solver"),
            ("Solver iterations", "training_iterations"),
            ("Solver status", "training_solver_status"),
            ("Training time (sec)", "training_time"),
        ]

        training_fields = [
            ("Residual sum of squares", "training_loss"),
            ("Training RMSE", "training_rmse"),
        ]

        coefs = self.coefficients
        top_coefs, bottom_coefs = _toolkit_get_topk_bottomk(coefs, k=5)

        (coefs_list,
         titles_list) = _summarize_coefficients(top_coefs, bottom_coefs)

        return (
            [model_fields, hyperparam_fields, solver_fields, training_fields] +
            coefs_list,
            ["Schema", "Hyperparameters", "Training Summary", "Settings"] +
            titles_list,
        )
示例#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.
        """

        model_fields = [
            ('Number of coefficients', 'num_coefficients'),
            ('Number of examples', 'num_examples'),
            ('Number of classes', 'num_classes'),
            ('Number of feature columns', 'num_features'),
            ('Number of unpacked features', 'num_unpacked_features')]

        hyperparam_fields = [
            ("L1 penalty", 'l1_penalty'),
            ("L2 penalty", 'l2_penalty')
        ]

        solver_fields = [
            ("Solver", 'solver'),
            ("Solver iterations", 'training_iterations'),
            ("Solver status", 'training_solver_status'),
            ("Training time (sec)", 'training_time')]

        training_fields = [
            ("Log-likelihood", 'training_loss')]

        coefs = self.coefficients
        top_coefs, bottom_coefs = _toolkit_get_topk_bottomk(coefs,k=5)

        (coefs_list, titles_list) = _summarize_coefficients(top_coefs, \
                                                                    bottom_coefs)

        return ([ model_fields, hyperparam_fields, \
                        solver_fields, training_fields ] + coefs_list, \
                        [ 'Schema', 'Hyperparameters', \
                        'Training Summary', 'Settings' ] + titles_list )