2019年第二次面试

# 小郑之家~

• 知道正则化吗？怎么正则化的？

• 它们俩有啥区别

• 它们为什么会有这样的差别

• LR 的代价函数怎么写的，解释一下它的意思？

• 概率论题

• 编程题

• 问我最后还有没有问题要问他

### 补充

• L2和L1正则化

• 那个概率题

>>> 0.7**6*0.3**4/(0.7**6*0.3**4+0.7**4*0.3**6)
0.8448275862068966



# ===========================================
# --coding:UTF-8 --
# file: test_prob.py
# date: 2019-03-30
# email: beyondpzk@outlook.com
# description:
# ===========================================

import random
import sys

def test(n):
assert n>=1

dicA = [0]*11
dicB = [0]*11
total=0
while total<n*1e5:
prop = random.random()
times = 0
black = 0
if prop<=0.5:
# from A
while times<10:
temp = random.random()
if temp<=0.7:
black += 1
times += 1
dicA[black] += 1
else:
# from B
while times<10:
temp = random.random()
if temp<=0.3:
black += 1
times += 1
dicB[black] += 1
total += 1

return dicA, dicB

iters = int(sys.argv[1])
ret1, ret2 = test(iters)
#print(ret1)
#print(ret2)
print(ret1[6]/(ret1[6]+ret2[6]))



[88, 2090, 21891, 134743, 550641, 1544449, 3001702, 4003078, 3501064, 1819538, 422348]
[423189, 1813674, 3501852, 4005470, 3000302, 1543225, 551448, 135039, 21952, 2136, 81]
0.8448002476675626