示例#1
0
def LATITUDE(instanceCLASS):
    instanceCLASS = val(instanceCLASS)
    instanceCLASS = instanceCLASS.split()  # convert to list
    instanceRES = pd.DataFrame(instanceCLASS, columns=['CODDEPAL'])
    COOR_DEP2["CODDEPAL"] = COOR_DEP2["CODDEPAL"].astype('object')
    COOR_DEP2["CODDEPAL"] = COOR_DEP2["CODDEPAL"].apply(
        lambda x: prepare_text.formatingText(x))
    COOR_DEP2["CODDEPAL"] = COOR_DEP2["CODDEPAL"].apply(
        lambda x: prepare_text.deletestopwords(x))
    COOR_DEP2['CODDEPAL'] = COOR_DEP2['CODDEPAL'].astype(str)
    COOR_DEP2["CODDEPAL"] = COOR_DEP2["CODDEPAL"].apply(
        lambda x: prepare_text.formatingText(x))
    #COOR_DEP2.head(3)
    instanceRES = pd.merge(instanceRES, COOR_DEP2, on='CODDEPAL')
    #instanceRES
    lat = instanceRES['DEPlatitude'][0]
    return lat
示例#2
0
def MODELOREGION(inst, loaded_model):
    instanceCLASS = ''
    if pd.notnull(inst):
        # Se limpia el texto para ingresar al modelo
        inst = prepare_text.formatingText(inst)
        inst = prepare_text.deletestopwords(inst)
        inst = ' '.join(inst)
        #inst = formatingText(inst)
        inst = prepare_text.onlyWORDS(inst, stop_mundep)
        inst = ' '.join(inst)
        instance = inst
        ###### CARGAR AL MODELO LAS PALABRAS
        instance_pred = loaded_model.predict(
            newprediction(instance, 9, tokenizer))
        instance_pred = prepare_text.convertprobtobin(instance_pred, 0.30)
        instanceCLASS = lemod.inverse_transform(instance_pred)
        instanceCLASS = str(instanceCLASS).strip('[()]')
        instanceCLASS = prepare_text.formatingText(instanceCLASS)
    return instanceCLASS
示例#3
0
def MODELODEPARTAMENTO(inst, modeloDepart):
    instanceCLASS = ''
    if pd.notnull(inst):
        # Se limpia el texto para ingresar al modelo
        inst = prepare_text.formatingText(inst)
        inst = prepare_text.deletestopwords(inst)
        inst = ' '.join(inst)
        #inst = formatingText(inst)
        inst = prepare_text.onlyWORDS(inst, stop_mundep)
        inst = ' '.join(inst)
        instance = inst
        ###### CARGAR AL MODELO LAS PALABRAS
        #        instance_pred = loaded_modelDEP.predict(newpredictionDEP(instance,9,tokenizerDEP))
        #        modeloDepart = find_location.modelo_dep()
        instance_pred = modeloDepart.predict(
            newpredictionDEP(instance, 9, tokenizerDEP))
        instance_pred = prepare_text.convertprobtobin(instance_pred, 0.30)
        instanceCLASS = lemodDEP.inverse_transform(instance_pred)
        instanceCLASS = str(instanceCLASS).strip('[()]')
        instanceCLASS = prepare_text.formatingText(instanceCLASS)
    return instanceCLASS
示例#4
0
    return lat


#### CARGAR EL MODELO

##  Se crean las categorias para el modelo
## Dataframe with the name of categories
data = {
    'CODRegionlist2':
    ['amazonia', 'andina', 'caribe', 'orinoquia', 'pacifico']
}
df = pd.DataFrame(data, columns=['CODRegionlist2'])

df["CODRegionlist2"] = df["CODRegionlist2"].astype('object')
df["CODRegionlist2"] = df["CODRegionlist2"].apply(
    lambda x: prepare_text.formatingText(x))
df["CODRegionlist2"] = df["CODRegionlist2"].apply(
    lambda x: prepare_text.deletestopwords(x))
df['CODRegionlist2'] = df['CODRegionlist2'].astype(str)
df['CODRegionlist2'] = df['CODRegionlist2'].map(lambda x: eval(x))

## leer archivo spara el modelo
### CARGAR BIBLIOTECA DE MUNICIPIOS Y DEPARTAMENTO
with open('ModReg/stop_mundep.txt', 'rb') as fp:
    list_1 = pickle.load(fp)
stop_mundep = list_1

# loading CARGAR EL ARCHIVO DEL TOKENIZER
with open('ModReg/tokenizermundep.pickle', 'rb') as handle:
    tokenizer = pickle.load(handle)