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 -*- | |
| 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 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 -*- | |
| ''' | |
| 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 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: gbk -*- | |
| import numpy as np | |
| def foo(x): | |
| return x**2 + 2*x + 1 | |
| def g(x): | |
| return 2*x + 2 |
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
| #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 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
| #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 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: 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 |
OlderNewer