View on GitHub

Tempura

Tempura documentation page

Table of contents

Tempura.Cluster.Kmeans(n_clusters, init, n_jobs, maxiter, tol)

parameters:

n_clusters : int, default 8, number of clusters

init : string, default "kmeans++", algorithm for initialization of clusters. *init should be "kmeans++" or "random".

n_jobs : int, default 1. the number of process when calculating k-means. *n_jobs > 1 is not implemented now.

maxiter : int, default 300, max iteration of Expectation and Maximization step of EM algorithm.

tol : float, default 0.001, convergence criterion.

fit(X)

parameters:

X : array [n_samples, n_feature], data matrix used for trainig gmm. Each row corresponds to a single data point.

returns:

this : instance of GMM, which has fitted parameters.

Tempura.Mixture.GMM(n_components, n_iter, thresh, min_covar)

parameters:

n_components : int, default 1, the number of components of gmm

n_iter : int, default 100, max iteration of Expectation and Maximization step of EM algorithm.

thresh : float, default 0.01, convergence criterion.

min_covar : float, default 0.01, floor on the diagonal of the covariance matrix to prevent overfitting

fit(X)

parameters:

X : array [n_samples, n_feature], data matrix used for training gmm. Each row corresponds to a single data point.

returns:

this : instance of GMM, which has fitted parameters.

calcLogLikelihood(X)

parameters:

X : array [n_samples, n_feature], data matrix.

returns:

loglikelihood : float, sum of negative log likelihood of given data X.

showParams()

parameters:

: None

returns:

: None

Tempura.Decomposition.PCA(n_components, whiten)

parameters:

n_components : int, default 1, the number of dimension after reduction

whiten : boolean, default false, whether whitening is applied or not

fit(X)

parameters:

X : array [n_samples, n_feature], data matrix to which dimension reduction is applied. Each row corresponds to a single data point.

returns:

this : instance of PCA, which has fitted parameters.

Tempura.CrossDecomposition.CCA(n_components, scale)

parameters:

n_components : int, default 2, the number of dimension of latent space.

normalize : boolean, default true, whether data is centerized and normalized or not

fit(X,Y)

parameters:

X : array [n_samples, n_features], training samples of domain 1

Y : array [n_samples, n_features], training samples of domain 2

*the number of samples of X and Y should be the same.

returns:

this : instance of CCA, which has fitted parameters.

transform(X,Y)

parameters:

X : array [n_samples, n_features], test samples of domain 1

Y : array [n_samples, n_features], test samples of domain 2.

*the number of samples of X and Y should be the same.

returns:

X_score : array [n_samples, n_components], samples of domain1 after projection onto latent space.

Y_score : array [n_samples, n_components], samples of domain2 after projection onto latent space.

Tempura.Neighbors.KNeighborsClassifier(n_neighbors, algorithm, leaf_size, weights)

parameters:

n_neightbors : int, default 5, the number of neighbors used to classify

algorithm : string, default "auto", algorithm of kNN

leaf_size : int, default 30, size of leaf

weights : string, default "uniform", weight of neighbors for prediction

*weights should be "uniform" or "dist".

fit(X, y)

parameters:

X : array [n_samples, n_feature], training data matrix. each row corresponds to a single data point.

y : array [n_samples, 1], target vector. i-th element corresponds to the target value of i-th data of X.

returns:

this : instance of kNN Classifier, which has fitted parameters.

predict(X)

parameters:

X : array [n_samples, n_feature], data matrix used for prediction.

returns:

res : array [n_samples, n_class], (i, j) element corresponds to predicted probability of i-th sample belonging j-th class.

Tempura.LinearModel.LinearRegression(center, normalize, solver)

parameters:

center : boolean, default true, whether data is centerized or not

normalize : boolean, default true, whether data is normalized or not

solver : string, default 'qr', solver used to calculate parameter

*solver should be "lrqr" or "qr".

fit(X, y)

parameters:

X : array [n_samples, n_feature], data matrix for training. each row corresponds to a single data point.

y : array [n_samples, 1], target vector. i-th element corresponds to the target value of i-th data of X.

returns:

this : instance of Ridge Regression, which has fitted parameters.

predict(X)

parameters:

X : array [n_samples, n_feature], data matrix used for prediction.

returns:

pred : array [n_samples, 1], i-th element corresponds to the target value of i-th data of test data.

Tempura.LinearModel.Lasso(lambda, center, normalize, n_iter, tolerance)

parameters:

lambda : float, default 1.0, constant value to avoid overfitting

center : boolean, default true, whether data is centerized or not

normalize : boolean, default true, whether data is normalized or not

n_iter : int, default 1000, the number of iteration

tolerance : int, default 0.0001, convergence criterion of cooridate decent.

fit(X, y)

parameters:

X : array [n_samples, n_feature], data matrix for training. each row corresponds to a single data point.

y : array [n_samples, 1], target vector. i-th element corresponds to the target value of i-th data of X.

returns:

this : instance of Ridge Regression, which has fitted parameters.

predict(X)

parameters:

X : array [n_samples, n_feature], data matrix used for prediction.

returns:

pred : array [n_samples, 1], i-th element corresponds to the target value of i-th data of test data.

Tempura.LinearModel.Ridge(lambda, center, nermalize, solver, n_iter, tolerance)

parameters:

lambda : float, default 1.0, constant value for avoiding overfit

center : boolean, default true, whether data is centerized or not

normalize : boolean, default true, whether data is normalized or not

solver : string, default 'cd', solver used to calculate parameter

*solver should be "lrqr" or "cd" (coordinate decent).

n_iter : int, default 1000, the number of iterations

tolerance : int, default 0.0001, convergence criterion of cooridate decent.

fit(X, y)

parameters:

X : array [n_samples, n_feature], data matrix for training. Each row corresponds to a single data point.

y : array [n_samples, 1], target vector. i-th element corresponds to the target value of i-th data of X.

returns:

this : instance of Ridge Regression, which has fitted parameters.

predict(X)

parameters:

X : array [n_samples, n_feature], data matrix used for prediction.

returns:

pred : array [n_samples, 1], i-th element corresponds to the target value of i-th data of test data.

Tempura.LinearModel.Logistic(eta, alpha, center, n_iter)

parameters:

eta : float, default 0.01, learning rate for delta Error

alpha : float, default 0.015, l2-regularization strength

center : boolean, default true, whether data is centerized or not *center is not implemented.

n_iter : int, default 100, the number of iterations

fit(X, y)

parameters:

X : array [n_samples, n_feature], data matrix for training. each row corresponds to a single data point.

y : array [n_samples, 1], target vector. i-th element corresponds to the target value of i-th data of X.

returns:

this : instance of Logistic Regression, which has fitted parameters.

predict(X)

parameters:

X : array [n_samples, n_feature], data matrix used for prediction.

returns:

pred : array [n_samples, 1], i-th element corresponds to the target value of i-th data of test data.

Tempura.LinearModel.SGDRegressor(algorithm, n_iter, t_zero, aver)

parameters:

algorithm : string, default 'sgdsvm', algorithm for online training

*algorithm should be "sgdsvm" or "perceptron".

n_iter : int, default 1000, the number of iterations

t_zero : float, default 1.0, value to decide step size alpha

aver : boolean, default true, whether averaging is used or not

fit(X, y, init_w)

parameters:

X : array [n_samples, n_feature], data matrix of training samples. Each row corresponds to a single data point.

y : array [n_samples, n_class], label matrix of training samples. Each row corresponds to label information of single data.

init_w : array [n_feature+1, n_class], initial value of weight parameter

returns:

this : instance of Regressor, which has fitted parameters.

predict(X)

parameters:

X : array [n_samples, n_feature], data matrix used for prediction.

returns:

pred : array [n_samples, 1], i-th element corresponds to the target value of i-th data of test data.

Tempura.LinearModel.OnlineLearning.Perceptron(eta, center, n_iter)

parameters:

eta : float, default 1.0, learning rate

center : boolean, default true, whether data is centerized or not

n_iter : int, default 100, the number of iterations

fit(X, y)

parameters:

X : array [n_samples, n_feature], data matrix of training samples. Each row corresponds to a single data point.

y : array [n_samples, 1], label vector of training samples. i-th element corresponds to the target value of i-th data of X.

returns:

this : instance of Perceptron, which has fitted parameters.

predict(X)

parameters:

X : array [n_samples, n_feature], data matrix used for prediction.

returns:

pred : array [n_samples, 1], i-th element corresponds to the target value of i-th data of test data.

Tempura.LinearModel.OnlineLearning.PassiveAggressive(C, mode, n_iter)

parameters:

C : float, default 1.0, parameter which controls the influence of the regularization term

mode : string, default "PA2", mode of passive aggressive *mode should be "PA1" or "PA2".

n_iter : int, default 100, the number of iterations

fit(X, y)

parameters:

X : array [n_samples, n_feature], data matrix of training samples. Each row corresponds to a single data point.

y : array [n_samples, 1], label vector of training samples. i-th element corresponds to the target value of i-th data of X.

returns:

this : instance of Perceptron, which has fitted parameters.

predict(X)

parameters:

X : array [n_samples, n_feature], data matrix used for prediction.

returns:

pred : array [n_samples, 1], i-th element corresponds to the target value of i-th data of test data.

Tempura.LinearModel.OnlineLearning.AdaptiveRegularizationOfWeight(C, mode, n_iter)

parameters:

C : float, default 0.1, parameter which controls the influence of the regularization term

center : boolean, default true, whether data is centerized or not

n_iter : int, default 100, the number of iterations

fit(X, y)

parameters:

X : array [n_samples, n_feature], data matrix of training samples. Each row corresponds to a single data point.

y : array [n_samples, 1], label vector of training samples. i-th element corresponds to the target value of i-th data of X.

returns:

this : instance of Perceptron, which has fitted parameters.

predict(X)

parameters:

X : array [n_samples, n_feature], data matrix used for prediction.

returns:

pred : array [n_samples, 1], i-th element corresponds to the target value of i-th data of test data.

Tempura.LinearModel.OnlineLearning.GaussianHearding(C, center, n_iter)

parameters:

C : float, default 0.1, parameter which controls the influence of the regularization term

center : boolean, default true, whether data is centerized or not

n_iter : int, default 100, the number of iterations

fit(X, y)

parameters:

X : array [n_samples, n_feature], data matrix of training samples. Each row corresponds to a single data point.

y : array [n_samples, 1], label vector of training samples. i-th element corresponds to the target value of i-th data of X.

returns:

this : instance of Perceptron, which has fitted parameters.

predict(X)

parameters:

X : array [n_samples, n_feature], data matrix used for prediction.

returns:

pred : array [n_samples, 1], i-th element corresponds to the target value of i-th data of test data.

Tempura.LinearModel.OnlineLearning.ConfidenceWeighted(eta, center, n_iter)

parameters:

eta : float, default 0.9, probability that the sample is correctly classified

center : boolean, default true, whether data is centerized or not

n_iter : int, default 100, the number of iterations

fit(X, y)

parameters:

X : array [n_samples, n_feature], data matrix of training samples. Each row corresponds to a single data point.

y : array [n_samples, 1], label vector of training samples. i-th element corresponds to the target value of i-th data of X.

returns:

this : instance of Perceptron, which has fitted parameters.

predict(X)

parameters:

X : array [n_samples, n_feature], data matrix used for prediction.

returns:

pred : array [n_samples, 1], i-th element corresponds to the target value of i-th data of test data.

Tempura.LinearModel.OnlineLearning.SoftConfidenceWeighted(eta, C, center, n_iter)

parameters:

eta : float, default 0.9, probability that the sample is correctly classified

C : float, default 0.1, parameter which controls the influence of the regularization term

center : boolean, default true, whether data is centerized or not

n_iter : int, default 100, the number of iterations

fit(X, y)

parameters:

X : array [n_samples, n_feature], data matrix of training samples. Each row corresponds to a single data point.

y : array [n_samples, 1], label vector of training samples. i-th element corresponds to the target value of i-th data of X.

returns:

this : instance of Perceptron, which has fitted parameters.

predict(X)

parameters:

X : array [n_samples, n_feature], data matrix used for prediction.

returns:

pred : array [n_samples, 1], i-th element corresponds to the target value of i-th data of test data.