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
# -*- coding: gbk -*- | |
import math | |
def cal_ndcg(r_list, k): | |
idcg = cal_dcg(sorted(r_list, reverse=True), k) | |
if idcg <= 1e-10: | |
return 1.0 | |
return cal_dcg(r_list, k) / idcg |
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
#include <iostream> | |
#include <ctime> | |
#include <random> | |
#include <vector> | |
#include <thread> | |
#include <omp.h> | |
using namespace std; | |
const static int TOTAL_SIZE = 100000; |
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
#ifndef KMEANS_H | |
#define KMEANS_H | |
#include <vector> | |
#include <set> | |
#include <random> | |
#include <ctime> | |
#include <cfloat> | |
#include <cassert> | |
#include <cmath> | |
#include <iostream> |
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
# -*- coding: gbk -*- | |
import numpy as np | |
def foo(x): | |
return x**2 + 2*x + 1 | |
def g(x): | |
return 2*x + 2 |
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
# -*- coding: utf-8 -*- | |
''' | |
Feature vectors are column vectors. | |
X, n * m, n -> feature dim, m -> sample number | |
Y, 1 * m, row vector | |
theta/weight/beta, n * 1, column vector | |
gradient, n * 1, column vector | |
gradient = X * (Y - sigmoid(theta' * X))' |
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
# -*- coding: utf-8 -*- | |
from email.mime.text import MIMEText | |
from email.mime.multipart import MIMEMultipart | |
import smtplib | |
class Message(object): | |
'''Email util.''' | |
def __init__(self, mailto_list=['xxxxxx@qq.com'], mail_host='smtp.126.com', | |
mail_user='yyyyyy', mail_password='zzzzzz', mail_postfix='126.com', attach_file_list=[]): |
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
#! /usr/bin/python | |
import sys | |
def read_input(file): | |
''' | |
read input tf mapper-reducer file | |
class:Queries\tword_1:val_1,word_2:val_2,..... | |
''' | |
for line in file: |
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
#include <string> | |
#include <vector> | |
#include <sstream> | |
using std::vector; | |
using std::string; | |
using std::stringstream; | |
vector<string> &split(const string &s, char delim, vector<string> &result) { | |
stringstream ss(s); |
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
package test_jsoup.test_jsoup; | |
import org.jsoup.Jsoup; | |
import org.jsoup.nodes.Document; | |
import org.jsoup.nodes.Element; | |
import org.jsoup.select.Elements; | |
public class App | |
{ | |
public static void main( String[] args ) throws Exception |
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
# -*- coding: utf-8 -*- | |
import requests | |
from pyquery import PyQuery as pq | |
import yaml | |
from hashlib import md5 | |
from datetime import datetime | |
import smtplib | |
from email.mime.text import MIMEText |
NewerOlder