Skip to content

Commit ae7df90

Browse files
authored
Merge pull request #11 from vaaaaanquish/add_github_actions
Add Github Actions CI/CD
2 parents bfed6ba + 0149b07 commit ae7df90

File tree

3 files changed

+66
-4
lines changed

3 files changed

+66
-4
lines changed

.github/workflows/test.yml

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
name: test
2+
3+
on: [push, pull_request]
4+
5+
jobs:
6+
build:
7+
name: Rust ${{ matrix.os }} ${{ matrix.rust }}
8+
runs-on: ${{ matrix.os }}
9+
strategy:
10+
matrix:
11+
rust:
12+
- stable
13+
- beta
14+
- nightly
15+
os: [ubuntu-latest, macos-latest]
16+
steps:
17+
- uses: actions/checkout@v2
18+
with:
19+
submodules: true
20+
- name: Setup Rust
21+
uses: actions-rs/toolchain@v1
22+
with:
23+
profile: minimal
24+
toolchain: ${{ matrix.rust }}
25+
override: true
26+
- name: Build for OS X
27+
if: matrix.os == 'macos-latest'
28+
run: |
29+
brew install cmake
30+
brew install libomp
31+
cargo build
32+
- name: Build for ubuntu
33+
if: matrix.os == 'ubuntu-latest'
34+
run: |
35+
sudo apt-get install -y cmake libclang-dev libc++-dev gcc-multilib
36+
cargo build
37+
- name: Run tests
38+
run: cargo test
39+
continue-on-error: ${{ matrix.rust == 'nightly' }}

README.md

Lines changed: 25 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,36 @@ brew install cmake libomp
1515
```
1616

1717
Please see below for details.
18-
https://lightgbm.readthedocs.io/en/latest/Installation-Guide.html
18+
- [LightGBM Installation-Guide](https://lightgbm.readthedocs.io/en/latest/Installation-Guide.html)
1919

2020

2121

2222
# Usage
2323

24-
Please see `./examples`.
24+
Example LightGBM train.
25+
```
26+
extern crate serde_json;
27+
use lightgbm::{Dataset, Booster};
28+
use serde_json::json;
29+
30+
let data = vec![vec![1.0, 0.1, 0.2, 0.1],
31+
vec![0.7, 0.4, 0.5, 0.1],
32+
vec![0.9, 0.8, 0.5, 0.1],
33+
vec![0.2, 0.2, 0.8, 0.7],
34+
vec![0.1, 0.7, 1.0, 0.9]];
35+
let label = vec![0.0, 0.0, 0.0, 1.0, 1.0];
36+
let dataset = Dataset::from_mat(data, label).unwrap();
37+
let params = json!{
38+
{
39+
"num_iterations": 3,
40+
"objective": "binary",
41+
"metric": "auc"
42+
}
43+
};
44+
let bst = Booster::train(dataset, &params).unwrap();
45+
```
46+
47+
Please see the `./examples` for details.
2548

2649
|example|link|
2750
|---|---|

src/booster.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -164,8 +164,8 @@ mod tests {
164164
let feature = vec![vec![0.5; 28], vec![0.0; 28], vec![0.9; 28]];
165165
let result = bst.predict(feature).unwrap();
166166
let mut normalized_result = Vec::new();
167-
for r in result[0]{
168-
if r > 0.5{
167+
for r in &result[0]{
168+
if r > &0.5{
169169
normalized_result.push(1);
170170
} else {
171171
normalized_result.push(0);

0 commit comments

Comments
 (0)