def get_positives_stat(channel):

    X, y = get_data(channel)
    print('# of ' + channel + ' frames = ' + str(X.shape[0]))
    percent_positives = 100 * float(len(filter(lambda x: x == 1, y))) / len(y)

    print('% of positives on ' + channel + ': ' + str(percent_positives))

    return percent_positives
def get_positives_stat(channel):

    X, y = get_data(channel)
    print('# of ' + channel + ' frames = ' + str(X.shape[0]))
    percent_positives = 100*float(len(filter(lambda x: x == 1, y))) / len(y)

    print('% of positives on ' + channel + ': ' + str(percent_positives))

    return percent_positives
def main():
    X_BBC, y_BBC = get_data('BBC')
    X_CNN, y_CNN = get_data('CNN')
    print('# of BBC frames = ' + str(X_BBC.shape[0]))
    print('# of CNN frames = ' + str(X_CNN.shape[0]))

    clf = SVC(C=0.5, cache_size=2000, class_weight='auto', kernel='linear')
    print('Training...')
    t0 = time.clock()
    clf.fit(X_BBC, y_BBC)
    trainTime = time.clock() - t0

    print('Training time: ' + str(trainTime) + 's\n')
    print('Testing...')
    t0 = time.clock()
    score = clf.score(X_CNN, y_CNN)
    testTime = time.clock() - t0

    print('Testing time: ' + str(testTime) + 's\n')
    print('Total time: ' + str(trainTime + testTime) + 's\n')
    print('score = ' + str(score))
def main():
    X_BBC, y_BBC = get_data('BBC')
    X_CNN, y_CNN = get_data('CNN')
    print('# of BBC frames = ' + str(X_BBC.shape[0]))
    print('# of CNN frames = ' + str(X_CNN.shape[0]))

    clf = SVC(C=0.5, cache_size=2000, class_weight='auto', kernel='linear')
    print('Training...')
    t0 = time.clock()
    clf.fit(X_BBC, y_BBC)
    trainTime = time.clock() - t0

    print('Training time: ' + str(trainTime) + 's\n')
    print('Testing...')
    t0 = time.clock()
    score = clf.score(X_CNN, y_CNN)
    testTime = time.clock() - t0

    print('Testing time: ' + str(testTime) + 's\n')
    print('Total time: ' + str(trainTime + testTime) + 's\n')
    print('score = ' + str(score))
def main():
    X_BBC, y_BBC = get_data('BBC')
    X_CNN, y_CNN = get_data('CNN')
    print('# of BBC frames = ' + str(X_BBC.shape[0]))
    print('# of CNN frames = ' + str(X_CNN.shape[0]))

    clf = RandomForestClassifier(n_estimators=10)
    print('Training...')

    t0 = time.clock()
    clf.fit(X_BBC, y_BBC)
    trainTime = time.clock() - t0

    print('Training time: ' + str(trainTime) + 's\n')
    print('Testing...')
    t0 = time.clock()
    score = clf.score(X_CNN, y_CNN)
    testTime = time.clock() - t0

    print('Testing time: ' + str(testTime) + 's\n')
    print('Total time: ' + str(trainTime + testTime) + 's\n')
    print('score = ' + str(score))
def main():
    X_BBC, y_BBC = get_data('BBC')
    X_CNN, y_CNN = get_data('CNN')
    print('# of BBC frames = ' + str(X_BBC.shape[0]))
    print('# of CNN frames = ' + str(X_CNN.shape[0]))

    clf = RandomForestClassifier(n_estimators=10)
    print('Training...')

    t0 = time.clock()
    clf.fit(X_BBC, y_BBC)
    trainTime = time.clock() - t0

    print('Training time: ' + str(trainTime) + 's\n')
    print('Testing...')
    t0 = time.clock()
    score = clf.score(X_CNN, y_CNN)
    testTime = time.clock() - t0

    print('Testing time: ' + str(testTime) + 's\n')
    print('Total time: ' + str(trainTime + testTime) + 's\n')
    print('score = ' + str(score))
示例#7
0
def main():
    X_BBC, y_BBC = get_data('BBC')
    X_CNN, y_CNN = get_data('CNN')
    print('# of BBC frames = ' + str(X_BBC.shape[0]))
    print('# of CNN frames = ' + str(X_CNN.shape[0]))

    clf = LDA()
    print('Training...')

    t0 = time.clock()
    clf.fit(X_BBC.toarray(), y_BBC)
    trainTime = time.clock() - t0

    print('Training time: ' + str(trainTime) + 's\n')
    print('Testing...')

    t0 = time.clock()
    score = clf.score(X_CNN.toarray(), y_CNN)
    testTime = time.clock() - t0

    print('Testing time: ' + str(testTime) + 's\n')
    print('Total time: ' + str(trainTime + testTime) + 's\n')
    print('score = ' + str(score))
def main():
    X_BBC, y_BBC = get_data('BBC')
    X_CNN, y_CNN = get_data('CNN')
    print('# of BBC frames = ' + str(X_BBC.shape[0]))
    print('# of CNN frames = ' + str(X_CNN.shape[0]))

    clf = LDA()
    print('Training...')

    t0 = time.clock()
    clf.fit(X_BBC.toarray(), y_BBC)
    trainTime = time.clock() - t0

    print('Training time: ' + str(trainTime) + 's\n')
    print('Testing...')

    t0 = time.clock()
    score = clf.score(X_CNN.toarray(), y_CNN)
    testTime = time.clock() - t0

    print('Testing time: ' + str(testTime) + 's\n')
    print('Total time: ' + str(trainTime + testTime) + 's\n')
    print('score = ' + str(score))
示例#9
0
def main():
	n_neighbors = 5

	XB, yB = get_data('BBC')
	XC, yC = get_data('CNN')

	print 'Number of BBC frames = ' + str(XB.shape[0]) + '\n'
	print 'Number of CNN frames = ' + str(XC.shape[0])

	clf = neighbors.KNeighborsClassifier(n_neighbors)
	print('Training...')
	t0 = time.clock()
	clf.fit(XB, yB)
	trainTime = time.clock() - t0

	print('Training time: ' + str(trainTime) + 's\n')

	print('Testing...')
	t0 = time.clock()
	score = clf.score(XC[:10000], yC[:10000])
	testTime = time.clock() - t0
	print('Testing time: ' + str(testTime) + 's\n')
	print('Total time: ' + str(trainTime + testTime) + 's\n')
	print 'score = ' + str(score)