## 2012年11月27日 星期二

### [ JLRToolkit ] Logistic Regression Toolkit - Usage tutorial

Preface:

Data format:

Usage Code Example:

- testSet.txt
-0.017612 14.053064 0
-1.395634 4.662541 1
-0.752157 6.538620 0
-1.322371 7.152853 0
0.423363 11.054677 0
0.406704 7.067335 1
0.667394 12.741452 0
-2.460150 6.866805 1
...

(紅點為 label=0 的集合; 藍點為 label=1 的集合

- testSet2.txt
1 -0.017612 14.053064 0
1 -1.395634 4.662541 1
1 -0.752157 6.538620 0
1 -1.322371 7.152853 0
1 0.423363 11.054677 0
1 0.406704 7.067335 1
...

1. Utils.SEP_CHAR="\t"// 設定 separator char = Tab
2. Train train = new Train(0.001150); // 設定 ALPHA=0.001; Loop iteration=150
3. train.start(new File("testSet2.txt")); // 對 file=testSet2.txt 進行 training.
4. train.saveModel(new File("Test.model")); // 將 Training 完得到的 weights 矩陣存到 Test.model 檔案中.

[Info] Total 100 records; Feature size=3; Label size=2...
[Info] Default label=1...
[Info] Label=0:[-1.65, -0.12, 0.35]...
[Info] Label=1:[3.53, 0.81, -0.53]...
[Info] Training done! (0 sec)

3.53 + 0.81X + -0.53Y = t

3.53 + 0.81X + -0.53Y = 0
Y = (3.53 + 0.81X) / 0.53

1. Predict predict = new Predict(new File("Test.model")); // 載入 Model=Test.model
4. predict.start(new File("testSet2.txt"), new File("testPredict.txt")); // 對 "testSet2.txt" 進行 prediction, 並輸出結果到 "testPredict.txt"

[Info] Total 2 labels; Default label=1...
[Info] Total predict 100 records...

Console Model Usage:

Supplement:
[ ML In Action ] Predicting numeric values : regression - Linear regression (1)
[ ML In Action ] Predicting numeric values : regression - Linear regression (2)
[ ML In Action ] Predicting numeric values : regression - Linear regression (3)

#### 2 則留言:

1. 你好~

那個完整的專案代碼的載點已經失效了

請問能方便再上傳一次嘛?

造成不便很不好意思

1. 請試試看下面的載點:

### [ Python 文章收集 ] List Comprehensions and Generator Expressions

Source From  Here   Preface   Do you know the difference between the following syntax?  view plain copy to clipboard print ? [x  for ...