Exemplo n.º 1
0
# pylint: disable=invalid-name,too-many-lines

from typing import Dict, List

from sklearn.ensemble import RandomForestClassifier  # type: ignore

from views.apps.model import api
from views.specs.models import cm
from views.specs.periods import get_periods

rf = RandomForestClassifier(n_jobs=-1, n_estimators=10_000)

# The currently latest model development run id
run_id = "d_2020_04_01"
periods: List[api.Period] = get_periods(run_id=run_id)
steps = [1, 3, 6, 9, 12, 18, 24, 30, 36, 38]

fullsample = api.Downsampling(share_positive=1.0, share_negative=1.0)

cm_sb_vdem_global = api.Model(
    name="cm_sb_vdem_global",
    col_outcome=cm["sb_vdem_global"]["col_outcome"],
    cols_features=cm["sb_vdem_global"]["cols_features"],
    steps=steps,
    outcome_type="prob",
    estimator=rf,
    periods=periods,
    downsampling=fullsample,
    tags=["train_global"],
)
Exemplo n.º 2
0
xgb
crosslevel

]
"""

# pylint: disable=invalid-name

from typing import Dict, List
from views.apps.model.api import Ensemble, Model, Period
from views.specs.periods import get_periods
from . import models_pgm

# The currently latest model development run id
run_id = "d_2020_04_01"
periods: List[Period] = get_periods(run_id=run_id)

models_pgm_sb_prelim: List[Model] = [
    models_pgm.pgm_sb_hist_legacy,
    models_pgm.pgm_sb_allthemes,
    models_pgm.pgm_sb_onset24_100_all,
    models_pgm.pgm_sb_onset24_1_all,
    models_pgm.pgm_sb_pgd_natural,
    models_pgm.pgm_sb_pgd_social,
    models_pgm.pgm_sb_sptime,
]

models_pgm_ns_prelim: List[Model] = [
    models_pgm.pgm_ns_hist_legacy,
    models_pgm.pgm_ns_allthemes,
    models_pgm.pgm_ns_onset24_100_all,
Exemplo n.º 3
0
from views.utils import db, io, data as datautils
from views.utils.data import assign_into_df

from views.apps.pipeline.models_cm import all_cm_models_by_name
from views.apps.pipeline.models_pgm import all_pgm_models_by_name

from sklearn.ensemble import RandomForestClassifier, RandomForestRegressor
for name, dataset in DATASETS.items():
    print(name)

dataset = views.DATASETS["cm_africa_imp_0"]
df = dataset.df

run_id = "d_2020_09_01_prelim"

periods = get_periods(run_id)  # as a list
periods_by_name = get_periods_by_name(run_id)  # as a dict

period_a = periods_by_name["A"]
period_b = periods_by_name["B"]
period_c = periods_by_name["C"]

model_from_pipeline_spec = all_cm_models_by_name["cm_sb_acled_violence"]
model_from_pipeline_spec1 = all_cm_models_by_name["cm_sb_cflong"]
model_from_pipeline_spec2 = all_cm_models_by_name["cm_sb_neibhist"]
model_from_pipeline_spec3 = all_cm_models_by_name["cm_sb_cdummies"]
model_from_pipeline_spec4 = all_cm_models_by_name["cm_sb_acled_protest"]
model_from_pipeline_spec5 = all_cm_models_by_name["cm_sb_reign_coups"]
model_from_pipeline_spec6 = all_cm_models_by_name["cm_sb_icgcw"]
model_from_pipeline_spec7 = all_cm_models_by_name["cm_sb_reign_drought"]
model_from_pipeline_spec8 = all_cm_models_by_name["cm_sb_reign_global"]