Documentation
¶
Overview ¶
Package plot implements plotting functionality for all kinds of data, including the Gaussian distribution, Taylor series approximations and more. It provides an insightful way to data representation and interpretation along with vector and matrix visualisations.
Index ¶
- func Absolute(x float64) float64
- func ApplyProductRule(f func(x float64) float64, base, power float64) func(float64) float64
- func AreDistant(a, b int) bool
- func AverageEuclidean(pts Points) float64
- func AverageX(pts Points) float64
- func AverageY(pts Points) float64
- func BiggestIndividualError(est, real Points) float64
- func Bisection(f func(float64) float64, down, upper float64, iter int) float64
- func ClosestToZero(pts Points) float64
- func Correlation(pts Points)
- func CosineEstimate(x float64, polynomial int) float64
- func Cost(pts Points, k, n float64) float64
- func Covariance(pts Points) float64
- func CovarianceMatrix(pts Points) matrix.Matrix
- func CrossEntropy(f func(x float64) float64, pts Points) float64
- func DegreesToRadians(x float64) float64
- func DisplayAllStats(pts Points)
- func DistanceFromOrigin(p Point) float64
- func DoApproximation(pts Points, learningRate float64, iterations int, file string) error
- func DrawApproximation(pts Points, k, n float64, file string) error
- func DrawLine(p1, p2 Point) (*plotter.Line, error)
- func DrawStddev(pl *plot.Plot, pts Points) error
- func ErrorBetweenPoints(est, real Points) float64
- func EstimationError(f func(x float64) float64, pts Points) float64
- func Euclidean(p1, p2 Point) float64
- func ExponentialEstimate(x float64, polynomial int) float64
- func F1Score(p1, p2 Points) int
- func Factorial(n int) int
- func FalseNegatives(p1, p2 Points) int
- func FalsePositives(p1, p2 Points) int
- func FindMaxX(pts Points) float64
- func FindMaxY(pts Points) float64
- func FindMinX(pts Points) float64
- func FindMinY(pts Points) float64
- func FixDifferentPointSizes(p1, p2 Points) (Points, Points)
- func Gaussian(x float64, mean float64, stddev float64) float64
- func GetEigenValues(m matrix.Matrix) ([]float64, error)
- func GetIndex(pts Points, p Point) (x int)
- func GetValueX(pts Points, index int) float64
- func GetValueY(pts Points, index int) float64
- func GradientAt(f func(x float64) float64, x float64) float64
- func GradientLines(f func(float64) float64, stPoint, endPoint float64, step float64, file string) error
- func Gradients(f func(x float64) float64, startPoint, endPoint float64) []float64
- func IndexAtClosestToValue(pts Points, value float64) int
- func IndexAtClosestToZero(pts Points) int
- func IndexAtMedianX(pts Points) int
- func IndexAtMedianY(pts Points) int
- func Integral(f func(x float64) float64, a, b float64, n int) float64
- func IntegralByTrapezoid(f func(x float64) float64, a, b float64, n int) float64
- func Intercept(p1, p2 Point) float64
- func JaccardIndex(p1, p2 Points) int
- func LargestCommonDivider(a, b int) int
- func LassoRegression(actual, pred []float64, lambda float64) float64
- func LinearRegression(pts Points, lr float64, iterations int) (k, c float64)
- func MaclaurinFor1Over1MinusX(x float64, polynomial int) float64
- func MedianX(pts Points) float64
- func MedianY(pts Points) float64
- func Mse(f func(x float64) float64, pts Points) float64
- func OutOfRange(pts Points, index int) bool
- func PartialsForLinReg(pts Points, k, c float64) (dk, dc float64)
- func PlotEigen(m matrix.Matrix, file string) error
- func PlotGaussian(mean, stddev float64, iterations int) error
- func PlotMatrix(m matrix.Matrix, file string) error
- func PlotPoints(pts Points, file string, showStddev bool) error
- func PlotSinusApproximation(iterations, polynomial int, file string) error
- func PlotTangents(f func(x float64) float64, startingPoint, endPoint float64, iterations int) error
- func PlotVector(v matrix.Vector, file string) error
- func PlotVectorAfterMatrixTransformation(v matrix.Vector, mat matrix.Matrix, file string) error
- func PlotVectors(vectors []matrix.Vector, file string) error
- func PlotsineAndCosine(file string) error
- func PointInDataset(pts Points, p Point) bool
- func PointToVector(pts Points) []matrix.Vector
- func PointToXYs(pts Points) plotter.XYs
- func Precision(p1, p2 Points) int
- func PrintMetrics(p1, p2 Points)
- func PrintPoints(pts Points)
- func RadiansToDegrees(x float64) float64
- func Recall(p1, p2 Points) int
- func RidgeRegression(actual, pred []float64, lambda float64) float64
- func Rmse(f func(x float64) float64, pts Points) float64
- func SamePoints(p1, p2 Points) bool
- func SameSign(f func(float64) float64, a, b float64) bool
- func Seasonality(time, amplitude float64, period, phase int) float64
- func Sensitivity(p1, p2 Points) int
- func Series(i Season, x float64) float64
- func Sigmoid(x float64) float64
- func SigmoidPrime(x float64) float64
- func SinusEstimate(x float64, polynomial int) float64
- func Slope(p1, p2 Point) float64
- func SmallestIndividualError(est, real Points) float64
- func Specificity(p1, p2 Points) int
- func StddevX(pts Points) float64
- func StddevY(pts Points) float64
- func TanEstimate(x float64, polynomial int) float64
- func TriangleArea(p1, p2, p3 Point) float64
- func TrueNegatives(p1, p2 Points) int
- func TruePositivies(p1, p2 Points) int
- func VarianceX(pts Points) float64
- func VarianceY(pts Points) float64
- func VectorToXYs(vectors []matrix.Vector) plotter.XYs
- func Xs(pts Points) []float64
- func Ys(pts Points) []float64
- type Category
- type Point
- func GetPoint(pts Points, index int) Point
- func HighestAccuracyPolynomial(f func(x float64, polynomial int) float64, fa func(x float64) float64, ...) ([]Point, int)
- func NewPoint(x, y float64) Point
- func PointNearestValue(pts Points, value float64) Point
- func RandomPoint() Point
- func TopKEuclideans(p Point, pts []Point, k int) []Point
- type Points
- func DefineDataset(f func(x float64) float64, stPoint, endPoint float64, iterations int) Points
- func DefineDatasetPolynomial(f func(x float64, polynomial int) float64, stPoint, endPoint float64, ...) Points
- func DefineDatasetQuadratic(f func(x, a, b, c float64) float64, a, b, c float64, stPoint, endPoint float64, ...) Points
- func DefineDatasetToPower(n float64, stPoint, endPoint float64, iterations int) Points
- func DefineLinearDataset(k, n, min, max float64, iterations int) Points
- func DefineNormalDistribution(n int, min, max, mean, stddev float64) Points
- func DefineRandomPoints(number int, min, max float64) Points
- func DefineWithRandomNoise(f func(x float64) float64, stPoint, endPoint float64, iterations int) Points
- func DiscludeNan(pts Points) Points
- func FlipOverXAxis(pts Points) Points
- func FlipOverYAxis(pts Points) Points
- func LimitTo(pts Points, xUpper, xDown, yUpper, yDown float64) Points
- func LimitToXDown(pts Points, xDown float64) Points
- func LimitToXUpper(pts Points, xUpper float64) Points
- func LimitToYDown(pts Points, yDown float64) Points
- func LimitToYUpper(pts Points, yUpper float64) Points
- func Normalize(pts Points) Points
- func PointsFromArrays(xs, ys []float64) Points
- func Randomize(pts Points) Points
- func ReadFromDatafile(filepath string) (Points, error)
- func RemoveFromIndexDownwards(pts Points, index int) Points
- func RemoveFromIndexUpwards(pts Points, index int) Points
- func RemoveFromPoints(pts Points, p Point) Points
- func RemovePointAt(pts Points, index int) Points
- func ReverseIndexes(pts Points) Points
- func RoundPointstoDecimals(pts Points, decimals int) Points
- func SeriesDataset(s Season, iterations int) Points
- func ShiftDatasetOnX(pts Points, scalar float64) Points
- func ShiftDatasetOnY(pts Points, scalar float64) Points
- func SortPointsByX(pts Points) Points
- func SortPointsByY(pts Points) Points
- func Standardize(pts Points) Points
- func StretchByFactorX(pts Points, factor float64) Points
- func StretchByFactorY(pts Points, factor float64) Points
- func VectorToPoints(vectors []matrix.Vector) Points
- type Season
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ApplyProductRule ¶
ApplyProductRule returns the function via the productRule. Note that the input function should be of shape a*b**x
func AreDistant ¶
AreDistant returns true if the largest common divider between a and b is 1, meaning they have no common dividers.
func AverageEuclidean ¶
AverageEuclidean returns the average euclidean distance by iteration through all Points.
func BiggestIndividualError ¶
BiggestIndividualError returns the highest error of individual Points.
func Bisection ¶
Bisection method for finding null values of the polynom by disecting the interval given down and upper parameters in this case.
func ClosestToZero ¶
ClosestToZero returns value closest to zero. You can use this function to see which approximation best estimates the actual function.
func Correlation ¶
func Correlation(pts Points)
Correlation prints the memo for how the X and Y of the dataset are correlated.
func CosineEstimate ¶
CosineEstimate returns the Taylor series cosine approximate of X.
func Covariance ¶
Covariance returns the covariance of a given dataset
func CovarianceMatrix ¶
CovarianceMatrix returns the covariance matrix of the dataset.
func CrossEntropy ¶
CrossEntropy returns the cross entropy loss
func DegreesToRadians ¶
DegreesToRadians converts degrees to radians
func DisplayAllStats ¶
func DisplayAllStats(pts Points)
DisplayAllStats prints all the statistics considering the dataset.
func DistanceFromOrigin ¶
DistanceFromOrigin returns the euclidean distance from origin.
func DoApproximation ¶
DoApproximation uses the ApproximateLine outputs to plot the approximation line.
func DrawApproximation ¶
DrawApproximation draws a line of approximation based on k,n which should be the outputs of ApproximiateLine
func DrawStddev ¶
DrawStddev plots the standard deviation
func ErrorBetweenPoints ¶
ErrorBetweenPoints returns the average error between est and real.
func EstimationError ¶
EstimationError returns the average error between Points and the function f at same parameters.
func ExponentialEstimate ¶
ExponentialEstimate returns the Taylor series exponential approximate of X. E to the x.
func F1Score ¶
F1Score based on the bool of Points, p1 should be the predicted value and p2 the actual values.
func FalseNegatives ¶
FalseNegatives returns the number of false negative predicted values.
func FalsePositives ¶
FalsePositives returns the number of false positive predicted values.
func FixDifferentPointSizes ¶
FixDifferentPointSizes equalizes Point sizes by shortening the longer one.
func Gaussian ¶
Gaussian returns the Gaussian distribution function. For plotting, check PlotGaussian().
func GetEigenValues ¶
GetEigenValues returns the eigenvalues. Inputs should be eigenvectors.
func GradientAt ¶
GradientAt returns the gradient of f at x
func GradientLines ¶
func GradientLines(f func(float64) float64, stPoint, endPoint float64, step float64, file string) error
GradientLines plots the tangents based on the gradients of the function f, given the starting and end point and the step
func Gradients ¶
Gradients returns the gradients from startPoint to endPoint See GradientAt for gradient at a specific Point.
func IndexAtClosestToValue ¶
IndexAtClosestToValue returns the index of the Point that is closest to the value on the Y axis.
func IndexAtClosestToZero ¶
IndexAtClosestToZero returns the index of the value within Points that is closest to zero.
func IndexAtMedianX ¶
IndexAtMedianX returns the index of the median x value of the dataset.
func IndexAtMedianY ¶
IndexAtMedianY returns the index of the median y value of the dataset.
func Integral ¶
Integral defines a definite integral between the Points a and b for function f. N represents the number to which you want to divide the space from a and b into. You should be getting better approximations for the area under the curve by increasing n.
func IntegralByTrapezoid ¶
IntegralByTrapezoid defines a definite integral between the Points a and b for function f. N represents the number of trapezoids you want to divide the space between a and b into. You should be getting better approximations for the area under the curve by increasing n.
func LargestCommonDivider ¶
LargestCommonDivider returns the largest common divider between a and b
func LassoRegression ¶
LassoRegression returns the LassoRegression or the l1 regularization to the loss function.
func LinearRegression ¶
LinearRegression returns the optimal line via gradient descent and returns the coefficient and the intercept.
func MaclaurinFor1Over1MinusX ¶
MaclaurinFor1Over1MinusX is designed to estimate 1/(1-x) function via Maclaurin series
func OutOfRange ¶
OutOfRange returns true if index is out of range.
func PartialsForLinReg ¶
PartialsForLinReg returns the
func PlotGaussian ¶
PlotGaussian plots the Gaussian distribution with the default filename of "Gaussian"
func PlotMatrix ¶
PlotMatrix returns the input matrix plotted to a file.
func PlotPoints ¶
PlotPoints plots the Points onto the file. By default it shows the standard deviation on the graph.
func PlotSinusApproximation ¶
PlotSinusApproximation plots the sinus approximation onto file
func PlotTangents ¶
PlotTangents plots the tangent via gradient to the plot
func PlotVector ¶
PlotVector plots the vector onto file.
func PlotVectorAfterMatrixTransformation ¶
PlotVectorAfterMatrixTransformation plots vector before and after matrix transorfmation
func PlotVectors ¶
PlotVectors plots vectors
func PlotsineAndCosine ¶
PlotsineAndCosine plots all four derivates.
func PointInDataset ¶
PointInDataset returns a bool if a Point belongs to the dataset
func PointToVector ¶
PointToVector is a helper function
func RadiansToDegrees ¶
RadiansToDegrees converts radians to degrees
func RidgeRegression ¶
RidgeRegression returns the RidgeRegression or the l2 regularization to the loss function.
func SamePoints ¶
SamePoints returns true if p1 dataset is the same as the p2 dataset.
func SameSign ¶
SameSign returns true if for f(a) and f(b) the values are on the side of the x axis. Either both positive or both negative.
func Seasonality ¶
Seasonality returns the amplitude* seasonalPattern
func Series ¶
Series returns a seasonal plot defined by 5 parameters. X is the actual input, time and slope define the gradient, amplitude is the frequency and noiseLevel is a constant You can use the SeasonalPattern,Seasonality and trend to define this function, but this has been taken care of for you.
func SigmoidPrime ¶
SigmoidPrime returns the derivative of sigmoid.
func SinusEstimate ¶
SinusEstimate returns the Taylor series sinus approximate of X.
func SmallestIndividualError ¶
SmallestIndividualError returns the smallest error of individual Points.
func TanEstimate ¶
TanEstimate returns the Taylor series approximation with polynomial accuracy.
func TriangleArea ¶
TriangleArea returns the area of a triangle via the determinant.
func TrueNegatives ¶
TrueNegatives returns the number of true negative predicted values.
func TruePositivies ¶
TruePositivies returns the number of true positive predicted values.
func VectorToXYs ¶
VectorToXYs is a helper function
Types ¶
type Category ¶
type Category struct {
// contains filtered or unexported fields
}
Category used with KNN algorithm
type Point ¶
Point struct Use the boolean is and categories only if needed.
func HighestAccuracyPolynomial ¶
func HighestAccuracyPolynomial(f func(x float64, polynomial int) float64, fa func(x float64) float64, stPoint, endPoint float64, iterations, uptopolynomial int) ([]Point, int)
HighestAccuracyPolynomial plots the best polynomial approximation of f regarding fa->which should be the actual function. Function returns Points and the polynomial accuracy index.
func PointNearestValue ¶
PointNearestValue returns the Point which is closest to value on the Y axis
type Points ¶
type Points []Point
Points is a slice of Points.
func DefineDataset ¶
DefineDataset returns Points given the inputs. The function will iterate from stPoint to endPoint producing iterations number of Points.
func DefineDatasetPolynomial ¶
func DefineDatasetPolynomial(f func(x float64, polynomial int) float64, stPoint, endPoint float64, iterations, polynomial int) Points
DefineDatasetPolynomial returns an array of Points given the inputs. The function will iterate from stPoint to endPoint with iterations.
func DefineDatasetQuadratic ¶
func DefineDatasetQuadratic(f func(x, a, b, c float64) float64, a, b, c float64, stPoint, endPoint float64, iterations int) Points
DefineDatasetQuadratic defines a quadratic dataset
func DefineDatasetToPower ¶
DefineDatasetToPower is designed to plot Points to the power datasets.
func DefineLinearDataset ¶
DefineLinearDataset returns points given k=slope and n=the intercept from min to max with iterations.
func DefineNormalDistribution ¶
DefineNormalDistribution defines the normal distribution via n which is the number of points, min and max, and the mean and the standard deviaton.
func DefineRandomPoints ¶
DefineRandomPoints returns 'number' of Points between min and max
func DefineWithRandomNoise ¶
func DefineWithRandomNoise(f func(x float64) float64, stPoint, endPoint float64, iterations int) Points
DefineWithRandomNoise generates a dataset based on a function and random noise
func FlipOverXAxis ¶
FlipOverXAxis flips Points over the X axis.
func FlipOverYAxis ¶
FlipOverYAxis flips Points over the Y axis.
func LimitToXDown ¶
LimitToXDown limits Points to an upper X limit.
func LimitToXUpper ¶
LimitToXUpper limits Points to an upper X limit.
func LimitToYDown ¶
LimitToYDown limits Points to an upper X limit.
func LimitToYUpper ¶
LimitToYUpper limits Points to an upper X limit.
func PointsFromArrays ¶
PointsFromArrays returns Points from arrays of x and y coordiantes.
func ReadFromDatafile ¶
ReadFromDatafile reads from the filepath and returns an array of Points.
func RemoveFromIndexDownwards ¶
RemoveFromIndexDownwards removes all Points from index Points downwards from the array
func RemoveFromIndexUpwards ¶
RemoveFromIndexUpwards removes all Points from index Points upwards from the array
func RemoveFromPoints ¶
RemoveFromPoints removes p from Points
func RemovePointAt ¶
RemovePointAt removes Point at index from Points.
func ReverseIndexes ¶
ReverseIndexes flips the array indices.
func RoundPointstoDecimals ¶
RoundPointstoDecimals rounds all Points to decimals accuracy.
func SeriesDataset ¶
SeriesDataset returns Points from inputs and iterations.
func ShiftDatasetOnX ¶
ShiftDatasetOnX shifts the x coordinates by the scalar
func ShiftDatasetOnY ¶
ShiftDatasetOnY shifts the y coordinates by the scalar
func SortPointsByX ¶
SortPointsByX bubble sorts Points, so the Point with the highest X value is the last element of the array.
func SortPointsByY ¶
SortPointsByY bubble sorts Points, so the Point with the highest Y value is the last element of the array.
func Standardize ¶
Standardize standardizes Points so that they are centered and the standard deviation is 1.
func StretchByFactorX ¶
StretchByFactorX streches the x coordinates by the factor. Check how mean and variance change.
func StretchByFactorY ¶
StretchByFactorY streches the x coordinates by the factor. Check how mean and variance change.
func VectorToPoints ¶
VectorToPoints is a helper function