Giter Club home page Giter Club logo

plot's Introduction

plot

Go simple-to-use library for plotting and interpreting data, including the Gaussian distribution and Taylor series approximations as well as statistical computations of datasets, vector and matrix visualizations and more.

GoDoc

The plot package is easy to use and it offers a vast ammount of data methods. You can upload your own dataset to plot or use a dataset with the correspondant output. Looking forward to get some feedback!

Let's take a look at some functionality!

Installation

Pretty straightforward.

go get github.com/timothy102/plot

Import the library in your Go file.

import "github.com/timothy102/plot"

Usage

Let's look at a dataset using the cosine function. Second and third argument to the function invoke the starting and end point of iteration. You can adjust the iterations parameter to get a more dense distribution.

points := plot.DefineDataset(math.Cos, -10.0, 10.0, 500)
plot.PlotPoints(points, "Cosine.png", false)

alt text

That is how simple it is. If you would like to import your dataset externally, use the ReadFromDatafile function. The rest is the same.

points,err:=plot.ReadFromDatafile(filepath)
//error handling
if err:=PlotPoints(points,"Graph.png",false);err!=nil{
  log.Fatalf("could not plot data :%v",err)
}

Taylor series approximation for the Tan function and its error with the real deal. The last argument indicates the polynomial degree to which the function approximates.

points := plot.DefineDatasetWithPolynomial(TanEstimate, -2.0, 2.0, 250, 15)
e := EstimationError(math.Tan, points)
fmt.Printf("%.9f\n", e)

And the error is:

0.000000059

Taylor series approximation of the 15th degree polynomial of Sine and the difference between Sine.

points := plot.DefineDatasetWithPolynomial(plot.SinusEstimate, -5.0, 5.0, 250, 14)
plot.PlotPoints(points, "SinusEstimate.png", false)

p2 := plot.DefineDataset(math.Sin, -5.0, 5.0, 250)
plot.PlotPoints(p2, "Sinus.png", false)
	
e := plot.ErrorBetweenPoints(points, p2)
fmt.Printf("%.7f", e)

alt text alt text

With an average error of:

0.0000085

Let's take a look at creating a random dataset and then normalizing it so the data is centered and it has the standard deviation of 1 The DefineRandomPoints creates a 1000 points between 0 and 10.

pts := plot.DefineRandomPoints(1000, 0.0, 10.0)
pts = plot.Normalize(pts)
plot.PlotPoints(pts, "RandomPoints.png", true)

alt text alt text

And finally, the Gaussian distribution. First parameter is the mean value, the second is the standard deviation and the third is the number of iterations. Adjust these parameters for experimentation.

PlotGaussian(4.2,1.2,1000)

alt text

Contact

Please, feel free to reach out on LinkedIn, gmail. For more, check my medium article.

https://towardsdatascience.com/golang-as-the-new-machine-learning-powerforce-e1b74b10b83b

https://www.linkedin.com/in/tim-cvetko-32842a1a6/

License

Licensed under the MIT LICENSE

plot's People

Contributors

timothy102 avatar

Stargazers

 avatar  avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.