This is the repository of CVLAB toolbox
- Scikit-learn API
importnumpyasnpfromnumpy.randomimportrandint, randfromsklearn.model_selectionimporttrain_test_splitfromsklearn.metricsimportaccuracy_scorefromcvt.modelsimportKernelMSMdim=100n_class=4n_train, n_test=20, 5# input data X is list of vector sets (list of 2d-arrays)X_train= [rand(randint(10, 20), dim) foriinrange(n_train)]
X_test= [rand(randint(10, 20), dim) foriinrange(n_test)]
# labels y is 1d-arrayy_train=randint(0, n_class, n_train)
y_test=randint(0, n_class, n_test)
model=KernelMSM(n_subdims=3, sigma=0.01)
# fitmodel.fit(X_train, y_train)
# predictpred=model.predict(X_test)
print(accuracy_score(pred, y_test))- pip
pip install -U git+https://github.com/ComputerVisionLaboratory/cvlab_toolbox- Follow
PEP8as much as possible - Write a description as docstring
defPCA(X, whiten=False): ''' apply PCA components, explained_variance = PCA(X) Parameters ---------- X: ndarray, shape (n_samples, n_features) matrix of input vectors whiten: boolean if it is True, the data is treated as whitened on each dimensions (average is 0 and variance is 1) Returns ------- components: ndarray, shape (n_features, n_features) the normalized component vectors explained_variance: ndarray, shape (n_features) the variance of each vectors ''' ...
- Make a pull request
- Ask some lab members to review the code
- when all agreements are taken, ask any admin member to merge it