{"id":1401,"date":"2022-05-22T23:44:53","date_gmt":"2022-05-22T15:44:53","guid":{"rendered":"http:\/\/www.eait.co\/?p=1401"},"modified":"2022-05-22T23:44:53","modified_gmt":"2022-05-22T15:44:53","slug":"svdtest","status":"publish","type":"post","link":"https:\/\/notes.coremix.net\/?p=1401","title":{"rendered":"SVDtest"},"content":{"rendered":"<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<pre class=\"brush: python; title: ; notranslate\" title=\"\">\r\nfrom numpy import linalg as la\r\nfrom numpy import mat\r\nimport matplotlib\r\nimport matplotlib.pyplot as plt\r\n#\u5171\u73b0\u77e9\u9635\r\nx=&#x5B;&#x5B;0,1,0,2,0,0],\r\n   &#x5B;1,0,1,0,0,0],\r\n   &#x5B;0,1,0,0,0,0],\r\n   &#x5B;2,0,0,0,1,1],\r\n   &#x5B;0,0,0,1,0,0],\r\n   &#x5B;0,0,0,1,0,0]]\r\n#\u901a\u8fc7SVD\u5b9e\u73b0\u5206\u89e3\uff0c\u4f7f\u7528U\u6765\u8868\u5f81\u5411\u91cf\u3002\r\nu,sigma,vt=la.svd(mat(x))\r\nprint(u)\r\n#\u8bcd\u7684\u5217\u8868\r\nx_word=&#x5B;u'\u6211',u'\u559c\u6b22',u'\u5927\u6570\u636e',u'\u7231',u'\u8fd0\u52a8',u'\u6444\u5f71']\r\n#\u753b\u56fe \u901a\u8fc7u\u7684\u77e9\u9635(\u524d\u4e24\u5217\u5206\u522b\u505a x y\u8f74) \u8d34\u4e0aword\u7684\u6807\u7b7e\r\n#\u628a\u77e9\u9635\u8f6c\u6362\u4e3alist\r\nu_list=u.tolist()\r\n#print(u_list)\r\n#\u4e2d\u6587\u5b57\u7b26\u5c55\u793a\r\nmatplotlib.rcParams&#x5B;'font.sans-serif'] = &#x5B;'SimHei']\r\nmatplotlib.rcParams&#x5B;'font.family'] = 'sans-serif'\r\n#\u8bbe\u7f6ex\u8f74 y\u8f74\u7684\u8303\u56f4\r\nplt.axis(&#x5B;min(u_list&#x5B;:1]&#x5B;0])-1,max(u_list&#x5B;:1]&#x5B;0])+1,min(u_list&#x5B;:2]&#x5B;1])-1,max(u_list&#x5B;:2]&#x5B;1])+1])\r\nfor x,y,word in zip(u_list&#x5B;:1]&#x5B;0],u_list&#x5B;:2]&#x5B;1],x_word):\r\n    plt.text(x+0.3,y+0.3,word,fontsize=10.5)\r\np\r\n<\/pre>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>&nbsp; &nbsp; &nbsp; from numpy import linalg as la fro [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[20],"class_list":["post-1401","post","type-post","status-publish","format-standard","hentry","category-uncategorized","tag-python"],"blocksy_meta":[],"_links":{"self":[{"href":"https:\/\/notes.coremix.net\/index.php?rest_route=\/wp\/v2\/posts\/1401","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/notes.coremix.net\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/notes.coremix.net\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/notes.coremix.net\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/notes.coremix.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=1401"}],"version-history":[{"count":1,"href":"https:\/\/notes.coremix.net\/index.php?rest_route=\/wp\/v2\/posts\/1401\/revisions"}],"predecessor-version":[{"id":1402,"href":"https:\/\/notes.coremix.net\/index.php?rest_route=\/wp\/v2\/posts\/1401\/revisions\/1402"}],"wp:attachment":[{"href":"https:\/\/notes.coremix.net\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1401"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/notes.coremix.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1401"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/notes.coremix.net\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1401"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}