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
| #! /usr/bin/env python | |
| # -*- coding: utf-8 -*- | |
| import os.path | |
| import shutil | |
| import random | |
| import math | |
| import cPickle | |
| import pickle |
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
| # https://www.kaggle.com/c/otto-group-product-classification-challenge/details/evaluation | |
| def print_kaggle_score(label_list, proba_result): | |
| label_index = sorted(list(set(label_list))) | |
| score = - 1.0 / len(label_list) * sum( | |
| [ | |
| math.log( | |
| max(min( | |
| proba_result[i][label_index.index(label_list[i])] | |
| / sum(proba_result[i]) |
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
| #coding:utf-8 | |
| # ε-Greedy base multi-armed bandit | |
| import random | |
| slotmachine_rate = [3, 5, 10, 20, 16, 15, 21, 22, 6] | |
| score_map = [[0.0, 0] for i in xrange(len(slotmachine_rate))] | |
| search_rate = 0.1 |
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
| #coding:utf-8 | |
| import multiprocessing | |
| import traceback | |
| import random | |
| import time | |
| import sys | |
| def random_error_func(x): | |
| n = random.random() |
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
| days, input_load, worker_stacks, total_stacks, output, ave_lead_time | |
| case 100% input 1...6 | |
| 0 2 [2, 0, 0, 0, 0] 2 0 5 | |
| 1 5 [5, 2, 0, 0, 0] 7 0 6 | |
| 2 2 [2, 5, 2, 0, 0] 9 0 6 | |
| 3 3 [3, 5, 2, 2, 0] 12 0 6 | |
| 4 3 [3, 4, 4, 2, 2] 15 0 7 | |
| 5 6 [6, 3, 4, 5, 1] 19 2 8 | |
| 6 1 [4, 3, 6, 1, 5] 19 1 8 | |
| 7 4 [4, 4, 3, 6, 2] 19 4 8 |
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
| #coding: utf-8 | |
| import urllib | |
| import json | |
| import datetime | |
| import os | |
| import time | |
| # http://www.kbremner.com/2014/03/15/kickstarter-part1.html | |
| # https://github.com/markolson/kickscraper/wiki/Project |
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 uniq_two(item_prices, max_price): | |
| bucket = {} | |
| for price in item_prices: | |
| if price > max_price: | |
| continue | |
| if price not in bucket : | |
| bucket[price] = 0 | |
| bucket[price] += 1 | |
| result = [] |
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
| #coding: utf-8 | |
| #python 2.7 | |
| class island_count: | |
| def __init__(self, pattern = None): | |
| self.pattern = None | |
| if pattern: | |
| self.load(pattern) |
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
| Hello=World=None | |
| print dir()[len([])], dir()[len([None])] |
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
| #coding:utf-8 | |
| import random | |
| def amida_shuffle(line_num, exchange_num): | |
| lines = range(line_num) | |
| for i in xrange(exchange_num): | |
| p = random.randrange(line_num - 1) | |
| lines[p], lines[p+1] = lines[p+1], lines[p] | |
| return lines |