Skip to content

Commit c68a618

Browse files
committed
Separate README for v1 and v2
1 parent c67fd12 commit c68a618

File tree

2 files changed

+88
-77
lines changed

2 files changed

+88
-77
lines changed

README.md

+3-77
Original file line numberDiff line numberDiff line change
@@ -1,82 +1,8 @@
11
regression v2
22
=======
3-
[![License][license-image]][license-url]
43

5-
[license-image]: http://img.shields.io/badge/license-MIT-green.svg?style=flat-square
6-
[license-url]: LICENSE
4+
This repository contains v2 of regression library that provides totally different API from the original version.
75

8-
Goで重回帰分析するライブラリ
9-
Multivariable Linear Regression in Go (golang)
6+
v2 is under `v2/` directory, or you can find at https://github.com/anyappinc/regression/tree/master/v2.
107

11-
*NOTE: This project is originally based on https://github.com/sajari/regression*
12-
13-
installation
14-
------------
15-
16-
$ go get github.com/anyappinc/regression/v2
17-
18-
example usage
19-
-------------
20-
21-
Import the package, create a regression and add data to it. You can use as many variables as you like, in the below example there are 3 variables for each observation.
22-
23-
```go
24-
package main
25-
26-
import (
27-
"fmt"
28-
29-
"github.com/anyappinc/regression/v2"
30-
)
31-
32-
func main() {
33-
r := regression.NewRegression()
34-
r.SetObjectiveVariableLabel("Murders per annum per 1,000,000 inhabitants")
35-
r.SetExplanatoryVariableLabel(0, "Inhabitants")
36-
r.SetExplanatoryVariableLabel(1, "Percent with incomes below $5000")
37-
r.SetExplanatoryVariableLabel(2, "Percent unemployed")
38-
r.AddObservations(
39-
regression.NewObservation(11.2, []float64{587000, 16.5, 6.2}),
40-
regression.NewObservation(13.4, []float64{643000, 20.5, 6.4}),
41-
regression.NewObservation(40.7, []float64{635000, 26.3, 9.3}),
42-
regression.NewObservation(5.3, []float64{692000, 16.5, 5.3}),
43-
regression.NewObservation(24.8, []float64{1248000, 19.2, 7.3}),
44-
regression.NewObservation(12.7, []float64{643000, 16.5, 5.9}),
45-
regression.NewObservation(20.9, []float64{1964000, 20.2, 6.4}),
46-
regression.NewObservation(35.7, []float64{1531000, 21.3, 7.6}),
47-
regression.NewObservation(8.7, []float64{713000, 17.2, 4.9}),
48-
regression.NewObservation(9.6, []float64{749000, 14.3, 6.4}),
49-
regression.NewObservation(14.5, []float64{7895000, 18.1, 6}),
50-
regression.NewObservation(26.9, []float64{762000, 23.1, 7.4}),
51-
regression.NewObservation(15.7, []float64{2793000, 19.1, 5.8}),
52-
regression.NewObservation(36.2, []float64{741000, 24.7, 8.6}),
53-
regression.NewObservation(18.1, []float64{625000, 18.6, 6.5}),
54-
regression.NewObservation(28.9, []float64{854000, 24.9, 8.3}),
55-
regression.NewObservation(14.9, []float64{716000, 17.9, 6.7}),
56-
regression.NewObservation(25.8, []float64{921000, 22.4, 8.6}),
57-
regression.NewObservation(21.7, []float64{595000, 20.2, 8.4}),
58-
regression.NewObservation(25.7, []float64{3353000, 16.9, 6.7}),
59-
)
60-
model, err := r.Run()
61-
if err != nil {
62-
log.Fatalln(err)
63-
}
64-
65-
fmt.Printf("Regression formula:\n%v\n", model.FormulaString())
66-
}
67-
```
68-
69-
Note: You can also add observations one by one.
70-
71-
Once calculated, you can look at the R^2, Standard Error, ANOVA, Coefficients, etc. e.g.
72-
73-
```go
74-
// Get the coefficient for the "Inhabitants" variable 0:
75-
c := model.ExplanatoryVars[0].Coeff
76-
```
77-
78-
You can also use the model to predict new observation
79-
80-
```go
81-
prediction, err := model.Predict([]float64{587000, 16.5, 6.2})
82-
```
8+
The original library that this one is based on is available at https://github.com/sajari/regression.

v2/README.md

+85
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
regression v2
2+
=======
3+
4+
[go-reference-badge]: https://pkg.go.dev/badge/github.com/anyappinc/regression/v2.svg
5+
[go-reference-url]: https://pkg.go.dev/github.com/anyappinc/regression/v2
6+
[license-image]: http://img.shields.io/badge/license-MIT-green.svg?style=flat-square
7+
[license-url]: LICENSE
8+
9+
[![Go Reference][go-reference-badge]][go-reference-url]
10+
[![License][license-image]][license-url]
11+
12+
Multiple linear regression analysis library written in Go
13+
14+
*NOTE: This project is originally based on https://github.com/sajari/regression*
15+
16+
installation
17+
------------
18+
19+
$ go get github.com/anyappinc/regression/v2
20+
21+
example usage
22+
-------------
23+
24+
Import the package, create a regression and add data to it. You can use as many variables as you like, in the below example there are 3 variables for each observation.
25+
26+
```go
27+
package main
28+
29+
import (
30+
"fmt"
31+
32+
"github.com/anyappinc/regression/v2"
33+
)
34+
35+
func main() {
36+
r := regression.NewRegression()
37+
r.SetObjectiveVariableLabel("Murders per annum per 1,000,000 inhabitants")
38+
r.SetExplanatoryVariableLabel(0, "Inhabitants")
39+
r.SetExplanatoryVariableLabel(1, "Percent with incomes below $5000")
40+
r.SetExplanatoryVariableLabel(2, "Percent unemployed")
41+
r.AddObservations(
42+
regression.NewObservation(11.2, []float64{587000, 16.5, 6.2}),
43+
regression.NewObservation(13.4, []float64{643000, 20.5, 6.4}),
44+
regression.NewObservation(40.7, []float64{635000, 26.3, 9.3}),
45+
regression.NewObservation(5.3, []float64{692000, 16.5, 5.3}),
46+
regression.NewObservation(24.8, []float64{1248000, 19.2, 7.3}),
47+
regression.NewObservation(12.7, []float64{643000, 16.5, 5.9}),
48+
regression.NewObservation(20.9, []float64{1964000, 20.2, 6.4}),
49+
regression.NewObservation(35.7, []float64{1531000, 21.3, 7.6}),
50+
regression.NewObservation(8.7, []float64{713000, 17.2, 4.9}),
51+
regression.NewObservation(9.6, []float64{749000, 14.3, 6.4}),
52+
regression.NewObservation(14.5, []float64{7895000, 18.1, 6}),
53+
regression.NewObservation(26.9, []float64{762000, 23.1, 7.4}),
54+
regression.NewObservation(15.7, []float64{2793000, 19.1, 5.8}),
55+
regression.NewObservation(36.2, []float64{741000, 24.7, 8.6}),
56+
regression.NewObservation(18.1, []float64{625000, 18.6, 6.5}),
57+
regression.NewObservation(28.9, []float64{854000, 24.9, 8.3}),
58+
regression.NewObservation(14.9, []float64{716000, 17.9, 6.7}),
59+
regression.NewObservation(25.8, []float64{921000, 22.4, 8.6}),
60+
regression.NewObservation(21.7, []float64{595000, 20.2, 8.4}),
61+
regression.NewObservation(25.7, []float64{3353000, 16.9, 6.7}),
62+
)
63+
model, err := r.Run()
64+
if err != nil {
65+
log.Fatalln(err)
66+
}
67+
68+
fmt.Printf("Regression formula:\n%v\n", model.FormulaString())
69+
}
70+
```
71+
72+
Note: You can also add observations one by one.
73+
74+
Once calculated, you can look at the R^2, Standard Error, ANOVA, Coefficients, etc. e.g.
75+
76+
```go
77+
// Get the coefficient for the "Inhabitants" variable 0:
78+
c := model.ExplanatoryVars[0].Coeff
79+
```
80+
81+
You can also use the model to predict new observation
82+
83+
```go
84+
prediction, err := model.Predict([]float64{587000, 16.5, 6.2})
85+
```

0 commit comments

Comments
 (0)