4 examples of 'why learn go' in Go

Every line of 'why learn go' code snippets is scanned for vulnerabilities by our powerful machine learning engine that combs millions of open source libraries, ensuring your Go code is secure.

All examples are scanned by Snyk Code

By copying the Snyk Code Snippets you agree to
112func (sv *SpellView) LearnAct() *gi.Action {
113 return sv.UnknownBar().ChildByName("learn", 3).(*gi.Action)
114}
236func (l *LeastSquares) Learn() error {
237 if l.trainingSet == nil || l.expectedResults == nil {
238 err := fmt.Errorf("ERROR: Attempting to learn with no training examples!\n")
239 fmt.Fprintf(l.Output, err.Error())
240 return err
241 }
242
243 examples := len(l.trainingSet)
244 if examples == 0 || len(l.trainingSet[0]) == 0 {
245 err := fmt.Errorf("ERROR: Attempting to learn with no training examples!\n")
246 fmt.Fprintf(l.Output, err.Error())
247 return err
248 }
249 if len(l.expectedResults) == 0 {
250 err := fmt.Errorf("ERROR: Attempting to learn with no expected results! This isn't an unsupervised model!! You'll need to include data before you learn :)\n")
251 fmt.Fprintf(l.Output, err.Error())
252 return err
253 }
254
255 fmt.Fprintf(l.Output, "Training:\n\tModel: Logistic (Binary) Classification\n\tOptimization Method: %v\n\tTraining Examples: %v\n\tFeatures: %v\n\tLearning Rate α: %v\n\tRegularization Parameter λ: %v\n...\n\n", l.method, examples, len(l.trainingSet[0]), l.alpha, l.regularization)
256
257 var err error
258 if l.method == base.BatchGA {
259 err = base.GradientAscent(l)
260 } else if l.method == base.StochasticGA {
261 err = base.StochasticGradientAscent(l)
262 } else {
263 err = fmt.Errorf("Chose a training method not implemented for LeastSquares regression")
264 }
265
266 if err != nil {
267 fmt.Fprintf(l.Output, "\nERROR: Error while learning –\n\t%v\n\n", err)
268 return err
269 }
270
271 fmt.Fprintf(l.Output, "Training Completed.\n%v\n\n", l)
272 return nil
273}
12func (this *app) Learn(ctx context.Context) error {
13 if len(this.Command.Args()) == 0 {
14 return fmt.Errorf("Missing argument")
15 }
16 for _, name := range this.Command.Args() {
17 codes := this.LIRCKeycodeManager.Keycode(name)
18 if len(codes) == 0 {
19 fmt.Println("No keys found for", name)
20 continue
21 }
22 for i, code := range codes {
23 fmt.Println(i+1, "of", len(codes))
24 if err := this.LearnCode(ctx, code, *this.name); err != nil {
25 return err
26 }
27 fmt.Println()
28 }
29 }
30 return nil
31}
236func (c *Classifier) Learn(document []string, which Class) {
237 data := c.datas[which]
238 for _, word := range document {
239 data.Freqs[word]++
240 data.Total++
241 }
242 c.learned++
243}

Related snippets