Skip to content

Instantly share code, notes, and snippets.

@maruware
Created October 30, 2015 05:23
Show Gist options
  • Save maruware/6854972955ffdf384434 to your computer and use it in GitHub Desktop.
Save maruware/6854972955ffdf384434 to your computer and use it in GitHub Desktop.
Enigma on GridSearchCV & requests
# -*- coding: utf-8 -*-
from sklearn.grid_search import GridSearchCV
from sklearn.linear_model import LogisticRegression
import requests
import numpy as np
import random
sample_num = 1400
dimension = 100
#Add request
requests.get('http://google.com')
X = []
y = []
for i in range(0, sample_num):
x = []
for j in range(0, dimension):
x.append(random.random())
X.append(x)
y.append(i%2)
print('start gscv')
tuned_parameters = [{'C': [10]}]
gscv = GridSearchCV(LogisticRegression(class_weight='auto'), tuned_parameters, cv=2, n_jobs=-1)
gscv.fit(X, y)
print('finished')
# -*- coding: utf-8 -*-
from sklearn.grid_search import GridSearchCV
from sklearn.linear_model import LogisticRegression
import requests
import numpy as np
import random
sample_num = 1400
dimension = 100
# requests.get('http://google.com')
X = []
y = []
for i in range(0, sample_num):
x = []
for j in range(0, dimension):
x.append(random.random())
X.append(x)
y.append(i%2)
print('start gscv')
tuned_parameters = [{'C': [10]}]
gscv = GridSearchCV(LogisticRegression(class_weight='auto'), tuned_parameters, cv=2, n_jobs=-1)
gscv.fit(X, y)
print('finished')
# -*- coding: utf-8 -*-
from sklearn.grid_search import GridSearchCV
from sklearn.linear_model import LogisticRegression
import requests
import numpy as np
import random
sample_num = 1300 # Decrease from 1400
dimension = 100
requests.get('http://google.com')
X = []
y = []
for i in range(0, sample_num):
x = []
for j in range(0, dimension):
x.append(random.random())
X.append(x)
y.append(i%2)
print('start gscv')
tuned_parameters = [{'C': [10]}]
gscv = GridSearchCV(LogisticRegression(class_weight='auto'), tuned_parameters, cv=2, n_jobs=-1)
gscv.fit(X, y)
print('finished')
# -*- coding: utf-8 -*-
from sklearn.grid_search import GridSearchCV
from sklearn.linear_model import LogisticRegression
import requests
import numpy as np
import random
sample_num = 1400
dimension = 100
requests.get('http://google.com')
X = []
y = []
for i in range(0, sample_num):
x = []
for j in range(0, dimension):
x.append(random.random())
X.append(x)
y.append(i%2)
print('start gscv')
tuned_parameters = [{'C': [10]}]
gscv = GridSearchCV(LogisticRegression(class_weight='auto'), tuned_parameters, cv=2) # Delete n_jobs
gscv.fit(X, y)
print('finished')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment