How to use the outcome.make_fake_inspections_all_parcels_cincy function in outcome

To help you get started, we’ve selected a few outcome examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github dssg / cincinnati / model / features / featurebot.py View on Github external
# set the search path, otherwise won't find ST_DWithin()
    cur = con.cursor()
    cur.execute("SET search_path TO {schema}, public;".format(schema=schema))

    # make a new table that contains one row for every parcel in Cincinnati
    # this table has three columns: parcel_id, inspection_date, viol_outcome
    # inspection_date is the one given as a parameter and
    # is the same for all parcels
    if 'parcels_inspections' not in existing_tables:
        logger.info('Creating parcels_inspections table...')

        if inspection_date is None:
            inspections = outcome.generate_labels()
        else:
          if insp_set=='all_inspections':
            inspections = outcome.make_fake_inspections_all_parcels_cincy(inspection_date)
          elif insp_set=='field_test':
            inspections = outcome.load_inspections_from_field_test(inspection_date)

        inspections.to_sql("parcels_inspections", engine, chunksize=50000,
                      if_exists='fail', index=False, schema=schema)
        logging.debug("... table has {} rows".format(len(inspections)))
        #Create an index to make joins with events_Xmonths_* tables faster
        cur.execute('CREATE INDEX ON parcels_inspections (parcel_id);')
        cur.execute('CREATE INDEX ON parcels_inspections (inspection_date);')
        cur.execute('CREATE INDEX ON parcels_inspections (parcel_id, inspection_date);')
        con.commit()
    else:
        logger.info('parcels_inspections table already exists, skipping...')

    for feature in features_to_generate:
        logging.info("Generating {} features".format(feature.table))

outcome

Capture the outcome of Python function calls.

MIT OR Apache-2.0
Latest version published 6 months ago

Package Health Score

82 / 100
Full package analysis