Beispiel #1
0
data = np.load('./data/features_data.npy')
target = np.load('./data/features_target.npy')

# Initialize pipeline template.
clf_pipeline = Pipeline([('scaling', RobustScaler())])


# root mean square logarithmic error
def rmsle(y_true, y_pred):
    return np.square(np.log(y_pred + 1) - np.log(y_true + 1)).mean()**0.5


# Select and initialize model.
if args.model == 'rf':
    model = RandomForestRegressor()
    model.name = 'rf'
elif args.model == 'svm':
    model = SVR(kernel='rbf', C=1e3, gamma='auto')
    model.name = 'svm'
elif args.model == 'stacking':
    model.name = 'stacking'
elif args.model == 'gboosting':
    model = GradientBoostingRegressor()
    model.name = 'gboosting'
    with open('./features_all.txt', 'r') as f:
        f_names = list(map(lambda x: x.strip(), f.readlines()))
        f_to_name = {
            'f' + str(idx): f_names[idx]
            for idx in range(len(f_names))
        }
elif args.model == 'logreg':