def predict_model(train_x, train_y, test_x, test_y=None, class_weights=None, random_state=0): # Learn the ProbMC model params = {'n_jobs':-1, 'random_state':random_state, 'n_estimators':1000, 'max_features':0.75, 'min_samples_leaf':1} model = fp.PMC_MultiTaskExtraTreesRegressor(train_y.shape[1], bags=1, params=params) sample_weight = None model.fit(train_x, train_y, sample_weight) # Predict on the test instances test_predicted = model.predict_proba(test_x) # Learn the ProbMC model params = {'n_jobs':12, 'random_state':random_state, 'n_estimators':1000, 'max_features':0.45, 'min_samples_leaf':1} model = fp.PMC_MultiTaskExtraTreesRegressor(train_y.shape[1], bags=1, params=params) sample_weight = None model.fit(train_x, train_y, sample_weight) # Predict on the test instances test_predicted = test_predicted + model.predict_proba(test_x) return(test_predicted / 2)
def predict_model(train_x, train_y, test_x, test_y=None, class_weights=None, random_state=0): # Learn the ProbMC model params = { 'n_jobs': -1, 'random_state': random_state, 'bootstrap': False, 'n_estimators': 250, 'max_features': 0.25, 'min_samples_leaf': 3 } model = fp.PMC_MultiTaskExtraTreesRegressor(train_y.shape[1], bags=1, params=params) sample_weight = np.dot(np.power(train_y + 1, -1), np.power(class_weights, -1)) model.fit(train_x, train_y, sample_weight) # Predict on the test instances test_predicted = model.predict_proba(test_x) return (test_predicted)