def test_train_small_bootstrap_multi_target(small_moddata, tf_session): """Tests the multi-target training.""" from modnet.models import EnsembleMODNetModel data = small_moddata # set 'optimal' features manually data.optimal_features = [ col for col in data.df_featurized.columns if col.startswith("ElementProperty") ] model = EnsembleMODNetModel( [[["eform", "egap"]]], weights={ "eform": 1, "egap": 1 }, num_neurons=[[16], [8], [8], [4]], n_feat=10, n_models=3, bootstrap=True, ) model.fit(data, epochs=5) model.predict(data, return_unc=True)
def test_train_small_bootstrap_single_target_classif(small_moddata, tf_session): """Tests the single target training.""" from modnet.models import EnsembleMODNetModel data = small_moddata # set 'optimal' features manually data.optimal_features = [ col for col in data.df_featurized.columns if col.startswith("ElementProperty") ] def is_metal(egap): if egap == 0: return 1 else: return 0 data.df_targets["is_metal"] = data.df_targets["egap"].apply(is_metal) model = EnsembleMODNetModel( [[["is_metal"]]], weights={"is_metal": 1}, num_neurons=[[16], [8], [8], [4]], num_classes={"is_metal": 2}, n_feat=10, n_models=3, bootstrap=True, ) model.fit(data, epochs=5) model.predict(data) model.predict(data, return_unc=True)