text_plain_output_1.png
from cuml.svm import SVR

import numpy as np

import pandas as pd

import random

data_types_dict = {'time_id': 'int16', 'investment_id': 'int16', 'target': 'float32'}
features = [f'f_{i}' for i in range(300)]
for f in features:
    data_types_dict[f] = 'float32'
train = pd.read_csv('../input/ubiquant-market-prediction/train.csv', usecols=data_types_dict.keys(), dtype=data_types_dict)

N_DEVIDE_DATA = 20
n_row = len(train)
idx_list = list(range(n_row))
random.shuffle(idx_list)

models = []
for i in range(N_DEVIDE_DATA - 1):
    start_idx = int(n_row / N_DEVIDE_DATA) * i
    end_idx = int(n_row / N_DEVIDE_DATA) * (i + 1)
    devide_idx_list = idx_list[start_idx:end_idx]
    tr = train.iloc[devide_idx_list]
    X = tr[features].to_numpy()
    y = tr['target'].to_numpy()
    model = SVR(C=5.0, kernel='rbf', epsilon=0.1)
    model.fit(X, y)
    r2 = model.score(X, y)
    models.append(model)

start_idx = int(n_row / N_DEVIDE_DATA) * 19
devide_idx_list = idx_list[start_idx:]
test = train.iloc[devide_idx_list]
X_test = test[features].to_numpy()
y_test = test['target'].to_numpy()
pre_y = 0
for model in models:
    pre_y += model.predict(X_test)
pre_y /= len(models)

np.corrcoef(y_test.tolist(), pre_y.tolist())