-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstart.py
More file actions
37 lines (26 loc) · 1.03 KB
/
start.py
File metadata and controls
37 lines (26 loc) · 1.03 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
import numpy as np
import pandas as pd
from kernels import SpectrumKernel
from svc import KernelSVC
#%%
Y = []
for i in range(3):
df_X = pd.read_csv("data-challenge-kernel-methods-2024-2025/Xtr" + str(i) + ".csv")
df_Y = pd.read_csv("data-challenge-kernel-methods-2024-2025/Ytr" + str(i) + ".csv")
X_train_seq = list(df_X["seq"])
y_train = np.array(df_Y["Bound"])
y_train = np.where(y_train == 1, 1, -1)
##########
kernel = SpectrumKernel(k = 8, X = X_train_seq)
clf = KernelSVC(kernel = kernel, C = 1)
clf.fit(X_train_seq, y_train)
##########
df_X_test = pd.read_csv("data-challenge-kernel-methods-2024-2025/Xte" + str(i) + ".csv")
X_test_seq = list(df_X_test["seq"])
predictions_test = clf.predict(X_test_seq)
predictions_test = np.where(predictions_test == 1, 1, 0)
data = {"Id": df_X_test["Id"], "Bound": predictions_test}
df_Y_test = pd.DataFrame(data = data)
Y.append(df_Y_test)
Y = pd.concat(Y, axis=0)[["Id", "Bound"]]
Y.to_csv("Yte.csv", index = False)