Code
Hub
Workspaces
Following
Trending
Connect
MCP
copy
Create free account
hub
/
github.com/cdipaolo/goml
/ functions
Functions
339 in github.com/cdipaolo/goml
⨍
Functions
339
◇
Types & classes
31
↓ 67 callers
Method
Len
* implement sort.Interface for Frequency list *// Len gives the length of a frequency array
text/tfidf.go:56
↓ 39 callers
Function
abs
(x float64)
perceptron/perceptron_test.go:22
↓ 36 callers
Method
Predict
Predict takes in a variable x (an array of floats,) and finds the value of the hypothesis function given the current parameter vector θ if normalize
cluster/kmeans.go:251
↓ 36 callers
Method
Predict
Predict takes in a variable x (an array of floats,) and finds the value of the hypothesis function given the current parameter vector θ if normalize
cluster/triangle_kmeans.go:261
↓ 32 callers
Function
NormalizePoint
NormalizePoint is the same as Normalize, but it only operates on one singular datapoint, normalizing it's value to unit length.
base/munge.go:23
↓ 30 callers
Function
NewLogistic
NewLogistic takes in a learning rate alpha, a regularization parameter value (0 means no regularization, higher value means higher bias on the model,)
linear/logistic.go:98
↓ 25 callers
Function
NewLeastSquares
NewLeastSquares returns a pointer to the linear model initialized with the learning rate alpha, the training set trainingSet, and the expected results
linear/linear.go:133
↓ 24 callers
Method
Learn
Learn takes the struct's dataset and expected results and runs batch gradient descent on them, optimizing theta so you can predict based on those resu
linear/logistic.go:203
↓ 24 callers
Function
NewSoftmax
NewSoftmax takes in a learning rate alpha, a regularization parameter value (0 means no regularization, higher value means higher bias on the model,)
linear/softmax.go:79
↓ 23 callers
Method
Predict
Predict takes in a variable x (an array of floats,) and finds the value of the hypothesis function given the current parameter vector θ if normalize
linear/logistic.go:179
↓ 22 callers
Method
Learn
Learn takes the struct's dataset and expected results and runs gradient descent on them, optimizing theta so you can predict accurately based on those
linear/softmax.go:198
↓ 22 callers
Function
abs
(x float64)
linear/softmax.go:65
↓ 21 callers
Function
diff
diff returns the square magnitude of the vector subtraction between u and v. This is also known as the Squared Euclidean Distance: diff(u, v) == |u -
cluster/kmeans.go:25
↓ 20 callers
Method
Learn
Learn takes the struct's dataset and expected results and runs batch gradient descent on them, optimizing theta so you can predict based on those resu
linear/linear.go:236
↓ 19 callers
Method
Predict
Predict takes in a variable x (an array of floats,) and finds the value of the hypothesis function given the current parameter vector θ if normalize
linear/linear.go:214
↓ 15 callers
Method
Predict
Predict takes in a variable x (an array of floats,) and finds the value of the hypothesis function given the current parameter vector θ
linear/softmax.go:164
↓ 14 callers
Function
maxI
maxI returns the index of the maximum value of a slice of float64's
linear/softmax_test.go:88
↓ 13 callers
Function
SaveDataToCSV
SaveDataToCSV takes in a absolute filepath, as well as a 2D array of 'X' values and a 1D array of 'Y', or expected values, concatenates the format to
base/data.go:164
↓ 11 callers
Function
NewKernelPerceptron
NewKernelPerceptron takes in a learning rate alpha, the number of features (not including the constant term) being evaluated by the model, the update
perceptron/kernel_perceptron.go:79
↓ 11 callers
Method
OnlineLearn
OnlineLearn runs off of the datastream within the Perceptron structure. Whenever the model makes a wrong prediction the parameter vector theta is upda
perceptron/kernel_perceptron.go:216
↓ 11 callers
Method
Predict
Predict takes in a variable x (an array of floats,) and finds the value of the hypothesis function given the current parameter vector θ
perceptron/kernel_perceptron.go:89
↓ 11 callers
Method
String
String implements the fmt interface for clean printing. Here we're using it to print the model as the equation h(θ)=... where h is the perceptron hypo
text/bayes.go:465
↓ 10 callers
Method
Predict
Predict takes in a document, predicts the class of the document based on the training data passed so far, and returns the class estimated for the docu
text/bayes.go:277
↓ 10 callers
Method
Predict
Predict takes in a variable x (an array of floats,) and finds the value of the hypothesis function given the current parameter vector θ if normalize
cluster/knn.go:176
↓ 9 callers
Function
NewNaiveBayes
NewNaiveBayes returns a NaiveBayes model the given number of classes instantiated, ready to learn off the given data stream. The sanitization function
text/bayes.go:259
↓ 7 callers
Function
LinearKernel
LinearKernel is the base kernel function. It will return a valid kernel for use within models that can use the Kernel Trick. The resultant kernel just
base/kernel.go:58
↓ 7 callers
Function
NewPerceptron
NewPerceptron takes in a learning rate alpha, the number of features (not including the constant term) being evaluated by the model, the update callba
perceptron/perceptron.go:166
↓ 7 callers
Function
Normalize
Normalize takes in an array of arrays of inputs as well as the corresponding array of solutions and normalizes each 'row' of data to unit vector lengt
base/munge.go:14
↓ 7 callers
Method
OnlineLearn
OnlineLearn runs off of the datastream within the Perceptron structure. Whenever the model makes a wrong prediction the parameter vector theta is upda
perceptron/perceptron.go:311
↓ 7 callers
Method
OnlineLearn
OnlineLearn lets the NaiveBayes model learn from the datastream, waiting for new data to come into the stream from a separate goroutine
text/bayes.go:364
↓ 7 callers
Method
Predict
Predict takes in a variable x (an array of floats,) and finds the value of the hypothesis function given the current parameter vector θ
perceptron/perceptron.go:189
↓ 7 callers
Method
Probability
Probability takes in a small document, returns the estimated class of the document based on the model as well as the probability that the model is par
text/bayes.go:325
↓ 6 callers
Method
OnlineLearn
OnlineLearn runs similar to using a fixed dataset with Stochastic Gradient Descent, but it handles data by passing it as a channal, and returns errors
linear/logistic.go:344
↓ 6 callers
Function
insertSorted
insertSorted takes a array v, and inserts u into the list in the position such that the list is sorted inversely. The function will not change the len
cluster/knn.go:136
↓ 5 callers
Function
GaussianKernel
GaussianKernel takes in a parameter for sigma (σ) and returns a valid (Gaussian) Radial Basis Function Kernel. If the input dimensions aren't valid, t
base/kernel.go:17
↓ 5 callers
Method
Get
Get looks up a word from h's Word map and should be used in place of a direct map lookup. The only caveat is that it will always return the 'success'
text/bayes.go:215
↓ 5 callers
Function
NewKMeans
NewKMeans returns a pointer to the k-means model, which clusters given inputs in an unsupervised manner. The algorithm only has one optimization metho
cluster/kmeans.go:163
↓ 5 callers
Function
NewTriangleKMeans
NewTriangleKMeans returns a pointer to the k-means model, which clusters given inputs in an unsupervised manner. The differences between this algorith
cluster/triangle_kmeans.go:183
↓ 5 callers
Method
OnlineLearn
OnlineLearn runs similar to using a fixed dataset with Stochastic Gradient Descent, but it handles data by passing it as a channel, and returns errors
linear/linear.go:368
↓ 5 callers
Method
Tokenize
(string)
text/bayes.go:173
↓ 4 callers
Method
Learn
Learn takes the struct's dataset and expected results and runs batch gradient descent on them, optimizing theta so you can predict based on those resu
cluster/kmeans.go:282
↓ 4 callers
Method
Learn
Learn takes the struct's dataset and expected results and runs batch gradient descent on them, optimizing theta so you can predict based on those resu
cluster/triangle_kmeans.go:390
↓ 4 callers
Function
PolynomialKernel
PolynomialKernel takes in an optional constant (where any extra args passed will be added and count as the constant,) and a main arg of the degree of
base/kernel.go:97
↓ 4 callers
Method
TFIDF
TFIDF returns the TermFrequency- InverseDocumentFrequency of a word within a corpus given by the trained NaiveBayes model Look at the TFIDF docs to s
text/tfidf.go:81
↓ 4 callers
Function
TanhKernel
TanhKernel takes in a required Kappa modifier parameter (defaults to 1.0 if 0.0 given,) and optional float64 args afterwords which will be added toget
base/kernel.go:142
↓ 4 callers
Method
Tokenize
Tokenize splits input sentences into a lowecase slice of strings. The tokenizer's SlitOn string is used as a delimiter and it
text/bayes.go:186
↓ 3 callers
Function
LoadDataFromCSV
LoadDataFromCSV takes in a path to a CSV file and loads that data into a Golang 2D array of 'X' values and a Golang 1D array of 'Y', or expected resul
base/data.go:31
↓ 3 callers
Function
NewKNN
NewKNN returns a pointer to the k-means model, which clusters given inputs in an unsupervised manner. The algorithm only has one optimization method (
cluster/knn.go:96
↓ 3 callers
Method
Predict
Predict takes in a variable x (an array of floats,) and finds the value of the hypothesis function given the current parameter vector θ if normalize
linear/local_linear.go:223
↓ 2 callers
Function
EuclideanDistance
EuclideanDistance returns the distance betweek two float64 vectors. NOTE that this function does not check that the vectors are different lengths (to
base/distance.go:17
↓ 2 callers
Function
GradientAscent
GradientAscent operates on a Ascendable model and further optimizes the parameter vector Theta of the model, which is then used within the Predict fun
base/optimize.go:18
↓ 2 callers
Method
InverseDocumentFrequency
InverseDocumentFrequency returns the 'uniqueness' of a word within the corpus defined within a trained NaiveBayes model. Look at the TFIDF docs to se
text/tfidf.go:174
↓ 2 callers
Method
LearningRate
LearningRate returns the learning rate α to be used in Gradient Descent as the modifier term
base/model.go:128
↓ 2 callers
Function
LoadDataFromCSVToStream
LoadDataFromCSVToStream loads a CSV data file just like LoadDataFromCSV, but it pushes each row into a data channel as it scans. This is useful for ve
base/data.go:95
↓ 2 callers
Function
ManhattanDistance
ManhattanDistance returns the manhattan distance between teo float64 vectors. This is the sum of the differences between each value Example Points: .
base/distance.go:45
↓ 2 callers
Method
MaxIterations
MaxIterations returns the maximum number of iterations to try using gradient ascent. Might return after less if strong convergance is detected, but it
base/model.go:143
↓ 2 callers
Method
MostImportantWords
MostImportantWords runs TFIDF on a whole document, returning the n most important words in the document. If n is greater than the number of words then
text/tfidf.go:96
↓ 2 callers
Function
NewLocalLinear
NewLocalLinear returns a pointer to the linear model initialized with the learning rate alpha, the training set trainingSet, and the expected results
linear/local_linear.go:143
↓ 2 callers
Method
OnlineLearn
OnlineLearn runs similar to using a fixed dataset with Stochastic Gradient Descent, but it handles data by passing it as a channal, and returns errors
linear/softmax.go:422
↓ 2 callers
Method
PersistToFile
PersistToFile takes in an absolute filepath and saves the parameter vector θ to the file, which can be restored later. The function will take paths fr
text/bayes.go:477
↓ 2 callers
Method
Restore
Restore takes the bytes of a NaiveBayes model and restores a model to it. It defaults the sanitizer to base.OnlyWordsAndNumbers and the tokenizer to t
text/bayes.go:506
↓ 2 callers
Method
RestoreFromFile
RestoreFromFile takes in a path to a parameter vector theta and assigns the model it's operating on's parameter vector to that. The only parameters no
text/bayes.go:537
↓ 2 callers
Method
Set
Set sets word k's value to v in h's Word map
text/bayes.go:223
↓ 2 callers
Function
StochasticGradientAscent
StochasticGradientAscent operates on a StochasticAscendable model and further optimizes the parameter vector Theta of the model, which is then used wi
base/optimize.go:75
↓ 2 callers
Method
Theta
Theta returns a pointer to the parameter vector theta, which is 1D vector of floats
base/model.go:137
↓ 2 callers
Method
computeCentroidDistanceMatrix
computeCentroidDistanceMatrix, as said in the function name, computes the centroid distance matrix, saving it to the model. Note that because we only
cluster/triangle_kmeans.go:290
↓ 2 callers
Function
equalStringSlices
(a, b []string)
text/bayes_test.go:393
↓ 2 callers
Method
weight
weight corresponds to the weight given between two datapoints (based on how 'far apart' they are.) w[i] = exp(-1 * |x[i] - x|^2 / 2σ^2)
linear/local_linear.go:347
↓ 1 callers
Method
Dij
Dij returns the derivative of the cost function J(θ) with respect to the j-th parameter of the hypothesis, θ[j], for the training example x[i]. Used i
linear/softmax.go:608
↓ 1 callers
Method
Dij
Dij returns the derivative of the cost function J(θ) with respect to the j-th parameter of the hypothesis, θ[j], for the training example x[i]. Used i
linear/local_linear.go:417
↓ 1 callers
Method
Dij
Dj returns the derivative of the cost function J(θ) with respect to the j-th parameter of the hypothesis, θ[j], for the training example x[i]. Called
base/model.go:165
↓ 1 callers
Method
Dj
Dj returns the partial derivative of the cost function J(θ) with respect to theta[k] where theta is the parameter vector associated with our hypothesi
linear/softmax.go:546
↓ 1 callers
Method
Dj
Dj returns the partial derivative of the cost function J(θ) with respect to theta[j] where theta is the parameter vector associated with our hypothesi
linear/local_linear.go:368
↓ 1 callers
Method
Dj
Dj returns the derivative of the cost function J(θ) with respect to the j-th parameter of the hypothesis, θ[j]. Called as Dj(j)
base/model.go:133
↓ 1 callers
Method
Examples
Examples returns the number of examples in the training set the model is using
base/model.go:159
↓ 1 callers
Method
OnlineLearn
* OnlineLearn implements a variant of the K-Means learning algorithm to work with streams of data. The basis of the model is discusses within this (ht
cluster/kmeans.go:496
↓ 1 callers
Method
PersistToFile
PersistToFile takes in an absolute filepath and saves the parameter vector θ to the file, which can be restored later. The function will take paths fr
linear/linear.go:599
↓ 1 callers
Method
PersistToFile
PersistToFile takes in an absolute filepath and saves the parameter vector θ to the file, which can be restored later. The function will take paths fr
linear/softmax.go:671
↓ 1 callers
Method
PersistToFile
PersistToFile takes in an absolute filepath and saves the parameter vector θ to the file, which can be restored later. The function will take paths fr
linear/logistic.go:556
↓ 1 callers
Method
PersistToFile
PersistToFile takes in an absolute filepath and saves the parameter vector θ to the file, which can be restored later. The function will take paths fr
perceptron/perceptron.go:417
↓ 1 callers
Method
PersistToFile
PersistToFile takes in an absolute filepath and saves the parameter vector θ to the file, which can be restored later. The function will take paths fr
perceptron/kernel_perceptron.go:297
↓ 1 callers
Method
PersistToFile
PersistToFile takes in an absolute filepath and saves the centroid vector to the file, which can be restored later. The function will take paths from
cluster/kmeans.go:603
↓ 1 callers
Method
PersistToFile
PersistToFile takes in an absolute filepath and saves the centroid vector to the file, which can be restored later. The function will take paths from
cluster/triangle_kmeans.go:605
↓ 1 callers
Method
RestoreFromFile
RestoreFromFile takes in a path to a parameter vector theta and assigns the model it's operating on's parameter vector to that. The path must ba an a
linear/linear.go:627
↓ 1 callers
Method
RestoreFromFile
RestoreFromFile takes in a path to a parameter vector theta and assigns the model it's operating on's parameter vector to that. The path must ba an a
linear/softmax.go:699
↓ 1 callers
Method
RestoreFromFile
RestoreFromFile takes in a path to a parameter vector theta and assigns the model it's operating on's parameter vector to that. The path must ba an a
linear/logistic.go:584
↓ 1 callers
Method
RestoreFromFile
RestoreFromFile takes in a path to a parameter vector theta and assigns the model it's operating on's parameter vector to that. The path must ba an a
perceptron/perceptron.go:445
↓ 1 callers
Method
RestoreFromFile
RestoreFromFile takes in a path to a parameter vector theta and assigns the model it's operating on's parameter vector to that. The path must ba an a
perceptron/kernel_perceptron.go:325
↓ 1 callers
Method
RestoreFromFile
RestoreFromFile takes in a path to a centroid vector and assigns the model it's operating on's parameter vector to that. The path must ba an absolute
cluster/kmeans.go:631
↓ 1 callers
Method
RestoreFromFile
RestoreFromFile takes in a path to a centroid vector and assigns the model it's operating on's parameter vector to that. The path must ba an absolute
cluster/triangle_kmeans.go:633
↓ 1 callers
Method
RestoreWithFuncs
RestoreWithFuncs takes raw JSON data of a model and restores a model from it. The tokenizer and sanitizer passed in will be assigned to the restored m
text/bayes.go:513
↓ 1 callers
Method
SaveClusteredData
SaveClusteredData takes operates on a k-means model, concatenating the given dataset with the assigned class from clustering and saving it to file. B
cluster/kmeans.go:586
↓ 1 callers
Method
SaveClusteredData
SaveClusteredData takes operates on a k-means model, concatenating the given dataset with the assigned class from clustering and saving it to file. B
cluster/triangle_kmeans.go:588
↓ 1 callers
Function
TermFrequencies
TermFrequencies gives the TermFrequency of all words in a document, and is more efficient at doing so than calling that function multiple times
text/tfidf.go:143
↓ 1 callers
Method
TermFrequency
TermFrequency returns the term frequency of a word within a corpus defined by the trained NaiveBayes model Look at the TFIDF docs to see more about h
text/tfidf.go:122
↓ 1 callers
Method
recalculateCentroids
recalculateCentroids assigns each centroid to the mean of all points assigned to it. This method is abstracted within the Triangle accelerated KMeans
cluster/triangle_kmeans.go:341
↓ 1 callers
Function
round
round rounds a float64
cluster/knn.go:161
Function
BenchmarkNormalizePoint100Inputs
(b *testing.B)
base/munge_test.go:133
Function
BenchmarkNormalizePoint1Input
* Benchmarks */
base/munge_test.go:104
Function
BenchmarkNormalizePoint200Inputs
(b *testing.B)
base/munge_test.go:146
next →
1–100 of 339, ranked by callers