This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class PrepareCalculationForB2BManager | |
def prepare(quotation) | |
CalculationForB2BManager.new( | |
quotation.yearly_premium_value, | |
quotation.yearly_offer_number, | |
quotation.yearly_premium_url, | |
quotation.position_in_leads, | |
quotation.token, | |
quotation.save_quote_key, | |
quotation.competitors |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def iteratorAtomsDepleted(iteratorAtoms): | |
return all(map(lambda iteratorAtom: iteratorAtom[1], iteratorAtoms)) | |
def combine(*args): | |
listIterators = [[iter(passedList), False] for passedList in args] | |
result = [] | |
while (not iteratorAtomsDepleted(listIterators)): | |
for index, iteratorAtom in enumerate(listIterators): | |
try: | |
iterator, alreadyDone = iteratorAtom |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# M1 (N x A) -> M2 (N x B) -> DM (A x B) | |
def ComputeDistanceMatrix(M1, M2): | |
# For each r-th row: Sum(k = 1, N) M1(r, k) ** 2 | |
SM1 = np.sum(M1 ** 2) | |
# For each r-th row: Sum(k = 1, N) M2(r, k) ** 2 | |
SM2 = np.sum(M2 ** 2) | |
# The last term: 2 * (M1 x M2^T) | |
M1M2_2 = 2 * np.dot(M1, M2.T) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const loginUnsuccessful = this.state.alert === "User Not Found"; | |
classNames("alert", "alert-dismissable", { | |
"alert-danger": loginUnsuccessful | |
"alert-success": !loginUnsuccessful | |
}); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from collections import Counter | |
for label in set(group_labels): | |
train_mask = group_labels == label | |
real_labels = train_labels[train_mask] | |
pos_stat = Counter(real_labels).values() | |
# pos_stat is info about quantity of each label - as a list of quantities |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
For label 0: 0.867669753086 | |
For label 1: 0.82792603512 | |
For label 2: 0.878846730532 | |
For label 3: 0.795057662006 | |
For label 4: 0.886658781769 | |
For label 5: 0.882785618599 | |
For label 6: 0.840796804795 | |
For label 7: 0.864856124316 | |
For label 8: 0.869239583546 | |
For label 9: 0.877142283582 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
For label 0: 0.865175145618 | |
Representative: [ 0.] | |
====== | |
For label 1: 0.869355945887 | |
Representative: [ 6.] | |
====== | |
For label 2: 0.828103005511 | |
Representative: [ 0.] | |
====== | |
For label 3: 0.886468632048 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from fuel.datasets.cifar10 import CIFAR10 | |
from sklearn.cluster import KMeans | |
from collections import Counter | |
from scipy.stats.mstats import mode | |
import numpy as np | |
def PerformKMeansAnalysis(train_data, train_labels, test_data, test_labels): | |
naive_grouping = KMeans(n_clusters=10, n_init=5, n_jobs=8) | |
naive_grouping.fit(train_data) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
svc = SGDClassifier(loss='squared_hinge', verbose=1, n_jobs=8, n_iter=100) | |
svc.fit(train_data, train_labels) | |
predictions = svc.predict(validation_data) | |
wrong = np.nonzero(validation_labels - predictions)[0].astype(np.float).shape[0] | |
print (float(wrong) / predictions.shape[0]) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
view.instance().populateSubnavigation(secondaryURLMapOne); | |
const secondaryNav = view.find(".navbar-rt-secondary"); | |
const navItems = secondaryNav.find(NavItem); | |
assert.equal(1, navItems.length); |