

@interactive
def train_model(model, data_filename, model_filename=None, random_state=None):
    from sklearn.externals import joblib
    (X, y, sample_weight) = joblib.load(data_filename, mmap_mode='r')
    model.set_params(random_state=random_state)
    if (sample_weight is not None):
        model.fit(X, y, sample_weight=sample_weight)
    else:
        model.fit(X, y)
    for estimator in model.estimators_:
        if (hasattr(estimator, 'tree_') and hasattr(estimator.tree_, 'random_state')):
            estimator.tree_.random_state = 0
    if (model_filename is not None):
        joblib.dump(model, model_filename)
        return model_filename
    return model

dataset/ETHPy150Open pydata/pyrallel/pyrallel/ensemble.py train_model/original