2017年3月30日 星期四

revival of an installed cygwin system after change of os

Cygwin 是一個依附在 Windows 作業系統上的 Linux 作業系統,可以方便用戶同時享用兩者便利功能。
更換 Windows 作業系統後,若不想重灌 cygwin 系統,想利用原有安裝目錄資料,可參考如下復活法。
假設參數如下:
  舊根目錄 Root install directory: D:\Cygwin64
  舊套件目錄 Local package directory: D:\Install\Cygwin64
  新舊用戶名 Windows User Name: Old_User, New_User

1.利用安裝程式重建桌面終端機捷徑
    下載執行 Cygwin 安裝程式 setup-x86_64.exe (64位元)
    Choose a download source: Installed from local directory
    Select root install directory: Root directory: [D:\Cygwin64]
    Select local package directory: Local package directory: [D:\Install\Cygwin64]
    Select packages: Current
    不裝新套件,選[下一步],[完成]後,會在桌面產生 Cygwin64 Terminal

2.利用終端機重建用戶密碼檔
    點選桌面 Cygwin64 Terminal 右鍵,選擇 [以系統管理者身分執行(A)]
    以命令列指令重建用戶檔: mkpasswd -l > /etc/passwd

3.利用 Windows 檔案總管設定安裝目錄的用戶權限
    檔案總管開啟 D:\Cygwin64,按右鍵,點選 內容(R)/安全性/進階(V)

  a)設定新用戶為目錄擁有者
    點選 擁有者/變更(C): 請輸入物件名稱來選取(E): [New_User]/檢查名稱/確定

  b)設定新用戶對目錄擁有完全控制權限
    點選 權限項目: 主體: [Old_User]/移除(R)
     新增(D)/選取一個主體/請輸入物件名稱來選取(E): [New_User]/檢查名稱/確定
      類型: 允許
      套用到: 這個資料夾、子資料夾及檔案
      基本權限: 完全控制
      確定

註1: 若 ssh 對外連線時,出現個人憑證權限不可開放外界存取訊息,可設定如下:
      > chmod 0700 /home/NEW_USER/.ssh/id_*
    其中,針對如下3個個人憑證檔,需確定個人可讀 (有時要透過檔案總管安全性設定才能設定成功)。
          /home/NEW_USER/.ssh/id_dsa
          /home/NEW_USER/.ssh/id_rsa
          /home/NEW_USER/.ssh/identity

2017年3月29日 星期三

weka.classifiers.bayes.NaiveBayesSimple

weka.classifiers.bayes.NaiveBayesSimple 為簡單貝氏機率學習器的簡化版,
記錄各類別事前機率,及給定類別下各屬性值出現之條件機率,
再依案例,累乘得到給定屬性值下各類別出現之事後機率,取機率高者為預測類別,
可提供案例集不錯表現值供標竿比較之用。

NaiveBayesSimple 學習分類時,同樣為每個類別統計其類別事前機率(prior probability)、給定類別下各屬性值出現之條件機率。
遇數值屬性時,一律假設母體為常態分布,統計其平均值、標準差,供條件機率之推估。
預測分類時,依新案例,累乘得到給定屬性值下各類別出現之事後機率(posterior probability),取機率高者為預測類別。

參數說明:

出處: R. Duda and P. Hart (1973). Pattern Classification and Scene Analysis. Wiley, New York.

>java -cp simpleEducationalLearningSchemes.jar;weka.jar;. 
   weka.classifiers.bayes.NaiveBayesSimple -t data\weather.numeric.arff


Naive Bayes (simple)

Class yes: P(C) = 0.625

Attribute outlook
sunny   overcast        rainy
0.25            0.41666667      0.33333333

Attribute temperature
Mean: 73        Standard Deviation: 6.164414

Attribute humidity
Mean: 79.11111111       Standard Deviation: 10.21572861

Attribute windy
TRUE    FALSE
0.36363636      0.63636364



Class no: P(C) = 0.375

Attribute outlook
sunny   overcast        rainy
0.5             0.125           0.375

Attribute temperature
Mean: 74.6      Standard Deviation: 7.8930349

Attribute humidity
Mean: 86.2      Standard Deviation: 9.7313925

Attribute windy
TRUE    FALSE
0.57142857      0.42857143


Time taken to build model: 0.77 seconds
Time taken to test model on training data: 0 seconds

=== Error on training data ===

Correctly Classified Instances          13               92.8571 %
Incorrectly Classified Instances         1                7.1429 %
Kappa statistic                          0.8372
Mean absolute error                      0.3003
Root mean squared error                  0.3431
Relative absolute error                 64.6705 %
Root relative squared error             71.5605 %
Total Number of Instances               14


=== Detailed Accuracy By Class ===

                 TP Rate  FP Rate  Precision  Recall   F-Measure  MCC      ROC Area  PRC Area  Class
                 1.000    0.200    0.900      1.000    0.947      0.849    0.933     0.963     yes
                 0.800    0.000    1.000      0.800    0.889      0.849    0.933     0.925     no
Weighted Avg.    0.929    0.129    0.936      0.929    0.926      0.849    0.933     0.949


=== Confusion Matrix ===

 a b   <-- classified as
 9 0 | a = yes
 1 4 | b = no



=== Stratified cross-validation ===

Correctly Classified Instances           8               57.1429 %
Incorrectly Classified Instances         6               42.8571 %
Kappa statistic                         -0.0244
Mean absolute error                      0.4699
Root mean squared error                  0.5376
Relative absolute error                 98.6856 %
Root relative squared error            108.9683 %
Total Number of Instances               14


=== Detailed Accuracy By Class ===

                 TP Rate  FP Rate  Precision  Recall   F-Measure  MCC      ROC Area  PRC Area  Class
                 0.778    0.800    0.636      0.778    0.700      -0.026   0.444     0.636     yes
                 0.200    0.222    0.333      0.200    0.250      -0.026   0.444     0.398     no
Weighted Avg.    0.571    0.594    0.528      0.571    0.539      -0.026   0.444     0.551


=== Confusion Matrix ===

 a b   <-- classified as
 7 2 | a = yes
 4 1 | b = no


如下 weather.numeric.arff 案例集的14個案例利用2個文字屬性及2個數字屬性,預測文字屬性。
outlooktemperaturehumiditywindyplay
sunny8585FALSEno
sunny8090TRUEno
rainy6570TRUEno
sunny7295FALSEno
rainy7191TRUEno
overcast8386FALSEyes
rainy7096FALSEyes
rainy6880FALSEyes
overcast6465TRUEyes
sunny6970FALSEyes
rainy7580FALSEyes
sunny7570TRUEyes
overcast7290TRUEyes
overcast8175FALSEyes
參考: 1.weka.classifiers.bayes.NaiveBayesSimple code | doc 2.從Weka 3.7.2版之後,NaiveBayesSimple 類別 從 weka.jar 主套件改歸到 simpleEducationalLearningSchemes.jar 選擇性套件內, 可利用Tools/Package Manager/Search: simpleEducationalSchemes/Install進行安裝。 在Windows下,下載套件存放位置在 C:\Users\用戶名\wekafiles\packages\ 資料夾內。 simpleEducationalSchemes 包含IB1,Prism,Id3,NaiveBayesSimple四個簡單分類器

matlab backslash benchmarking on T3600 + Tesla C2075

Dell T3600 (CPU: Intel Xeon E5-1607, quad-core, 3GHz) +
(GPU: Tesla C2075, 14 MultiProcessor x 32 cores per MP = 448 cores, 1.15GHz)

>> paralleldemo_gpu_backslash
Warning: Support for GPU devices with Compute Capability 2.0 will be removed in a future MATLAB release.
To learn more about supported GPU devices, see www.mathworks.com/gpudevice. 
> In parallel.internal.gpu.selectDevice
  In parallel.gpu.GPUDevice.current (line 44)
  In gpuDevice (line 23)
  In paralleldemo_gpu_backslash (line 25) 

Starting benchmarks with 8 different single-precision matrices of sizes
ranging from 1024-by-1024 to 22528-by-22528.
Creating a matrix of size 1024-by-1024.
Gigaflops on CPU: 48.665627
Gigaflops on GPU: 88.271370
Creating a matrix of size 4096-by-4096.
Gigaflops on CPU: 100.882839
Gigaflops on GPU: 413.998827
Creating a matrix of size 7168-by-7168.
Gigaflops on CPU: 118.687441
Gigaflops on GPU: 509.776228
Creating a matrix of size 10240-by-10240.
Gigaflops on CPU: 133.868299
Gigaflops on GPU: 573.530695
Creating a matrix of size 13312-by-13312.
Gigaflops on CPU: 139.691629
Gigaflops on GPU: 599.239014
Creating a matrix of size 16384-by-16384.
Gigaflops on CPU: 137.981033
Gigaflops on GPU: 611.514780
Creating a matrix of size 19456-by-19456.
Gigaflops on CPU: 143.995683
Gigaflops on GPU: 620.246637
Creating a matrix of size 22528-by-22528.
Gigaflops on CPU: 149.399225
Gigaflops on GPU: 628.924035

Starting benchmarks with 6 different double-precision matrices of sizes
ranging from 1024-by-1024 to 16384-by-16384.
Creating a matrix of size 1024-by-1024.
Gigaflops on CPU: 29.380086
Gigaflops on GPU: 63.980649
Creating a matrix of size 4096-by-4096.
Gigaflops on CPU: 48.082489
Gigaflops on GPU: 227.926438
Creating a matrix of size 7168-by-7168.
Gigaflops on CPU: 61.270138
Gigaflops on GPU: 270.644244
Creating a matrix of size 10240-by-10240.
Gigaflops on CPU: 64.503818
Gigaflops on GPU: 291.146412
Creating a matrix of size 13312-by-13312.
Gigaflops on CPU: 68.655104
Gigaflops on GPU: 300.565164
Creating a matrix of size 16384-by-16384.
Gigaflops on CPU: 56.189737
Gigaflops on GPU: 302.010177

ans = 

  struct with fields:

         sizeSingle: [1024 4096 7168 10240 13312 16384 19456 22528]
    gflopsSingleCPU: [48.6656 100.8828 118.6874 133.8683 139.6916 137.9810 143.9957 149.3992]
    gflopsSingleGPU: [88.2714 413.9988 509.7762 573.5307 599.2390 611.5148 620.2466 628.9240]
         sizeDouble: [1024 4096 7168 10240 13312 16384]
    gflopsDoubleCPU: [29.3801 48.0825 61.2701 64.5038 68.6551 56.1897]
    gflopsDoubleGPU: [63.9806 227.9264 270.6442 291.1464 300.5652 302.0102]
Single precision GFlops
Double precision GFlops
Speedup

2017年3月24日 星期五

missing font display in ms word

當你在使用中文繁體Windows作業系統時,若突然發現怎麼純文字檔(.txt)的中文碼亂掉或Office的標楷體,細明體消失,出現楷体、DFKai-SB、PMinLiU等字型,這時別慌,你的繁體字型都還在,只是顯示不出來。只要修改如下位置的設定,一切就回復成繁體原狀。

    [控制台 / 時鐘、語言和區域 / 語言 / 系統管理 / 非Unicode程式的語言 / 變更系統地區設定(C)...]

將目前的系統地區設定由 [中文(簡體、中國)] 改為 [中文(繁體、台灣)],然後選擇 [立即重新啟動] 。

    註解:
  1.  Unicode字碼可同時顯示多國語言,但為了容舊,繁體中文Windows純文字檔仍使用Big5字碼,所以當非Unicode語言設定成簡體GB字碼時,原來的純文字檔顯示就變亂碼。
  2.  Office字型名稱的顯示會依據 [非Unicode程式的語言] 設定而決定。當正常設定為繁體時,DFKai-SB會顯示成標楷體、PMinLiU會顯示成細明體。所以當不知何原因被切換成簡體時,就顯示其英文名。至於楷体是簡體字型,在設定回復為繁體後,就顯示其英文名KaiTi。
  3. 常見漢字字型如下: 繁體中文字型有細明體(MinLiU) 、新細明體(PMinLiU)、標楷體(DFKai-SB)、微軟正黑體(Microsoft JhengHei);簡體中文字型有宋体(SimSun)、新宋体(NSimSun)、仿宋(FangSong)、楷体(KaiTi)、黑体(SimHei)、微软雅黑(Microsoft YaHei)、等线(DengXian);日文字型有明朝體(MS Mincho)、黑體(MS Gothic)。

2017年3月11日 星期六

benefits of installing guest additions in virtualbox guest os

電腦主機可以安裝虛擬機軟體VirtualBox,在主機上建立虛擬硬體層,
其上再安裝諸多客戶作業系統,同時間跑多個作業系統。
為了提升用戶體驗,VirtualBox同時提供客戶補充包(Guest Additions)套件,
若將其安裝在客戶作業系統上,使用起來會更上手,其具體好處如下:

1.滑鼠指標整合
    在客戶作業系統安裝滑鼠驅動器,進出視窗點選內容,不必再按主機鍵(右邊Ctrl鍵)跳出

2.共用資料夾
    可指定主機某資料夾分享給客戶作業系統,自動掛載顯示在桌面,
      Windows: 自動多一台磁碟機
      Linux: /media/sf_sharename
             用戶要對其讀寫須加入vboxsf群組

    或手動設定掛載點:
      Windows: net use x: \\vboxsvr\sharename
      Linux: mount -t vboxsf [-o OPTIONS] sharename mountpoint
          或 vi /etc/fstab
             sharename   mountpoint   vboxsf   defaults  0   0

3.共用剪貼簿
    主機和客戶系統可共用剪貼簿

4.檔案拖放
    主機和客戶系統可拖放檔案

5.較佳視訊支援
    支援更多非標準視訊模式,方便任意調整視窗大小

6.無縫視窗
    利用主機鍵(右邊Ctrl鍵)+"L"切換,可讓虛擬機桌面放大到主機桌面並且隱藏虛擬機桌面背景。
    這樣虛擬機桌面的視窗感覺就像主機桌面的視窗

7.時間同步
    確保客戶系統時間和主機相同.

8.通用主機客戶通訊管道
    方便主機控制和監看客戶系統

9.自動登入(傳送憑證)
    須透過複雜設定才能自動登入Windows或Linux系統

10.記憶體汽球調整及合併
    利用汽球調整(ballooning)及合併(fusion)技術,讓客戶系統間記憶體互相支援及共用,減少主機記憶體負荷

參考: https://www.virtualbox.org/manual/ch04.html#idm1721

2017年3月9日 星期四

weka.classifiers.rules.DecisionTable

 
weka.classifiers.rules.DecisionTable 為決策表學習器,適用於類別/數值預測。
預設利用最佳優先(登山)搜尋法,以交叉驗證之準確率或均方差為指標,找出最佳的屬性子集合。
然後,將訓練案例集縮減為只用留下的屬性子集合描述。
視每個案例為一條規則,其前件由留下屬性值組成,其後件則為多數決類別或平均值。
預測時若新案例有符合某規則之前件,則依其後件進行預測。
若遇決策表未涵蓋新案例,則使用k最近鄰居法,或背景多數決法作預測。

參數說明:
-X  crossVal: [1] 交叉驗證切割組數,1表只保留一測試案例,餘供訓練
-I  useIBk: [false] 遇未涵蓋新案例,使用k最近鄰居法,否則使用多數決法
-R  displayRules: [false] 列印決策表
-E  evaluationMeasure: [acc 或 rmse] 最佳指標遇類別採用準確率,遇數值採用均方差
                       其他指標還有  mae , auc
-S  search: [weka.attributeSelection.BestFirst] 子集合搜尋策略

  -- 以下為搜尋策略的參數 --

-D  direction: [1] 0表向後屬性變少,1表向前屬性變多,3表雙向
-S  lookupCacheSize: [1] 保留候選子集合的個數為案例集屬性個數的多少倍
-N  searchTermination: [5] 放棄搜尋前,能忍受指標無進步之試走步數
-P  startSet: [] 找尋初始點的屬性子集合,預設為空集合

參考: 
    kohavi-ecml-95-the power of decision tables

> java weka.classifiers.rules.DecisionTable -R -t data\weather.nominal.arff


Options: -R 

Decision Table:

Number of training instances: 14
Number of Rules : 1
Non matches covered by Majority class.
 Best first.
 Start set: no attributes
 Search direction: forward
 Stale search after 5 node expansions
 Total number of subsets evaluated: 12
 Merit of best subset found:   64.286
Evaluation (for feature selection): CV (leave one out) 
Feature set: 5

Rules:
================
play  
================
yes
================



Time taken to build model: 0 seconds
Time taken to test model on training data: 0 seconds

=== Error on training data ===

Correctly Classified Instances           9               64.2857 %
Incorrectly Classified Instances         5               35.7143 %
Kappa statistic                          0     
Mean absolute error                      0.4524
Root mean squared error                  0.4797
Relative absolute error                 97.4359 %
Root relative squared error            100.0539 %
Total Number of Instances               14     


=== Confusion Matrix ===

 a b   <-- classified as
 9 0 | a = yes
 5 0 | b = no



=== Stratified cross-validation ===

Correctly Classified Instances           6               42.8571 %
Incorrectly Classified Instances         8               57.1429 %
Kappa statistic                         -0.3659
Mean absolute error                      0.5318
Root mean squared error                  0.5583
Relative absolute error                111.6786 %
Root relative squared error            113.1584 %
Total Number of Instances               14     


=== Confusion Matrix ===

 a b   <-- classified as
 6 3 | a = yes
 5 0 | b = no

如下 weather.nominal.arff 案例集的14個案例有9個yes、5個no。
outlooktemperaturehumiditywindyplay
sunnyhothighFALSEno
sunnyhothighTRUEno
rainycoolnormalTRUEno
sunnymildhighFALSEno
rainymildhighTRUEno
overcasthothighFALSEyes
rainymildhighFALSEyes
rainycoolnormalFALSEyes
overcastcoolnormalTRUEyes
sunnycoolnormalFALSEyes
rainymildnormalFALSEyes
sunnymildnormalTRUEyes
overcastmildhighTRUEyes
overcasthotnormalFALSEyes
參考:
1.weka.classifiers.rules.DecisionTable
   code | doc