<jupyter_start><jupyter_text>Classes:* -1: walking (original classes 1, 2, 3)* 1: other classes<jupyter_code>device = "cuda"

def load_subset(subset):
    X = []
    with open(f"../UCI HAR Dataset/{subset}/X_{subset}.txt") as f:
        for line in f:
            X.append([float(x) for x in line.split()])
    with open(f"../UCI HAR Dataset/{subset}/y_{subset}.txt") as f:
        y = [int(x) for x in f]
    y = np.array(y)
    return np.array(X), np.where(y <= 3, -1, 1)

X_train, y_train = load_subset("train")
X_test, y_test = load_subset("test")
X_train.shape, X_test.shape
np.unique(y_train, return_counts=True)
np.unique(y_test, return_counts=True)
X_train = torch.tensor(X_train, device=device)
X_test = torch.tensor(X_test, device=device)
y_train = torch.tensor(y_train, device=device)
y_test = torch.tensor(y_test, device=device)
model = LogisticRegression(X_train, y_train, 1e-2, device=device)
model.fit(1e-5, max_iter=100500)
len(model.log)
preds = model.predict(X_test)
torch.mean((preds == y_test).double())
model.new_objective(X_train.cpu(), y_train.cpu(), 1e-2, device="cpu")
experiment = RestartingExperiment(model, 5, device="cpu")
n = 1000
experiment.run_method("RRE+QR", RRE, n, {"qr": True})
experiment.run_method("RNA", RNA, n, {"lambda_range": (1e-15, 1e-2), "linesearch": False, "norm": False})
experiment.run_method("RNA+norm", RNA, n, {"lambda_range": (1e-15, 1e-2), "linesearch": False})
experiment.run_method("RNA+ls", RNA, n, {"lambda_range": (1e-15, 1e-2), "linesearch": True})
experiment.plot_values(n=3000, figsize=(12, 10), ylim=(None, 200))
experiment.plot_log_diff(n=3000, figsize=(12, 10), ylim=(None, 2))<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.1852958756724447, 'fraction_numerical': 0.03586371787208607, 'mean_word_length': 5.590551181102362, 'pattern_counts': {'":': 8, '<': 6, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '1', 'dir': 'jupyter-structured-clean-dedup', 'id': '280976', 'license': 'MIT', 'n_tokens_mistral': 708, 'n_tokens_neox': 659, 'n_words': 137, 'path': 'notebooks/logistic regression/uci-har-restarts.ipynb', 'repo_name': 'JaworWr/MLAcceleration', 'size': '1673'}