Make a confidence report and save it to disk.
5828
def main(argv=None):
  
  assert len(argv) >= 3
  _name_of_script = argv[0]
  model_filepath = argv[1]
  adv_x_filepaths = argv[2:]

  sess = tf.Session()
  with sess.as_default():
    model = serial.load(model_filepath)

  factory = model.dataset_factory
  factory.kwargs['train_start'] = FLAGS.train_start
  factory.kwargs['train_end'] = FLAGS.train_end
  factory.kwargs['test_start'] = FLAGS.test_start
  factory.kwargs['test_end'] = FLAGS.test_end
  dataset = factory()

  adv_x_list = [np.load(filepath) for filepath in adv_x_filepaths]
  x, y = dataset.get_set(FLAGS.which_set)
  for adv_x in adv_x_list:
    assert adv_x.shape == x.shape, (adv_x.shape, x.shape)
    # Make sure these were made for the right dataset with right scaling
    # arguments, etc.
    assert adv_x.min() >= 0. - dataset.kwargs['center'] * dataset.max_val
    assert adv_x.max() <= dataset.max_val
    data_range = dataset.max_val * (1. + dataset.kwargs['center'])

    if adv_x.max() - adv_x.min() <= .8 * data_range:
      warnings.warn("Something is weird. Your adversarial examples use "
                    "less than 80% of the data range."
                    "This might mean you generated them for a model with "
                    "inputs in [0, 1] and are now using them for a model "
                    "with inputs in [0, 255] or something like that. "
                    "Or it could be OK if you're evaluating on a very small "
                    "batch.")

  report_path = FLAGS.report_path
  if report_path is None:
    suffix = "_bundled_examples_report.joblib"
    assert model_filepath.endswith('.joblib')
    report_path = model_filepath[:-len('.joblib')] + suffix

  goal = MaxConfidence()
  bundle_examples_with_goal(sess, model, adv_x_list, y, goal,
                            report_path, batch_size=FLAGS.batch_size)
157534
def _save_junit(self):
        
        report = ReportJunit(self)
        file_name = report.get_latest_filename("result.junit.xml", "")
        report.generate(file_name)

        file_name = report.get_latest_filename("junit.xml", "../")
        report.generate(file_name)
537962
def main(argv=None):
  
  try:
    _name_of_script, filepath = argv
  except ValueError:
    raise ValueError(argv)
  print(filepath)
  make_confidence_report_bundled(filepath=filepath,
                                 test_start=FLAGS.test_start,
                                 test_end=FLAGS.test_end,
                                 which_set=FLAGS.which_set,
                                 recipe=FLAGS.recipe,
                                 report_path=FLAGS.report_path, batch_size=FLAGS.batch_size)
638996
def save_assessment_taken(self, assessment_taken_form, *args, **kwargs):
        """"""
        # Implemented from kitosid template for -
        # osid.resource.ResourceAdminSession.update_resource
        if assessment_taken_form.is_for_update():
            return self.update_assessment_taken(assessment_taken_form, *args, **kwargs)
        else:
            return self.create_assessment_taken(assessment_taken_form, *args, **kwargs)
852465
def create(cls, result_id=None, summary=None, file_modified_at=None):
        """"""
        asset = cls(result_id, summary, file_modified_at)

        db.session.add(asset)
        db.session.commit()

        return asset
1001067
def save(self,
             data,
             chart_type,
             options=None,
             filename='chart',
             w=800,
             h=420,
             overwrite=True):
        """"""
        html = self.render(
            data=data,
            chart_type=chart_type,
            options=options,
            div_id=filename,
            head=self.head,
            w=w,
            h=h)

        if overwrite:
            with open(filename.replace(" ", "_") + '.html', 'w') as f:
                f.write(html)
        else:
            if not os.path.exists(filename.replace(" ", "_") + '.html'):
                with open(filename.replace(" ", "_") + '.html', 'w') as f:
                    f.write(html)
            else:
                raise IOError('File Already Exists!')
895644
def save_state(self):
        """"""
        set_setting('lastSourceDir', self.source_directory.text())
        set_setting('lastOutputDir', self.output_directory.text())
        set_setting(
            'useDefaultOutputDir', self.scenario_directory_radio.isChecked())
965325
def save_to_file(self,
                     file_path,
                     labels=None,
                     predict_proba=True,
                     show_predicted_value=True,
                     **kwargs):
        
        file_ = open(file_path, 'w', encoding='utf8')
        file_.write(self.as_html(labels=labels,
                                 predict_proba=predict_proba,
                                 show_predicted_value=show_predicted_value,
                                 **kwargs))
        file_.close()
1146839
def store(self, completed_task, resultsdir):
        """"""

        with working_directory(resultsdir):
            _logger.info('storing result')
            return completed_task.store(self)
163506
def create_result(self, local_path, container_path, permissions, meta, val, dividers):
        """"""
        if permissions is NotSpecified:
            permissions = 'rw'
        return Mount(local_path, container_path, permissions)
1299800
def save(self, heads, console=True):
        
        # Junit
        self._save_junit()
        # HTML
        self._save_html_report(heads)
        if console:
            # Console print
            self._print_console_summary()
90365
def report(data):
    """"""
    work_dir = dd.get_work_dir(data[0][0])
    out_dir = op.join(work_dir, "report")
    safe_makedir(out_dir)
    summary_file = op.join(out_dir, "summary.csv")
    with file_transaction(summary_file) as out_tx:
        with open(out_tx, 'w') as out_handle:
            out_handle.write("sample_id,%s\n" % _guess_header(data[0][0]))
            for sample in data:
                info = sample[0]
                group = _guess_group(info)
                files = info["seqbuster"] if "seqbuster" in info else "None"
                out_handle.write(",".join([dd.get_sample_name(info),
                                           group]) + "\n")
    _modify_report(work_dir, out_dir)
    return summary_file
43648
def dump(self):
        """"""
        text = ''

        for result in self.objects:
            if result.is_failure or result.is_error:
                text += '\n#{red}#{bright}'
                text += '{}\n'.format(''.ljust(79, '='))

                status = 'FAILED' if result.is_failure else 'ERROR'
                text += '{}: {}\n'.format(status, result.process)
                text += '{}\n#{{reset_all}}'.format(''.ljust(79, '='))

                if result.output:
                    text += result.output

                if result.error:
                    if result.output:
                        text += '\n{}\n'.format(''.ljust(79, '-'))
                        text += 'Additional error output:\n'
                        text += '{}\n'.format(''.ljust(79, '-'))
                    text += result.error

                if not text.endswith('\n'):
                    text += '\n'

        if self.has_modified_files:
            text += '\n#{{yellow}}#{{bright}}{}\n'.format(''.ljust(79, '-'))
            text += 'Modified files:\n'
            text += '{}\n'.format(''.ljust(79, '-'))
            for path, modified_by in self.modified_files:
                text += '#{{reset_all}}{} #{{cyan}}<- {}\n'.format(path, ', '.join(modified_by))

        return text
1157254
def save_files(self):
        """"""
        while True:
            try:
                os.mkdir(self.output_name)
            except Exception as e:
                self.output_name = raw_input("This directory already exists - please enter a new name:")
            else:
                break
        self.workdir = os.getcwd()
        os.chdir(self.workdir+"/"+self.output_name)
1144152
def save_report_to_html(self):
        """"""
        html = self.page().mainFrame().toHtml()
        if self.report_path is not None:
            html_to_file(html, self.report_path)
        else:
            msg = self.tr('report_path is not set')
            raise InvalidParameterError(msg)
429062
def new_percent_saved(report_stats):
    """"""
    size_in = report_stats.bytes_in
    if size_in > 0:
        size_out = report_stats.bytes_out
        ratio = size_out / size_in
        kb_saved = _humanize_bytes(size_in - size_out)
    else:
        ratio = 0
        kb_saved = 0
    percent_saved = (1 - ratio) * 100

    result = '{:.{prec}f}% ({})'.format(percent_saved, kb_saved, prec=2)
    return result
1111815
def save(self):
        """"""
        file_name = fd.asksaveasfilename()
        if file_name is "" or file_name is None:
            return
        with open(file_name, "w") as f:
            f.write(self.text.get("1.0", tk.END))