Comments (5)
This sounds like a good idea. I'm pretty stacked with work today but should be able to prototype something with the io.Writer
tomorrow I think. I'll let you know.
from goml.
I'm likely going to add an io.Writer
field to the model structs and just change the fmt.Printf
calls to fmt.Fprintf
, which (as seen below from the fmt
package code) is equivalent if you set your writer to os.Stdout
, so I'll default to that so there are no breaking changes. If you have any comments let me know.
I wouldn't want to remove the printing completely in case someone was relying on that feature for anything in an application. Similarly I think that the output is potentially nice if you're debugging something.
from https://golang.org/src/fmt/print.go
184 // Fprintf formats according to a format specifier and writes to w.
185 // It returns the number of bytes written and any write error encountered.
186 func Fprintf(w io.Writer, format string, a ...interface{}) (n int, err error) {
187 p := newPrinter()
188 p.doPrintf(format, a)
189 n, err = w.Write(p.buf)
190 p.free()
191 return
192 }
193
194 // Printf formats according to a format specifier and writes to standard output.
195 // It returns the number of bytes written and any write error encountered.
196 func Printf(format string, a ...interface{}) (n int, err error) {
197 return Fprintf(os.Stdout, format, a...)
198 }
from goml.
That sounds perfect. Thanks!
from goml.
Tests Before Changes
➜ goml git:(master) go test ./...
ok github.com/cdipaolo/goml/base 0.252s
ok github.com/cdipaolo/goml/cluster 14.893s
ok github.com/cdipaolo/goml/linear 46.546s
ok github.com/cdipaolo/goml/perceptron 9.365s
ok github.com/cdipaolo/goml/text 0.009s
Tests After Changes
➜ goml git:(logging) go test ./...
ok github.com/cdipaolo/goml/base 0.287s
ok github.com/cdipaolo/goml/cluster 11.707s
ok github.com/cdipaolo/goml/linear 38.457s
ok github.com/cdipaolo/goml/perceptron 9.029s
ok github.com/cdipaolo/goml/text 0.006s
The speedup is a little surprising because I basically just removed one or two function calls per test. I suspect that printing to dev/null (with ioutil.Discard
) might speed up tests a lot.
All models that did print to log not have an
// Output is the io.Writer used for logging
// and printing. Defaults to os.Stdout.
Output io.Writer
struct field as a public variable that can be changed by the user. All calls to fmt.Printf
were switched to fmt.Fprintf
.
from goml.
If you have any other comments let me know and I can reopen this.
from goml.
Related Issues (17)
- Examples HOT 3
- Bayes.go tokenizer breaks the sentiment restoration HOT 9
- Silhouette validation for clustering HOT 3
- Any plan to support ARIMA? HOT 1
- Allow users to disable stdout HOT 1
- Why do Predict and Probability functions use different operators? HOT 2
- Comparison with Weka, others? HOT 1
- Copying lock values TFIDF HOT 1
- TFIDF doesn't work HOT 1
- fmt.Errorf format %v reads arg #2, but call has 1 arg HOT 4
- Any interest in XGBoost? HOT 1
- This library is defunct: please correct me if I'm wrong
- Roadmap / Comparison to other Go ML libraries HOT 1
- Bug in k nearest neighbors HOT 1
- Text models, uint8 for number of classes? HOT 2
- Concurrent map access during NaiveBayes's OnlineLearning sequence
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from goml.