讲解:Newton’s method、R、R、log-likelihoodR|C/C++

Homework # 61. Let f(x) be a function from Rnto R. Suppose we would like tomaximize f(x). Show that if Hf(x) is negative definite thenthe Newton’s method direction at x, [Hf(x)]1f(x), is anascent direction. What does this imply for Newton’s methodwith backtracking? (We did this in class, except that we consideredthe minimization case and Hf(x) as positive definite;here I want you to go through the argument yourself for thisslightly altered case.)2. Consider the log-likelihood for the single covariate (i.e. eachxi ∈ R) logistic regression:log L(α) = XNi=1(1 yi)(α0 α1xi) log(1 + exp(α0 α1xi))(1)(a) Let g(α) = log(1+exp(α0α1xi)). To make the notationsimpler, set xi as follows,(2)and explain why we can rewrite g(x) in the more compactform: g(α) = log(1 + exp(α · xi)). (This compact formmakes it easier to take derivatives.(b) Show the following(4)(You computed the gradient and Hessian of g(α) in previoushws, but here I want you to see the form above so thenext subproblem is easier.)1(c) Let v ∈ Rn. Thinking of v as a column vector, define thematrix A = vvT. Show that A is positive semidefinite,meaning that xTAx ≥ 0 for all x ∈ Rn. (Hint: Consider(xTv)(vT x)). Use this fact to show that the function g(x)is convex.(d) Show the following facts. You can prove them from thedefinition or just explain the intuition through a graph.i. If two functions f(x) and h(x) are convex then so istheir sum f(x) + g(x).ii. If a function f(x) is convex, then f(x) is concave.Then, show that log L(α) is a concave function.(e) Generate a plot of log L(α) over some line in R2that containsthe maximum of log L(α) (you computed this pointin a previous hw.). Explain why the graph you produce isconcave.3. The MNIST dataset is a popular dataset for practicing machinelearning algorithms. Read about the dataset herehttps://代写Newton’s method作业、R编程作业代做、代写R实验作业、代做log-likelihood留学生作业 代写en.wikipedia.org/wiki/MNIST_databaseAttached you will find two files. mnist_train.csv, mnist_test.csv.Each file contains a matrix. Each row of the matrix correspondsto an image of a hand written digit. The first entry in the rowis the digit in the image (i.e. 7 if the digit image is a seven), therest of the values, of which there are 784 (from a 28 × 28 pixelimage) are the pixel values. See the script mnist_intro.R foran example.In this problem, you will build a classifier that identifies whena hand written digit equals 3. To build the classifier you willfit a logistic regression to the data. The response variable,y ∈ {0, 1} will be 1 if the number is 3 and 0 otherwise. Thecovariates, x ∈ R784 are the pixel values. Setα = (α0, α1, α2, . . . , α784) (5)The logistic-regression model assumesP(y 1 | x, α) = 11 + exp[α · x](6)2where x is defined as in problem 2 (i.e. we just add a 1 to thebeginning of the x vector.)(a) Show that the log-likelihood is given bylog L(α) = XNi=1(1yi)(α· xi)log(1 + exp(α· xi)) (7)(b) Set g(α) = log(1 + exp(α · xi)) and show that g(x) andHg(x) have the same form given in problem 2(c) Write a damped Newton’s method algorithm to computethe optimal α by maximizing the log likelihood on thetraining dataset. How do you know Newton’s method willconverge to a maximum? (NOTE: You may run into dif-ficulties with non-invertible Hessians; we will address thatissue in coming classes. If that happens, try other startingpoints.)(d) Recall that a classifier is a functionC(x) : R784 → {0, 1}. (8)Once you compute an α in (c), you can build a classifieras followsC(x) = 1 if P(x | α) = 11+exp[α·x] ≥ p0 otherwise.(9)where p is some cutoff probability. Above p, you call theimages as 3’s, below p you call images as not 3’s. Selecta p and test the accuracy of your classifier using the testdataset.转自:http://ass.3daixie.com/2019022347964256.html

©著作权归作者所有,转载或内容合作请联系作者
  • 序言:七十年代末,一起剥皮案震惊了整个滨河市,随后出现的几起案子,更是在滨河造成了极大的恐慌,老刑警刘岩,带你破解...
    沈念sama阅读 217,406评论 6 503
  • 序言:滨河连续发生了三起死亡事件,死亡现场离奇诡异,居然都是意外死亡,警方通过查阅死者的电脑和手机,发现死者居然都...
    沈念sama阅读 92,732评论 3 393
  • 文/潘晓璐 我一进店门,熙熙楼的掌柜王于贵愁眉苦脸地迎上来,“玉大人,你说我怎么就摊上这事。” “怎么了?”我有些...
    开封第一讲书人阅读 163,711评论 0 353
  • 文/不坏的土叔 我叫张陵,是天一观的道长。 经常有香客问我,道长,这世上最难降的妖魔是什么? 我笑而不...
    开封第一讲书人阅读 58,380评论 1 293
  • 正文 为了忘掉前任,我火速办了婚礼,结果婚礼上,老公的妹妹穿的比我还像新娘。我一直安慰自己,他们只是感情好,可当我...
    茶点故事阅读 67,432评论 6 392
  • 文/花漫 我一把揭开白布。 她就那样静静地躺着,像睡着了一般。 火红的嫁衣衬着肌肤如雪。 梳的纹丝不乱的头发上,一...
    开封第一讲书人阅读 51,301评论 1 301
  • 那天,我揣着相机与录音,去河边找鬼。 笑死,一个胖子当着我的面吹牛,可吹牛的内容都是我干的。 我是一名探鬼主播,决...
    沈念sama阅读 40,145评论 3 418
  • 文/苍兰香墨 我猛地睁开眼,长吁一口气:“原来是场噩梦啊……” “哼!你这毒妇竟也来了?” 一声冷哼从身侧响起,我...
    开封第一讲书人阅读 39,008评论 0 276
  • 序言:老挝万荣一对情侣失踪,失踪者是张志新(化名)和其女友刘颖,没想到半个月后,有当地人在树林里发现了一具尸体,经...
    沈念sama阅读 45,443评论 1 314
  • 正文 独居荒郊野岭守林人离奇死亡,尸身上长有42处带血的脓包…… 初始之章·张勋 以下内容为张勋视角 年9月15日...
    茶点故事阅读 37,649评论 3 334
  • 正文 我和宋清朗相恋三年,在试婚纱的时候发现自己被绿了。 大学时的朋友给我发了我未婚夫和他白月光在一起吃饭的照片。...
    茶点故事阅读 39,795评论 1 347
  • 序言:一个原本活蹦乱跳的男人离奇死亡,死状恐怖,灵堂内的尸体忽然破棺而出,到底是诈尸还是另有隐情,我是刑警宁泽,带...
    沈念sama阅读 35,501评论 5 345
  • 正文 年R本政府宣布,位于F岛的核电站,受9级特大地震影响,放射性物质发生泄漏。R本人自食恶果不足惜,却给世界环境...
    茶点故事阅读 41,119评论 3 328
  • 文/蒙蒙 一、第九天 我趴在偏房一处隐蔽的房顶上张望。 院中可真热闹,春花似锦、人声如沸。这庄子的主人今日做“春日...
    开封第一讲书人阅读 31,731评论 0 22
  • 文/苍兰香墨 我抬头看了看天上的太阳。三九已至,却和暖如春,着一层夹袄步出监牢的瞬间,已是汗流浃背。 一阵脚步声响...
    开封第一讲书人阅读 32,865评论 1 269
  • 我被黑心中介骗来泰国打工, 没想到刚下飞机就差点儿被人妖公主榨干…… 1. 我叫王不留,地道东北人。 一个月前我还...
    沈念sama阅读 47,899评论 2 370
  • 正文 我出身青楼,却偏偏与公主长得像,于是被迫代替她去往敌国和亲。 传闻我的和亲对象是个残疾皇子,可洞房花烛夜当晚...
    茶点故事阅读 44,724评论 2 354

推荐阅读更多精彩内容

  • pyspark.sql模块 模块上下文 Spark SQL和DataFrames的重要类: pyspark.sql...
    mpro阅读 9,451评论 0 13
  • mean to add the formatted="false" attribute?.[ 46% 47325/...
    ProZoom阅读 2,696评论 0 3
  • 欢迎关注我的专栏( つ•̀ω•́)つ【人工智能通识】【汇总】2019年4月专题 关于概率、条件概率、联合概率的基本...
    zhyuzh3d阅读 908评论 0 4
  • 这个星期越来越不想写文章了,不知道为什么感觉心有点累,但是实际上又不是,感觉好像是没有什么好说,其实又有得说,为...
    b79ddab78458阅读 189评论 0 0
  • 昨天晚上参加了007不写就出局覃杰老大主导的头脑风暴第四波—如何将付费圈子做到1000人,获益匪浅。给我最大的感受...
    大漠雄鹰_Potter阅读 164评论 0 1