This file contains 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
// Topcoder Server の時間計測は rdtsc 以外壊れています | |
// 以下のコードで正しく時間計測ができます | |
// サブミットするときに #define LOCAL を消してください | |
#define LOCAL | |
#ifdef LOCAL | |
#include <chrono> | |
inline double getTime() { | |
using namespace std::chrono; | |
return duration_cast<milliseconds>(system_clock::now().time_since_epoch()).count() / 1000.0; |
This file contains 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 datetime import datetime | |
from csv import DictReader | |
from math import exp, log, sqrt,pow | |
import itertools | |
import math | |
from random import random,shuffle,uniform,seed | |
import pickle | |
import sys | |
seed(1024) |
This file contains 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
import numpy as np | |
from math import exp, log | |
""" | |
SGD for logistic loss + factorization machines | |
The code follows this paper: | |
[1] http://www.ics.uci.edu/~smyth/courses/cs277/papers/factorization_machines_with_libFM.pdf | |
""" | |
def sigmoid(x): |