办公室扫地僧的日常生活

独孤九剑 vs 辟邪剑谱


  • Home

  • Archives

  • Tags

recommend-algorithm

Posted on 2017-10-09 | In machine learning

排名算法

Reddit

基于用户投票的排名算法(二):Reddit

StackOverflow

基于用户投票的排名算法(三):Stack Overflow

牛顿冷却定律

基于用户投票的排名算法(四):牛顿冷却定律

威尔逊区间

基于用户投票的排名算法(五):威尔逊区间

Docker.qcow2 osx 删除

Posted on 2017-08-28 | In Docker

docker rm $(docker ps -a -q)
docker rmi $(docker images -q)
docker volume rm $(docker volume ls |awk ‘{print $2}’)
rm -rf ~/Library/Containers/com.docker.docker/Data/*

Normal Equation VS Gradient Descent

Posted on 2017-07-26 | In Machine Learning

Normal Equation 跟 Gradient Descent(梯度下降)一样,可以用来求权重向量θ。但它与Gradient Descent相比,既有优势也有劣势。

优势:

Normal Equation可以不在意x特征的scale。比如,有特征向量X={x1, x2}, 其中x1的range为1~2000,而x2的range为1~4,可以看到它们的范围相差了500倍。如果使用Gradient Descent方法的话,会导致椭圆变得很窄很长,而出现梯度下降困难,甚至无法下降梯度(因为导数乘上步长后可能会冲出椭圆的外面)。但是,如果用Normal Equation方法的话,就不用担心这个问题了。因为它是纯粹的矩阵算法。

劣势:

相比于Gradient Descent,Normal Equation需要大量的矩阵运算,特别是求矩阵的逆。在矩阵很大的情况下,会大大增加计算复杂性以及对计算机内存容量的要求。

Python-yield原理

Posted on 2017-07-05 | In python

yield关键字 实际上是生成了一个迭代器,如下:

1
2
3
4
5
6
7
8
9
10
def shushu(n):
for i in range(n):
print i
yield i
if __name__ == '__main__':
ss = shushu(10)
ss.next()

方法 shushu被封装成了一个generator,
调用next方法,程序会走到yield i的位置并且把i的值返回,
当下一次调用next方法是,程序又会执行到这个位置,直到循环结束。
在两次next调用中 去执行其他的代码的过程,其实就是在进行任务切换,也就实现了协程的效果

API Gateway - kong

Posted on 2017-06-02 | In nginx

hexo使用

Posted on 2017-06-02 | In hexo

hexo 部署

1
2
3
4
5
hexo clean
hexo generate
hexo deploy

java 函数式接口

Posted on 2017-05-31 | In java

methodhandle

Posted on 2017-05-26 | In java

JDK中的动态代理,通过实现InvocationHandler代理实现代理类的方法,

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
public interface InvocationHandler {
/**
* Processes a method invocation on a proxy instance and returns
* the result. This method will be invoked on an invocation handler
* when a method is invoked on a proxy instance that it is
* associated with.
*
* @param proxy the proxy instance that the method was invoked on
*
* @param method the {@code Method} instance corresponding to
* the interface method invoked on the proxy instance. The declaring
* class of the {@code Method} object will be the interface that
* the method was declared in, which may be a superinterface of the
* proxy interface that the proxy class inherits the method through.
*
* @param args an array of objects containing the values of the
* arguments passed in the method invocation on the proxy instance,
* or {@code null} if interface method takes no arguments.
* Arguments of primitive types are wrapped in instances of the
* appropriate primitive wrapper class, such as
* {@code java.lang.Integer} or {@code java.lang.Boolean}.
*
* @return the value to return from the method invocation on the
* proxy instance. If the declared return type of the interface
* method is a primitive type, then the value returned by
* this method must be an instance of the corresponding primitive
* wrapper class; otherwise, it must be a type assignable to the
* declared return type. If the value returned by this method is
* {@code null} and the interface method's return type is
* primitive, then a {@code NullPointerException} will be
* thrown by the method invocation on the proxy instance. If the
* value returned by this method is otherwise not compatible with
* the interface method's declared return type as described above,
* a {@code ClassCastException} will be thrown by the method
* invocation on the proxy instance.
*
* @throws Throwable the exception to throw from the method
* invocation on the proxy instance. The exception's type must be
* assignable either to any of the exception types declared in the
* {@code throws} clause of the interface method or to the
* unchecked exception types {@code java.lang.RuntimeException}
* or {@code java.lang.Error}. If a checked exception is
* thrown by this method that is not assignable to any of the
* exception types declared in the {@code throws} clause of
* the interface method, then an
* {@link UndeclaredThrowableException} containing the
* exception that was thrown by this method will be thrown by the
* method invocation on the proxy instance.
*
* @see UndeclaredThrowableException
*/
public Object invoke(Object proxy, Method method, Object[] args)
throws Throwable;
}

InvocationHandler中的invoker方法是对代理类的所有method生效,如果要应对复杂的代理需求,
将会使这个方法过于庞大,所以可以通过自定义接口MethodHandler为每一个方法实现不同的代理逻辑。

1
2
3
4
public interface MethodHandler {
Object invoke(Object[] args) throws Throwable;
}

1
2
3
4
5
6
7
8
9
10
11
12
13
14
public class HttpHelperHandler implements InvocationHandler {
private Map<Method, MethodHandler> methodHandlerMap;
@Override
public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
MethodHandler methodHandler = methodHandlerMap.get(method);
if (methodHandler != null) {
return methodHandler.invoke(args);
} else {
return method.invoke(proxy,args);
}
}
}

这种方式更加灵活

lombok

Posted on 2017-05-24 | In java

简化代码神器

1
2
3
4
5
@DATA // 自动生成Getter Setter方法
@Slf4j // 自动生成Slf4j log
public class Sample{
}

FineBI Note

Posted on 2017-05-24 | In FineBI

螺旋分析

螺旋分析产生的螺旋分析表是不可以做关联的,如果需要实现复杂的关联的功能,可以通过ETL的方式建立中间表

123
Carl Zhu

Carl Zhu

21 posts
11 categories
19 tags
© 2018 Carl Zhu
Powered by Hexo
Theme - NexT.Muse