Пример #1
0
def update(dbname, configfile, bbox=None):
    """Fetch datasets and update database."""
    conf = datasets.readDatasetList(configfile)
    try:
        bbox = map(lambda s: conf.getfloat('domain', s), [
                   'minlon', 'minlat', 'maxlon', 'maxlat'])
    except:
        bbox = None
    for name in conf.sections():
        if name != 'domain':
            try:
                mod = __import__("datasets.{0}".format(name), fromlist=[name])
            except:
                mod = None
            if mod is None:
                # download generic datasets
                datasets.download(name, dbname, bbox)
            else:
                dt = mod.dates(dbname)
                mod.download(dbname, dt, bbox)
Пример #2
0
def update(dbname, configfile, bbox=None):
    """Fetch datasets and update database."""
    conf = datasets.readDatasetList(configfile)
    try:
        bbox = map(lambda s: conf.getfloat('domain', s), [
                   'minlon', 'minlat', 'maxlon', 'maxlat'])
    except:
        bbox = None
    for name in conf.sections():
        if name != 'domain':
            try:
                mod = __import__("datasets.{0}".format(name), fromlist=[name])
            except:
                mod = None
            if mod is None:
                # download generic datasets
                datasets.download(name, dbname, bbox)
            else:
                if conf.has_option(name, 'startdate'):
                    t0 = datetime.strptime(conf.get(name, 'startdate'), "%Y-%m-%d")
                else:
                    t0 = None
                if conf.has_option(name, 'enddate'):
                    t1 = datetime.strptime(conf.get(name, 'enddate'), "%Y-%m-%d")
                else:
                    t1 = None
                dt = mod.dates(dbname)
                if t0 is None:
                    if dt is None:
                        print("WARNING! Date information for {0} not found in the database or data.conf. Please add a startdate in the data.conf file.")
                    else:
                        if t1 is not None:
                            dt = (dt[0], t1)
                else:
                    if t1 is None:
                        dt = (t0, dt[1])
                    else:
                        dt = (t0, t1)
                if dt is not None:
                    mod.download(dbname, dt, bbox)
Пример #3
0
def update(dbname, configfile):
    """Fetch datasets and update database."""
    log = logging.getLogger(__name__)
    conf = datasets.readDatasetList(configfile)
    try:
        bbox = map(lambda s: conf.getfloat('domain', s),
                   ['minlon', 'minlat', 'maxlon', 'maxlat'])
    except:
        bbox = None
    for name in conf.sections():
        if name != 'domain':
            try:
                mod = __import__("datasets.{0}".format(name), fromlist=[name])
            except:
                mod = None
            if conf.has_option(name, 'startdate'):
                t0 = datetime.strptime(conf.get(name, 'startdate'), "%Y-%m-%d")
            else:
                t0 = None
            if conf.has_option(name, 'enddate'):
                t1 = datetime.strptime(conf.get(name, 'enddate'), "%Y-%m-%d")
            else:
                t1 = datetime.today()
            if mod is None:
                # download generic datasets
                datasets.download(dbname, (t0, t1), bbox, conf, name)
            else:
                dt = mod.dates(dbname)
                if t0 is None:
                    if dt is None:
                        log.warning(
                            "Date information for {0} not found in the database or data.conf. Please add a startdate in the data.conf file."
                            .format(name))
                    else:
                        dt = (dt[0], t1)
                else:
                    dt = (t0, t1)
                if dt is not None:
                    mod.download(dbname, dt, bbox)
Пример #4
0
        "class-values"
    ],
    "pima": [
        "times-pregnant", "glucose-concentration", "diastolic-blood-pressure",
        "triceps-skin-thickness", "two-hour-insulin", "bmi",
        "diabetes-pedigree-function", "age", "class-variable"
    ],
    "mpg": [
        "mpg", "cylinders", "displacement", "horsepower", "weight",
        "acceleration", "model-year", "origin", "car-name"
    ]
}

# Loading Data into program

download()

datas = load(cols)
iris = load_iris()

# testing iris

irisDF = pd.DataFrame(data=np.c_[iris['data'], iris['target']],
                      columns=iris['feature_names'] + ['target'])

print("Iris Dataset")

calculate_accuracy(irisDF, "target")

# cars