Skip to content

Instantly share code, notes, and snippets.

View MitI-7's full-sized avatar

MitI_7 MitI-7

View GitHub Profile
// 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;
@halegreen
halegreen / FFM.py
Created November 17, 2017 02:44
Python implementation of Field-aware Factorization Machine Model
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)
@kalaidin
kalaidin / fm_lr.py
Created May 28, 2015 22:11
Logistic regression + Factorization machines + SGD
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):