Skip to content

Instantly share code, notes, and snippets.

@joshreini1
Created October 7, 2022 20:26
Show Gist options
  • Save joshreini1/235e20285c1c896e0a146ccb5174f952 to your computer and use it in GitHub Desktop.
Save joshreini1/235e20285c1c896e0a146ccb5174f952 to your computer and use it in GitHub Desktop.
models = {}
import time
for window_size in range(1,11):
time_start = time.time()
key = f'{window_size}year_window'
print(f'Training linear model for {key}')
models[f'linear_{key}'] = LogisticRegression(random_state=321, max_iter=1000, solver='saga').fit(data_train_x[key], data_train_y[key]>0.01)
n_est = 20
print(f'Training gb{n_est} model for {key}')
models[f'gb_{n_est}_{key}'] = GradientBoostingClassifier(random_state=321, n_estimators=n_est).fit(data_train_x[key], data_train_y[key]>0.01)
n_est = 200
print(f'Training gb{n_est} model for {key}')
models[f'gb_{n_est}_{key}'] = GradientBoostingClassifier(random_state=321, n_estimators=n_est).fit(data_train_x[key], data_train_y[key]>0.01)
c_weight = 30
print(f'Training SVC{c_weight} mdoel for {key}')
models[f'SVC{c_weight}_{key}'] = SVC(random_state=321, probability=True, class_weight = {0:1.0, 1:c_weight}).fit(data_train_x[key], data_train_y[key]>0.01)
c_weight = 300
print(f'Training SVC{c_weight} model for {key}')
models[f'SVC{c_weight}_{key}'] = SVC(random_state=321, probability=True, class_weight = {0:1.0, 1:c_weight}).fit(data_train_x[key], data_train_y[key]>0.01)
print(f'elapsed: {time.time() - time_start}')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment