├── .gitignore ├── .ycm_extra_conf.py ├── CMakeLists.txt ├── LICENSE ├── README.md ├── cmake ├── FindEigen3.cmake ├── old_FindBoost.cmake └── pods.cmake ├── cuda ├── choiceMult_kernel.cu ├── copy_kernel.cu ├── deprecated │ ├── ddpvMFlabels_kernel.cu │ ├── helper_cuda.h │ ├── helper_string.h │ └── vectorSum_kernel.cu ├── gmmPdf_kernel.cu ├── karcherMeans_kernel.cu ├── log_p_kernel.cu ├── sphereMixturePdf_kernel.cu └── sufficientStatistics_kernel.cu ├── data ├── rndSphereDataIwUncertain.csv └── rndSphereDataIwUncertain_gt.lbl ├── doc └── Sub-Clusters.pdf ├── include ├── deprecated │ ├── ddpmeans.hpp │ ├── ddpvMFmeans.hpp │ ├── ddpvMFmeansCUDA.hpp │ ├── dpSubclustersMM.hpp │ ├── dpSubclustersSphereMM.hpp │ ├── dpmeans.hpp │ ├── dpvMFmeans.hpp │ ├── kmeans.hpp │ ├── niwSphere_sampled.h │ ├── niwTangent.hpp │ └── sphericalKMeans.hpp ├── dpMM │ ├── basemeasure.hpp │ ├── cat.hpp │ ├── clGMMData.hpp │ ├── clGMMDataGpu.hpp │ ├── clTGMMDataGpu.hpp │ ├── clusterer.hpp │ ├── crpMM.hpp │ ├── dir.hpp │ ├── dirBaseMeasure.hpp │ ├── dirMM.hpp │ ├── dirMMcld.hpp │ ├── dirMMsplitMerge.hpp │ ├── dirMultiNaiveBayes.hpp │ ├── dirNaiveBayes.hpp │ ├── distribution.hpp │ ├── dpMM.hpp │ ├── dpSubclusterMM.hpp │ ├── dpmmSampler.hpp │ ├── global.hpp │ ├── gpuMatrix.hpp │ ├── iw.hpp │ ├── iwTangent.hpp │ ├── karcherMean.hpp │ ├── lrCluster.hpp │ ├── mult.hpp │ ├── niw.hpp │ ├── niwBaseMeasure.hpp │ ├── niwSphere.hpp │ ├── niwSphereFull.hpp │ ├── normal.hpp │ ├── normalSphere.hpp │ ├── sampler.hpp │ ├── sphere.hpp │ ├── sufficientStatistics.hpp │ ├── timer.hpp │ ├── timerLog.hpp │ ├── typedef.h │ ├── unifSphere.hpp │ ├── vmf.hpp │ ├── vmfBaseMeasure.hpp │ ├── vmfBaseMeasure3D.hpp │ ├── vmfPriorAOne.hpp │ └── vmfPriorFull.hpp ├── dpmmSubclusters │ ├── cluster_sampledT.cpp │ ├── cluster_sampledT.h │ ├── common.h │ ├── linear_algebra.h │ ├── linkedList.cpp │ ├── linkedList.h │ ├── myfuncs.h │ ├── niw_sampled.cpp │ ├── niw_sampled.h │ ├── normal.cpp │ ├── normal.h │ ├── reduction_array.h │ ├── reduction_array2.h │ ├── sample_categorical.h │ └── tableFuncs.h ├── dpmmSubclustersV2 │ ├── README │ ├── clusters.cpp │ └── clusters.h ├── mmf │ ├── mf.hpp │ ├── mfBaseMeasure.hpp │ ├── mfPrior.hpp │ ├── optimizationSO3.hpp │ └── optimizationSO3_approx.hpp └── nvidia │ ├── cuda_global.h │ ├── helper_cuda.h │ └── helper_string.h ├── mathematica ├── SphereExpMap.nb ├── SphereLogMap.nb ├── areaOfHypersphere.nb ├── changeOfVariableJacobianNormLogP.nb ├── changeOfVariablesJacobian.nb └── integralOverMuOnSphereKnownSigma.nb ├── python ├── dpRnMM.py ├── dpSphereMM.py ├── dpView.py ├── dpmmSampler.py ├── evalCompareMethodsOnNYU2.py ├── evalHeldout.py ├── evalHeldoutMnistSun.py ├── evalSphereMMsynthetic.py ├── evalWikiWordVectors.py ├── figures │ ├── TpS.png │ ├── TpS2clusters.png │ ├── TpSGaussian.png │ └── plotTpS.py ├── manifold ├── pytagcloudLocal │ ├── __init__.py │ ├── colors.py │ ├── fonts │ │ ├── Cantarell-Regular.ttf │ │ ├── Cardo99s.ttf │ │ ├── Coustard-Regular.ttf │ │ ├── CrimsonText-Roman.ttf │ │ ├── Cuprum.ttf │ │ ├── DroidSans.ttf │ │ ├── IMFeENrm28P.ttf │ │ ├── Inconsolata.ttf │ │ ├── JosefinSansStd-Light.ttf │ │ ├── Lobster.ttf │ │ ├── Molengo-Regular.ttf │ │ ├── Neucha.ttf │ │ ├── Neuton.ttf │ │ ├── OldStandard-Regular.ttf │ │ ├── PT_Sans-Regular.ttf │ │ ├── Philosopher.ttf │ │ ├── ReenieBeanie.ttf │ │ ├── Tangerine_Regular.ttf │ │ ├── Vollkorn-Regular.ttf │ │ ├── YanoneKaffeesatz-Regular.ttf │ │ ├── fonts.json │ │ └── nobile.ttf │ └── lang │ │ ├── __init__.py │ │ ├── counter.py │ │ ├── stop │ │ ├── arabic │ │ ├── catalan │ │ ├── croatian │ │ ├── czech │ │ ├── danish │ │ ├── dutch │ │ ├── english │ │ ├── esperanto │ │ ├── farsi │ │ ├── finnish │ │ ├── french │ │ ├── german │ │ ├── greek │ │ ├── hebrew │ │ ├── hindi │ │ ├── hungarian │ │ ├── italian │ │ ├── latin │ │ ├── norwegian │ │ ├── polish │ │ ├── portuguese │ │ ├── romanian │ │ ├── russian │ │ ├── slovak │ │ ├── slovenian │ │ ├── spanish │ │ ├── swedish │ │ └── turkish │ │ └── stopwords.py └── rgbd ├── src ├── cat.cpp ├── deprecated │ ├── dpSubclusterGMM.cpp │ ├── dpSubclusterSphereGMM.cpp │ ├── dpSubclustersMM.cpp │ ├── dpSubclustersSphereMM.cpp │ ├── niwSphere_sampled.cpp │ └── niwTangent.cpp ├── dir.cpp ├── dirMultiObsNaiveBayes.cpp ├── dirSphereMM.cpp ├── dpDirMM.cpp ├── dpmmSampler.cpp ├── generateSphericalData.cpp ├── iw.cpp ├── iwTangent.cpp ├── mult.cpp ├── niw.cpp ├── niwSphere.cpp ├── niwSphereFull.cpp ├── normal.cpp ├── optimizationSO3.cpp ├── optimizationSO3_approx.cpp ├── sampler.cpp └── sphere.cpp └── test ├── crpMM.cpp ├── deprecated ├── spkm.cpp └── vMFmeans.cpp ├── dirMM.cpp ├── distributions.cpp ├── dpSubclusterMM.cpp ├── mf.cpp ├── naiveBayes.cpp ├── sampler.cpp ├── sphere.cpp └── test_naiveBayes.cpp /.gitignore: -------------------------------------------------------------------------------- 1 | build 2 | *~ 3 | *.pyc 4 | *.csv 5 | tags 6 | *.swp 7 | *.swo 8 | *.lbl 9 | *.png 10 | .DS_Store 11 | results 12 | copyrightSnipped* 13 | *json 14 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2015 Julian Straub 2 | 3 | Permission is hereby granted, free of charge, to any person obtaining a 4 | copy of this software and associated documentation files (the 5 | "Software"), to deal in the Software without restriction, including 6 | without limitation the rights to use, copy, modify, merge, publish, 7 | distribute, sublicense, and/or sell copies of the Software, and to 8 | permit persons to whom the Software is furnished to do so, subject to 9 | the following conditions: 10 | 11 | The above copyright notice and this permission notice shall be included 12 | in all copies of the Software and its documentation and acknowledgment 13 | shall be given in the documentation and software packages that this 14 | Software was used. 15 | 16 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 17 | OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 18 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 19 | IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 21 | FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 22 | DEALINGS IN THE SOFTWARE. 23 | -------------------------------------------------------------------------------- /cmake/FindEigen3.cmake: -------------------------------------------------------------------------------- 1 | # - Try to find Eigen3 lib 2 | # 3 | # This module supports requiring a minimum version, e.g. you can do 4 | # find_package(Eigen3 3.1.2) 5 | # to require version 3.1.2 or newer of Eigen3. 6 | # 7 | # Once done this will define 8 | # 9 | # EIGEN3_FOUND - system has eigen lib with correct version 10 | # EIGEN3_INCLUDE_DIR - the eigen include directory 11 | # EIGEN3_VERSION - eigen version 12 | 13 | # Copyright (c) 2006, 2007 Montel Laurent, 14 | # Copyright (c) 2008, 2009 Gael Guennebaud, 15 | # Copyright (c) 2009 Benoit Jacob 16 | # Redistribution and use is allowed according to the terms of the 2-clause BSD license. 17 | 18 | if(NOT Eigen3_FIND_VERSION) 19 | if(NOT Eigen3_FIND_VERSION_MAJOR) 20 | set(Eigen3_FIND_VERSION_MAJOR 2) 21 | endif(NOT Eigen3_FIND_VERSION_MAJOR) 22 | if(NOT Eigen3_FIND_VERSION_MINOR) 23 | set(Eigen3_FIND_VERSION_MINOR 91) 24 | endif(NOT Eigen3_FIND_VERSION_MINOR) 25 | if(NOT Eigen3_FIND_VERSION_PATCH) 26 | set(Eigen3_FIND_VERSION_PATCH 0) 27 | endif(NOT Eigen3_FIND_VERSION_PATCH) 28 | 29 | set(Eigen3_FIND_VERSION "${Eigen3_FIND_VERSION_MAJOR}.${Eigen3_FIND_VERSION_MINOR}.${Eigen3_FIND_VERSION_PATCH}") 30 | endif(NOT Eigen3_FIND_VERSION) 31 | 32 | macro(_eigen3_check_version) 33 | file(READ "${EIGEN3_INCLUDE_DIR}/Eigen/src/Core/util/Macros.h" _eigen3_version_header) 34 | 35 | string(REGEX MATCH "define[ \t]+EIGEN_WORLD_VERSION[ \t]+([0-9]+)" _eigen3_world_version_match "${_eigen3_version_header}") 36 | set(EIGEN3_WORLD_VERSION "${CMAKE_MATCH_1}") 37 | string(REGEX MATCH "define[ \t]+EIGEN_MAJOR_VERSION[ \t]+([0-9]+)" _eigen3_major_version_match "${_eigen3_version_header}") 38 | set(EIGEN3_MAJOR_VERSION "${CMAKE_MATCH_1}") 39 | string(REGEX MATCH "define[ \t]+EIGEN_MINOR_VERSION[ \t]+([0-9]+)" _eigen3_minor_version_match "${_eigen3_version_header}") 40 | set(EIGEN3_MINOR_VERSION "${CMAKE_MATCH_1}") 41 | 42 | set(EIGEN3_VERSION ${EIGEN3_WORLD_VERSION}.${EIGEN3_MAJOR_VERSION}.${EIGEN3_MINOR_VERSION}) 43 | if(${EIGEN3_VERSION} VERSION_LESS ${Eigen3_FIND_VERSION}) 44 | set(EIGEN3_VERSION_OK FALSE) 45 | else(${EIGEN3_VERSION} VERSION_LESS ${Eigen3_FIND_VERSION}) 46 | set(EIGEN3_VERSION_OK TRUE) 47 | endif(${EIGEN3_VERSION} VERSION_LESS ${Eigen3_FIND_VERSION}) 48 | 49 | if(NOT EIGEN3_VERSION_OK) 50 | 51 | message(STATUS "Eigen3 version ${EIGEN3_VERSION} found in ${EIGEN3_INCLUDE_DIR}, " 52 | "but at least version ${Eigen3_FIND_VERSION} is required") 53 | endif(NOT EIGEN3_VERSION_OK) 54 | endmacro(_eigen3_check_version) 55 | 56 | if (EIGEN3_INCLUDE_DIR) 57 | 58 | # in cache already 59 | _eigen3_check_version() 60 | set(EIGEN3_FOUND ${EIGEN3_VERSION_OK}) 61 | 62 | else (EIGEN3_INCLUDE_DIR) 63 | 64 | find_path(EIGEN3_INCLUDE_DIR NAMES signature_of_eigen3_matrix_library 65 | PATHS 66 | ${CMAKE_INSTALL_PREFIX}/include 67 | ${KDE4_INCLUDE_DIR} 68 | PATH_SUFFIXES eigen3 eigen 69 | ) 70 | 71 | if(EIGEN3_INCLUDE_DIR) 72 | _eigen3_check_version() 73 | endif(EIGEN3_INCLUDE_DIR) 74 | 75 | include(FindPackageHandleStandardArgs) 76 | find_package_handle_standard_args(Eigen3 DEFAULT_MSG EIGEN3_INCLUDE_DIR EIGEN3_VERSION_OK) 77 | 78 | mark_as_advanced(EIGEN3_INCLUDE_DIR) 79 | 80 | endif(EIGEN3_INCLUDE_DIR) 81 | 82 | -------------------------------------------------------------------------------- /cuda/copy_kernel.cu: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2015, Julian Straub 2 | * Licensed under the MIT license. See the license file LICENSE. 3 | */ 4 | 5 | #include 6 | 7 | // executions per thread 8 | #define N_PER_T 32 9 | #define BLOCK_SIZE 256 10 | 11 | template 12 | uint32_t N, uint32_t step, uint32_t offset) 13 | { 14 | // const int tid = threadIdx.x; 15 | const int idx = threadIdx.x + blockDim.x * blockIdx.x; 16 | 17 | for(int id=idx*N_PER_T; id DIM*K+DIM*(DIM-1)*K); 32 | 33 | dim3 threads(BLK_SIZE,1,1); 34 | dim3 blocks(N/(BLK_SIZE*N_PER_T)+(N%(BLK_SIZE*N_PER_T)>0?1:0),1,1); 35 | if(D == 1){ 36 | copy_kernel<<>>( 37 | d_from, d_to, N, step,offset); 38 | }else if(D==2){ 39 | copy_kernel<<>>( 40 | d_from, d_to, N, step,offset); 41 | }else if(D==3){ 42 | copy_kernel<<>>( 43 | d_from, d_to, N, step,offset); 44 | }else if(D==4){ 45 | copy_kernel<<>>( 46 | d_from, d_to, N, step,offset); 47 | }else if(D==5){ 48 | copy_kernel<<>>( 49 | d_from, d_to, N, step,offset); 50 | }else if(D==6){ 51 | copy_kernel<<>>( 52 | d_from, d_to, N, step,offset); 53 | }else{ 54 | assert(false); 55 | } 56 | } 57 | 58 | extern void copy_gpu( float *d_from, float *d_to , uint32_t N, 59 | uint32_t step, uint32_t offset, uint32_t D) 60 | { 61 | const uint32_t BLK_SIZE = BLOCK_SIZE; 62 | assert(BLK_SIZE > DIM*K+DIM*(DIM-1)*K); 63 | 64 | dim3 threads(BLK_SIZE,1,1); 65 | dim3 blocks(N/(BLK_SIZE*N_PER_T)+(N%(BLK_SIZE*N_PER_T)>0?1:0),1,1); 66 | if(D == 1){ 67 | copy_kernel<<>>( 68 | d_from, d_to, N, step,offset); 69 | }else if(D==2){ 70 | copy_kernel<<>>( 71 | d_from, d_to, N, step,offset); 72 | }else if(D==3){ 73 | copy_kernel<<>>( 74 | d_from, d_to, N, step,offset); 75 | }else if(D==4){ 76 | copy_kernel<<>>( 77 | d_from, d_to, N, step,offset); 78 | }else if(D==5){ 79 | copy_kernel<<>>( 80 | d_from, d_to, N, step,offset); 81 | }else if(D==6){ 82 | copy_kernel<<>>( 83 | d_from, d_to, N, step,offset); 84 | }else{ 85 | assert(false); 86 | } 87 | } 88 | 89 | extern void copy_gpu( uint32_t *d_from, uint32_t *d_to , uint32_t N, 90 | uint32_t step, uint32_t offset, uint32_t D) 91 | { 92 | const uint32_t BLK_SIZE = BLOCK_SIZE; 93 | assert(BLK_SIZE > DIM*K+DIM*(DIM-1)*K); 94 | 95 | dim3 threads(BLK_SIZE,1,1); 96 | dim3 blocks(N/(BLK_SIZE*N_PER_T)+(N%(BLK_SIZE*N_PER_T)>0?1:0),1,1); 97 | if(D == 1){ 98 | copy_kernel<<>>( 99 | d_from, d_to, N, step,offset); 100 | }else if(D==2){ 101 | copy_kernel<<>>( 102 | d_from, d_to, N, step,offset); 103 | }else if(D==3){ 104 | copy_kernel<<>>( 105 | d_from, d_to, N, step,offset); 106 | }else if(D==4){ 107 | copy_kernel<<>>( 108 | d_from, d_to, N, step,offset); 109 | }else if(D==5){ 110 | copy_kernel<<>>( 111 | d_from, d_to, N, step,offset); 112 | }else if(D==6){ 113 | copy_kernel<<>>( 114 | d_from, d_to, N, step,offset); 115 | }else{ 116 | assert(false); 117 | } 118 | } 119 | 120 | -------------------------------------------------------------------------------- /cuda/deprecated/vectorSum_kernel.cu: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2015, Julian Straub 2 | * Licensed under the MIT license. See the license file LICENSE. 3 | */ 4 | 5 | 6 | #include "cuda_global.h" 7 | 8 | // executions per thread 9 | #define N_PER_T 32 10 | #define BLOCK_SIZE 256 11 | //#define K 6 12 | #define SS_DIM (DIM+1) 13 | 14 | template 15 | __global__ void vectorSum_kernel(T *d_x, 16 | uint32_t *z, uint32_t N, uint32_t k0, T *SSs) 17 | { 18 | // sufficient statistics for whole blocksize 19 | // 2 (x in TpS @north) + 1 (count) + 4 (outer product in TpS @north) 20 | // all fo that times 6 for the different axes 21 | __shared__ T xSSs[BLK_SIZE*SS_DIM*K]; 22 | 23 | //const int tid = threadIdx.x; 24 | const int tid = threadIdx.x; 25 | const int idx = threadIdx.x + blockDim.x * blockIdx.x; 26 | 27 | // caching 28 | #pragma unroll 29 | for(int s=0; s< K*SS_DIM; ++s) { 30 | // this is almost certainly bad ordering 31 | xSSs[tid*K*SS_DIM+s] = 0.0f; 32 | } 33 | __syncthreads(); // make sure that ys have been cached 34 | 35 | for(int id=idx*N_PER_T; id1; s>>=1) { 56 | if(tid < s) 57 | { 58 | const uint32_t si = s*K*SS_DIM; 59 | const uint32_t tidk = tid*K*SS_DIM; 60 | #pragma unroll 61 | for( int k=0; k(&SSs[tid],xSSs[tid]+xSSs[tid+K*SS_DIM]); 70 | } 71 | } 72 | 73 | extern void vectorSum_gpu( double *d_x, uint32_t *d_z , uint32_t N, 74 | uint32_t k0, uint32_t K, double *d_SSs) 75 | { 76 | const uint32_t BLK_SIZE = BLOCK_SIZE/2; 77 | assert(BLK_SIZE > DIM*K+DIM*(DIM-1)*K); 78 | 79 | dim3 threads(BLK_SIZE,1,1); 80 | dim3 blocks(N/(BLK_SIZE*N_PER_T)+(N%(BLK_SIZE*N_PER_T)>0?1:0),1,1); 81 | if(K == 1){ 82 | vectorSum_kernel<<>>( 83 | d_x, d_z,N,k0,d_SSs); 84 | }else if(K==2){ 85 | vectorSum_kernel<<>>( 86 | d_x, d_z,N,k0,d_SSs); 87 | }else if(K==3){ 88 | vectorSum_kernel<<>>( 89 | d_x, d_z,N,k0,d_SSs); 90 | }else if(K==4){ 91 | vectorSum_kernel<<>>( 92 | d_x, d_z,N,k0,d_SSs); 93 | }else if(K==5){ 94 | vectorSum_kernel<<>>( 95 | d_x, d_z,N,k0,d_SSs); 96 | }else if(K==6){ 97 | vectorSum_kernel<<>>( 98 | d_x, d_z,N,k0,d_SSs); 99 | }else{ 100 | assert(false); 101 | } 102 | checkCudaErrors(cudaDeviceSynchronize()); 103 | }; 104 | 105 | extern void vectorSum_gpu(float *d_x, uint32_t *d_z, 106 | uint32_t N, uint32_t k0, uint32_t K, float *d_SSs) 107 | { 108 | const uint32_t BLK_SIZE = BLOCK_SIZE; 109 | assert(BLK_SIZE > DIM*K+DIM*(DIM-1)*K); 110 | 111 | dim3 threads(BLK_SIZE,1,1); 112 | dim3 blocks(N/(BLK_SIZE*N_PER_T)+(N%(BLK_SIZE*N_PER_T)>0?1:0),1,1); 113 | if(K == 1){ 114 | vectorSum_kernel<<>>( 115 | d_x, d_z,N,k0,d_SSs); 116 | }else if(K==2){ 117 | vectorSum_kernel<<>>( 118 | d_x, d_z,N,k0,d_SSs); 119 | }else if(K==3){ 120 | vectorSum_kernel<<>>( 121 | d_x, d_z,N,k0,d_SSs); 122 | }else if(K==4){ 123 | vectorSum_kernel<<>>( 124 | d_x, d_z,N,k0,d_SSs); 125 | }else if(K==5){ 126 | vectorSum_kernel<<>>( 127 | d_x, d_z,N,k0,d_SSs); 128 | }else if(K==6){ 129 | vectorSum_kernel<<>>( 130 | d_x, d_z,N,k0,d_SSs); 131 | }else{ 132 | assert(false); 133 | } 134 | checkCudaErrors(cudaDeviceSynchronize()); 135 | }; 136 | 137 | -------------------------------------------------------------------------------- /cuda/gmmPdf_kernel.cu: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2015, Julian Straub 2 | * Licensed under the MIT license. See the license file LICENSE. 3 | */ 4 | 5 | 6 | #include 7 | 8 | // executions per thread 9 | #define N_PER_T 32 10 | #define BLOCK_SIZE 256 11 | #define K 6 12 | 13 | 14 | template 15 | __global__ void gmmPdf_3D(T * d_x, T *d_invSigmas, T *d_logNormalizer, 16 | T *d_logPi, T* d_logPdf, uint32_t N) 17 | { 18 | __shared__ T logNorm[K]; 19 | 20 | const int tid = threadIdx.x; 21 | const int idx = threadIdx.x + blockDim.x * blockIdx.x; 22 | 23 | // caching 24 | if(tid < K) logNorm[tid] = d_logNormalizer[tid]; 25 | __syncthreads(); // make sure that ys have been cached 26 | 27 | for(uint32_t id=idx*N_PER_T; id 56 | __global__ void gmmPdf(T * d_x, 57 | T *d_invSigmas, T *d_logNormalizer, T *d_logPi, 58 | T* d_logPdf, uint32_t N) 59 | { 60 | __shared__ T logNorm[K]; 61 | 62 | const int tid = threadIdx.x; 63 | const int idx = threadIdx.x + blockDim.x * blockIdx.x; 64 | 65 | // caching 66 | if(tid < K) logNorm[tid] = d_logNormalizer[tid]; 67 | __syncthreads(); // make sure that ys have been cached 68 | 69 | for(uint32_t id=idx*N_PER_T; id K*(DIM+1)); 107 | 108 | dim3 threads(BLOCK_SIZE,1,1); 109 | dim3 blocks(N/(BLOCK_SIZE*N_PER_T)+(N%(BLOCK_SIZE*N_PER_T)>0?1:0),1,1); 110 | if(DIM ==3) 111 | gmmPdf_3D<<>>(d_x,d_invSigmas, 112 | d_logNormalizers,d_logPi,d_logPdf,N); 113 | else 114 | gmmPdf<<>>(d_x,d_invSigmas, 115 | d_logNormalizers,d_logPi,d_logPdf,N); 116 | checkCudaErrors(cudaDeviceSynchronize()); 117 | }; 118 | 119 | 120 | extern void gmmPdf(float * d_x, float *d_invSigmas, 121 | float *d_logNormalizers, float *d_logPi, float* d_logPdf, uint32_t N, 122 | uint32_t K_) 123 | { 124 | assert(K_==K); 125 | assert(BLOCK_SIZE > K*(DIM+1)); 126 | 127 | dim3 threads(BLOCK_SIZE,1,1); 128 | dim3 blocks(N/(BLOCK_SIZE*N_PER_T)+(N%(BLOCK_SIZE*N_PER_T)>0?1:0),1,1); 129 | if(DIM ==3) 130 | gmmPdf_3D<<>>(d_x,d_invSigmas, 131 | d_logNormalizers,d_logPi,d_logPdf,N); 132 | else 133 | gmmPdf<<>>(d_x,d_invSigmas, 134 | d_logNormalizers,d_logPi,d_logPdf,N); 135 | checkCudaErrors(cudaDeviceSynchronize()); 136 | }; 137 | -------------------------------------------------------------------------------- /cuda/log_p_kernel.cu: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2015, Julian Straub 2 | * Licensed under the MIT license. See the license file LICENSE. 3 | */ 4 | 5 | 6 | #include 7 | 8 | template 9 | __global__ void Log_p_kernel_noBuff(T *p, T *q, T *Rs, uint32_t *z, 10 | uint32_t K, uint32_t N, T *x) 11 | { 12 | const uint32_t idx=threadIdx.x + blockIdx.x*blockDim.x; 13 | 14 | if(idx < N) 15 | { 16 | T xD_i[DIM]; 17 | uint32_t k=z[idx]; 18 | T *pk = p+k*DIM; 19 | T *q_i = q+idx*DIM; 20 | // // precompute dot, sinc 21 | // T qiTp = q_i[0]*p_i[0]; 22 | // #pragma unroll 23 | // for(uint32_t i=1; i(pk,q_i,xD_i); 36 | T *x_i = x+idx*(DIM-1); 37 | T *R = Rs+k*DIM*(DIM-1); // last row of Rs is not transmitted, since we dont need 38 | // rotate to north 39 | #pragma unroll 40 | for(uint32_t i=0; i 51 | __global__ void Log_p_kernel_3D(T *p, T *q, T *Rs, uint32_t *z, 52 | uint32_t K, uint32_t N, T *x) 53 | { 54 | const uint32_t idx=threadIdx.x + blockIdx.x*blockDim.x; 55 | 56 | if(idx < N) 57 | { 58 | T xD_i[3]; 59 | uint32_t k=z[idx]; 60 | T *pk = p+k*3; 61 | T *q_i = q+idx*3; 62 | Log_p(pk,q_i,xD_i); 63 | T *x_i = x+idx*(2); 64 | T *R = Rs+k*3*(2); // last row of Rs is not transmitted, since we dont need 65 | // rotate to north 66 | x_i[0] = R[0]*xD_i[0] + R[2]*xD_i[1] + R[4]*xD_i[2]; 67 | x_i[1] = R[1]*xD_i[0] + R[3]*xD_i[1] + R[5]*xD_i[2]; 68 | } 69 | } 70 | 71 | /* 72 | * assumes p,q,x are column major 73 | */ 74 | template 75 | __global__ void Log_p_kernel(T *p, T *q, T *Rs, uint32_t *z, 76 | uint32_t K, uint32_t N, T *x) 77 | { 78 | const uint32_t idx=threadIdx.x + blockIdx.x*blockDim.x; 79 | 80 | if(idx < N) 81 | { 82 | T p_i[DIM]; 83 | T q_i[DIM]; 84 | T xD_i[DIM]; 85 | T x_i[DIM-1]; 86 | 87 | T R[DIM*(DIM-1)]; 88 | uint32_t k=z[idx]; 89 | T *pp_i = p+k*DIM; 90 | T *qq_i = q+idx*DIM; 91 | T *Rk = Rs+k*DIM*(DIM-1); // last row of Rs is not transmitted, since we dont need 92 | 93 | #pragma unroll 94 | for(uint32_t i=0; i0?1:0), 1,1); 140 | if(DIM ==3) 141 | // interestingly not faster than nDIM 142 | Log_p_kernel_3D<<>>(p,q,Rs,z,K,N,x); 143 | else 144 | Log_p_kernel_noBuff<<>>(p,q,Rs,z,K,N,x); 145 | checkCudaErrors(cudaDeviceSynchronize()); 146 | } 147 | 148 | extern void Log_p_gpu(float *p, float *q, float *Rs, uint32_t *z, 149 | uint32_t K, uint32_t N, float *x) 150 | { 151 | dim3 threads(256,1,1); 152 | dim3 blocks(N/256+(N%256>0?1:0), 1,1); 153 | if(DIM ==3) 154 | // interestingly not faster than nDIM 155 | Log_p_kernel_3D<<>>(p,q,Rs,z,K,N,x); 156 | else 157 | Log_p_kernel_noBuff<<>>(p,q,Rs,z,K,N,x); 158 | checkCudaErrors(cudaDeviceSynchronize()); 159 | } 160 | -------------------------------------------------------------------------------- /doc/Sub-Clusters.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jstraub/dpMM/538c432d5f98c040d5c1adb072e545e38f97fc69/doc/Sub-Clusters.pdf -------------------------------------------------------------------------------- /include/deprecated/dpmeans.hpp: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2015, Julian Straub 2 | * Licensed under the MIT license. See the license file LICENSE. 3 | */ 4 | #pragma once 5 | 6 | #include 7 | #include 8 | 9 | #include 10 | #include 11 | 12 | #include "kmeans.hpp" 13 | 14 | using namespace Eigen; 15 | using std::cout; 16 | using std::endl; 17 | 18 | template 19 | class DPMeans : public KMeans 20 | { 21 | public: 22 | DPMeans(const boost::shared_ptr >& spx, uint32_t K0, 23 | double lambda, boost::mt19937* pRndGen); 24 | virtual ~DPMeans(); 25 | 26 | // void initialize(const Matrix& x); 27 | 28 | virtual void updateLabels(); 29 | virtual void updateCenters(); 30 | 31 | virtual uint32_t indOfClosestCluster(int32_t i); 32 | 33 | protected: 34 | double lambda_; 35 | }; 36 | 37 | // -------------------------------- impl ---------------------------------- 38 | template 39 | DPMeans::DPMeans(const boost::shared_ptr >& spx, 40 | uint32_t K0, double lambda, boost::mt19937* pRndGen) 41 | : KMeans(spx,K0,pRndGen), lambda_(lambda) 42 | {} 43 | 44 | template 45 | DPMeans::~DPMeans() 46 | {} 47 | 48 | template 49 | uint32_t DPMeans::indOfClosestCluster(int32_t i) 50 | { 51 | int z_i = this->K_; 52 | T sim_closest = lambda_; 53 | for (uint32_t k=0; kK_; ++k) 54 | { 55 | T sim_k = this->dist(this->ps_.col(k), this->spx_->col(i)); 56 | if(this->closer(sim_k, sim_closest)) 57 | { 58 | sim_closest = sim_k; 59 | z_i = k; 60 | } 61 | } 62 | return z_i; 63 | } 64 | 65 | template 66 | void DPMeans::updateLabels() 67 | { 68 | //#pragma omp parallel for 69 | // TODO not sure how to parallelize 70 | for(uint32_t i=0; iN_; ++i) 71 | { 72 | uint32_t z_i = indOfClosestCluster(i); 73 | 74 | if(z_i == this->K_) 75 | { 76 | this->ps_.conservativeResize(this->D_,this->K_+1); 77 | this->Ns_.conservativeResize(this->K_+1); 78 | this->ps_.col(this->K_) = this->spx_->col(i); 79 | this->Ns_(this->K_) = 1.; 80 | this->K_ ++; 81 | } 82 | this->z_(i) = z_i; 83 | } 84 | }; 85 | 86 | template 87 | void DPMeans::updateCenters() 88 | { 89 | vector toDelete(this->K_,false); 90 | #pragma omp parallel for 91 | for(uint32_t k=0; kK_; ++k) 92 | { 93 | this->ps_.col(k) = this->computeCenter(k); 94 | if (this->Ns_(k) <= 0) 95 | toDelete[k] = true; 96 | } 97 | 98 | uint32_t kNew = this->K_; 99 | for(int32_t k=this->K_-1; k>-1; --k) 100 | if(toDelete[k]) 101 | { 102 | cout<<"cluster k "<N_; ++i) 105 | { 106 | if(static_cast(this->z_(i)) >= k) this->z_(i)--; 107 | } 108 | kNew --; 109 | } 110 | 111 | Matrix psNew(this->D_,kNew); 112 | int32_t offset = 0; 113 | for(uint32_t k=0; kK_; ++k) 114 | if(toDelete[k]) 115 | { 116 | offset ++; 117 | }else{ 118 | psNew.col(k-offset) = this->ps_.col(k); 119 | } 120 | this->ps_ = psNew; 121 | this->K_ = kNew; 122 | }; 123 | -------------------------------------------------------------------------------- /include/deprecated/niwTangent.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | #include 6 | #include 7 | 8 | #include 9 | #include 10 | 11 | #include "basemeasure.hpp" 12 | #include "distribution.hpp" 13 | #include "normalSphere.hpp" 14 | #include "niw.hpp" 15 | #include "sphere.hpp" 16 | #include "karcherMean.hpp" 17 | #include "clData.hpp" 18 | 19 | using namespace Eigen; 20 | using std::endl; 21 | using std::cout; 22 | 23 | template 24 | class NiwTangent : public BaseMeasure 25 | { 26 | public: 27 | 28 | NIW niw0_; // IW prior on the covariance of the normal in T_\muS^D 29 | Sphere S_; 30 | NormalSphere normalS_; // normal on sphere 31 | 32 | NiwTangent(const NIW& niw, boost::mt19937* pRndGen); 33 | ~NiwTangent(); 34 | 35 | virtual baseMeasureType getBaseMeasureType() const {return(NIW_TANGENT); } 36 | 37 | virtual BaseMeasure* copy(); 38 | virtual NiwTangent* copyNative(); 39 | 40 | /* for any point on the sphere; maps into T_muS and rotates north first */ 41 | virtual T logLikelihood(const Matrix& x) const ; 42 | virtual T logLikelihood(const Matrix& x, uint32_t i) const 43 | {return logLikelihood(x.col(i));}; 44 | /* assumes x is already in T_northS */ 45 | virtual T logLikelihoodNorth(const Matrix& x) const ; 46 | 47 | void posterior(const Matrix& x, const VectorXu& z, 48 | uint32_t k); 49 | void posterior(const shared_ptr >& cldp, uint32_t k); 50 | /* assumes the x are already in T_northS correctly */ 51 | void posteriorFromPtsInTpS(const Matrix& x, 52 | const VectorXu& z, uint32_t k); 53 | 54 | void sample(); 55 | 56 | T logPdfUnderPrior() const; 57 | T logPdfUnderPriorMarginalized() const; 58 | T logPdfUnderPriorMarginalizedMerged(const shared_ptr >& other) const; 59 | 60 | void print() const; 61 | 62 | virtual NiwTangent* merge(const NiwTangent& other); 63 | void fromMerge(const NiwTangent& niwA, const NiwTangent& niwB); 64 | 65 | const Matrix& scatter() const {return niw0_.scatter();}; 66 | Matrix& scatter() {return niw0_.scatter();}; 67 | T count() const {return niw0_.count();}; 68 | T& count() {return niw0_.count();}; 69 | 70 | const Matrix& Sigma() const {return normalS_.Sigma();}; 71 | 72 | const Matrix& getMean() const {return normalS_.getMean();}; 73 | void setMean(const Matrix& mean) {return normalS_.setMean(mean);}; 74 | 75 | // extension 76 | Matrix qqTSum_; // \sum q_i q_i^T 77 | Matrix qqTAngSum_; // \sum q_i q_i^T * theta_{q_i \mu} 78 | Matrix qqTAngSqSum_; // \sum q_i q_i^T * theta_{q_i \mu}^2 79 | Matrix qSum_; // \sum q_i 80 | Matrix qSumAngle_; // \sum q_i* theta_{q_i \mu} 81 | Matrix qSumAngleSq_; // \sum q_i* theta_{q_i \mu}^2 82 | T sumAngle_; // \sum theta_{q_i \mu} 83 | T sumAngleSq_; // \sum theta_{q_i \mu}^2 84 | 85 | Matrix scatterCorrection1(const Matrix& p) const; 86 | virtual uint32_t getDim() const {return(normalS_.D_);}; 87 | private: 88 | 89 | void computeMergedSS( const NiwTangent& niwA, 90 | const NiwTangent& niwB, Matrix& scatterM, 91 | Matrix& meanM, Matrix& pM, T& countM) const; 92 | 93 | // sufficient statistics 94 | Matrix scatter_; 95 | T count_; 96 | 97 | }; 98 | 99 | typedef NiwTangent NiwTangentd; 100 | typedef NiwTangent NiwTangentf; 101 | 102 | -------------------------------------------------------------------------------- /include/dpMM/basemeasure.hpp: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2015, Julian Straub , Randi Cabezas 2 | * Licensed under the MIT license. See the license file LICENSE. 3 | */ 4 | #pragma once 5 | 6 | #include 7 | #include 8 | #include 9 | 10 | #include 11 | #include 12 | 13 | using namespace Eigen; 14 | using std::cout; 15 | using std::endl; 16 | 17 | //TODO add to remaining classes. I added them to the ones I found.. RC 10/29/14. 18 | enum baseMeasureType {BASE, NIW_SAMPLED, NIW_MARGINALIZED, 19 | DIR_SAMPLED, NIW_TANGENT, NIW_SPHERE, 20 | NIW_SPHERE_FULL, UNIF_SPHERE, MF_T}; 21 | 22 | 23 | template 24 | class BaseMeasure 25 | { 26 | public: 27 | BaseMeasure() 28 | {}; 29 | virtual ~BaseMeasure() 30 | {}; 31 | 32 | virtual baseMeasureType getBaseMeasureType() const {return(BASE); } 33 | 34 | virtual BaseMeasure* copy() = 0; 35 | 36 | // log likelihood under the model sampled from this base measure 37 | virtual T logLikelihood(const Matrix& x) const =0; 38 | virtual T logLikelihood(const Matrix& x, uint32_t i) const 39 | {return logLikelihood(x.col(i));}; 40 | 41 | //adding this here to let derived classes to work with SS rather than data 42 | virtual T logLikelihoodFromSS(const Matrix& x) const 43 | {assert(false); return(T(1e20));} 44 | virtual void posteriorFromSS(const vector >&x, const VectorXu& z, uint32_t k) 45 | {assert(false);} 46 | virtual void posteriorFromSS(const Matrix &x) 47 | {assert(false);} 48 | 49 | 50 | // sample new model from the possterior under this base measure 51 | virtual void posterior(const Matrix&x, const VectorXu& z, 52 | uint32_t k) =0; 53 | virtual void posterior(const vector >&x, const VectorXu& z, 54 | uint32_t k) 55 | {assert(false);}; 56 | virtual void posterior(const boost::shared_ptr >& cldp, uint32_t k) 57 | {assert(false);}; 58 | 59 | 60 | // log pdf value of the current model under the base measure 61 | virtual T logPdfUnderPrior() const =0; 62 | 63 | // log pdf value of the data point under the base measure (integrated over 64 | // model parameters - could use Monte carlo integration if not analytic) 65 | virtual T logPdfUnderPriorMarginalized(const Matrix& x) {return 0.;}; 66 | // log pdf value of the data point under the base measure using the 67 | // sufficient statistics stored with the base measure 68 | virtual T logPdfUnderPriorMarginalized() const {return 0;}; 69 | 70 | virtual void print() const =0; 71 | virtual uint32_t getDim() const =0; // {return(0);}; 72 | 73 | // //TODO UGLY 74 | // virtual Matrix& scatter() 75 | // {assert(false); return Matrix::Zero(1,1);}; 76 | // //TODO UGLY 77 | // virtual T& count() 78 | // {assert(false); return 0;}; 79 | }; 80 | 81 | 82 | -------------------------------------------------------------------------------- /include/dpMM/cat.hpp: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2015, Julian Straub 2 | * Licensed under the MIT license. See the license file LICENSE. 3 | */ 4 | 5 | #pragma once 6 | 7 | #include 8 | #include 9 | #include 10 | 11 | //#include 12 | //#include 13 | #include 14 | 15 | #include 16 | #include 17 | 18 | using namespace Eigen; 19 | using std::cout; 20 | using std::endl; 21 | 22 | template 23 | class Cat : public Distribution 24 | { 25 | public: 26 | uint32_t K_; 27 | Matrix pdf_; 28 | Matrix cdf_; 29 | 30 | /* constructor from pdf */ 31 | Cat(const Matrix& pdf, boost::mt19937 *pRndGen); 32 | /* constructor from indicators - estimates from counts */ 33 | Cat(const VectorXu& z, boost::mt19937 *pRndGen); 34 | /* copy constructor */ 35 | Cat(const Cat& other); 36 | virtual ~Cat(); 37 | 38 | uint32_t sample(); 39 | void sample(VectorXu& z); 40 | 41 | T logPdf(const Matrix& x) const 42 | { 43 | //assuming x is all zeros except one element 44 | assert(x.rows()==K_); //data dimmension should agree with # categories 45 | for(uint32_t d=0; d& x) const 61 | { 62 | 63 | assert(x.rows()==K_); //data dimmension should agree with # categories 64 | T logPdf = 0; 65 | for(uint32_t d=0; d& pdf() const {return pdf_;}; 72 | void pdf(const Matrix& pdf){ 73 | pdf_ = pdf; 74 | updateCdf(); 75 | }; 76 | const Matrix& cdf() const {return cdf_;}; 77 | 78 | void print() const; 79 | 80 | private: 81 | boost::uniform_01 unif_; 82 | void updateCdf(); 83 | }; 84 | 85 | typedef Cat Catf; 86 | typedef Cat Catd; 87 | 88 | template 89 | inline T logSumExpRow(const Matrix& pdf, uint32_t i) 90 | { 91 | T max = pdf.row(i).maxCoeff(); 92 | return log((pdf.row(i).array()-max).exp().matrix().sum()) + max; 93 | } 94 | 95 | template 96 | inline T logSumExpCol(const Matrix& pdf, uint32_t i) 97 | { 98 | T max = pdf.col(i).maxCoeff(); 99 | return log((pdf.col(i).array()-max).exp().matrix().sum()) + max; 100 | } 101 | 102 | 103 | template 104 | inline T logSumExp(const Matrix& pdf) 105 | { 106 | T max = pdf.maxCoeff(); 107 | return log((pdf.array()-max).exp().matrix().sum()) + max; 108 | } 109 | 110 | //template 111 | //inline T logSumExp(const Matrix& pdf) 112 | //{ 113 | // T max = pdf.maxCoeff(); 114 | // return log((pdf.array()-max).exp().matrix().sum()) + max; 115 | //} 116 | 117 | -------------------------------------------------------------------------------- /include/dpMM/clusterer.hpp: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2015, Julian Straub 2 | * Licensed under the MIT license. See the license file LICENSE. 3 | */ 4 | #pragma once 5 | 6 | 7 | #include 8 | //#include 9 | //#include 10 | 11 | #include 12 | 13 | using namespace Eigen; 14 | 15 | template 16 | class Clusterer 17 | { 18 | public: 19 | Clusterer(const boost::shared_ptr >& spx, uint32_t K, 20 | boost::mt19937* pRndGen); 21 | virtual ~Clusterer(); 22 | 23 | // void initialize(const Matrix& x); 24 | 25 | virtual void updateLabels() = 0; 26 | virtual void updateCenters() = 0; 27 | virtual MatrixXu mostLikelyInds(uint32_t n, 28 | Matrix& deviates) = 0; 29 | virtual T avgIntraClusterDeviation() = 0; 30 | 31 | const VectorXu& z() const {return z_;}; 32 | const Matrix& centroids() const {return ps_;}; 33 | 34 | uint32_t getK(){return K_;}; 35 | uint32_t K(){return K_;}; 36 | 37 | protected: 38 | uint32_t K_; 39 | const uint32_t D_; 40 | uint32_t N_; 41 | boost::shared_ptr > spx_; // pointer to data 42 | Matrix ps_; // centroids on the sphere 43 | Matrix Ns_; // counts for each cluster 44 | VectorXu z_; // labels 45 | boost::mt19937* pRndGen_; 46 | }; 47 | 48 | // ----------------------------- impl ----------------------------------------- 49 | 50 | template 51 | Clusterer::Clusterer( 52 | const boost::shared_ptr >& spx, uint32_t K, 53 | boost::mt19937* pRndGen) 54 | : K_(K), D_(spx->rows()), N_(spx->cols()), spx_(spx), ps_(D_,K_), Ns_(K_), 55 | z_(N_), pRndGen_(pRndGen) 56 | {}; 57 | 58 | template 59 | Clusterer::~Clusterer() 60 | {}; 61 | -------------------------------------------------------------------------------- /include/dpMM/dir.hpp: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2015, Julian Straub 2 | * Licensed under the MIT license. See the license file LICENSE. 3 | */ 4 | 5 | #pragma once 6 | 7 | #include 8 | #include 9 | #include 10 | 11 | #include // for gamma_distribution. 12 | #include 13 | 14 | #include 15 | #include 16 | #include 17 | 18 | using namespace Eigen; 19 | using std::cout; 20 | using std::endl; 21 | using std::vector; 22 | 23 | #ifdef BOOST_OLD 24 | using boost::gamma_distribution; 25 | #else 26 | using boost::random::gamma_distribution; 27 | #endif 28 | 29 | #ifdef WIN32 30 | using boost::math::lgamma; 31 | #endif 32 | 33 | template 34 | class Dir : public Distribution 35 | { 36 | public: 37 | uint32_t K_; 38 | Matrix alpha_; 39 | 40 | Dir(const Matrix& alpha, boost::mt19937 *pRndGen); 41 | Dir(const Matrix& alpha, const Matrix& counts, boost::mt19937 *pRndGen); 42 | Dir(const Dir& other); 43 | ~Dir(); 44 | 45 | Dir* copy(); 46 | 47 | Disc sample(); 48 | Dir posterior() const; 49 | Dir posterior(const VectorXu& z); 50 | Dir posterior(const Matrix& x, 51 | const VectorXu& z, uint32_t k); 52 | Dir posteriorFromCounts(const Matrix& counts); 53 | Dir posteriorFromCounts(const VectorXu& counts); 54 | Dir posteriorFromCounts(const vector > & 55 | counts, const VectorXu& z, uint32_t k); 56 | 57 | T logPdf(const Disc& cat); 58 | 59 | uint32_t K(){return K_;} 60 | 61 | T logPdf(const Disc& cat) const; 62 | T logPdfMarginalized() const; // log pdf of SS under NIW prior 63 | T logPdfUnderPriorMarginalizedMerged(const Dir& other) const; 64 | 65 | T logLikelihoodMarginalized(const Matrix& counts) const; 66 | void print() const; 67 | 68 | virtual Dir* merge(const Dir& other); 69 | void fromMerge(const Dir& niwA, const Dir& niwB); 70 | 71 | // const Matrix& scatter() const {return scatter_;}; 72 | // Matrix& scatter() {return scatter_;}; 73 | // const Matrix& mean() const {return mean_;}; 74 | // Matrix& mean() {return mean_;}; 75 | // T count() const {return count_;}; 76 | // T& count() {return count_;}; 77 | // 78 | const Matrix& counts() const {return counts_;}; 79 | Matrix& counts() {return counts_;}; 80 | void setCounts(const Matrix& counts) {counts_ = counts;}; 81 | T count() const {return counts_.sum();}; 82 | 83 | void computeMergedSS( const Dir& dirA, 84 | const Dir& dirB, Matrix& NsM) const; 85 | 86 | private: 87 | 88 | Matrix counts_; // counts for the different classes -> SS 89 | vector > gammas_; 90 | 91 | Matrix samplePdf(); 92 | }; 93 | 94 | typedef Dir, double> DirCatd; 95 | typedef Dir, float> DirCatf; 96 | typedef Dir, double> DirMultd; 97 | typedef Dir, float> DirMultf; 98 | -------------------------------------------------------------------------------- /include/dpMM/dirMMsplitMerge.hpp: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2015, Julian Straub 2 | * Licensed under the MIT license. See the license file LICENSE. 3 | */ 4 | #pragma once 5 | #include 6 | #include 7 | #include 8 | #include 9 | 10 | #include 11 | 12 | #include 13 | 14 | 15 | using namespace Eigen; 16 | using std::endl, std::cout, std::vector; 17 | using boost::shared_ptr; 18 | 19 | template 20 | class DirMMsplitMerge : public DirMM 21 | { 22 | public: 23 | DirMMsplitMerge(const Dir& alpha, const shared_ptr >& theta); 24 | virtual ~DirMMsplitMerge(); 25 | 26 | virtual void sampleParameters(); 27 | 28 | protected: 29 | proposeSplit(); 30 | BaseMeasure* proposeMerge(); 31 | merge(); 32 | split(); 33 | 34 | mhRatioMerge(); 35 | mhRatioSplit(); 36 | 37 | }; 38 | 39 | // -------------------------------------- impl -------------------------------- 40 | template 41 | DirMMsplitMerge::DirMMsplitMerge() 42 | {}; 43 | 44 | template 45 | DirMMsplitMerge::~DirMMsplitMerge() 46 | {}; 47 | 48 | 49 | template 50 | DirMMsplitMerge::sampleParameters() 51 | { 52 | DirMM::sampleParameters(); 53 | queue emptyClusters; 54 | for(uint32_t k=0; kK_; ++k) 55 | if(this->thetas_[k]->count() == 0) 56 | { 57 | emptyClusters.push(k); 58 | } 59 | for(uint32_t k=0; kK_; ++k) 60 | if(!emptyClusters.empty()) 61 | { 62 | std::pair< BaseMeasure*, BaseMeasure* > split = proposeSplit(k); 63 | if(split.first && split.second) 64 | { 65 | this->thetas_[k].reset(split.first); 66 | this->thetas_[emptyClusters.front()].reset(split.second); 67 | emptyClusters.pop(); 68 | } 69 | } 70 | for(uint32_t k=0; kK_; ++k) 71 | for(uint32_t j=0; jK_; ++j) 72 | { 73 | BaseMeasure* merged = proposeMerge(k,j); 74 | if(merged) 75 | { 76 | this->thetas_[k].reset(merged); 77 | this->thetas_[j].reset(new theta0_->copy()); 78 | } 79 | } 80 | }; 81 | 82 | 83 | template 84 | std::pair< BaseMeasure*, BaseMeasure* > DirMMsplitMerge::proposeSplit( 85 | uint32_t k) 86 | { 87 | 88 | return std::pair< BaseMeasure*, BaseMeasure* > (NULL,NULL); 89 | }; 90 | 91 | template 92 | BaseMeasure* DirMMsplitMerge::proposeMerge(uint32_t k, uint32_t j) 93 | { 94 | BaseMeasure* merged(this->thetas_[k]->merge(*this->thetas_[j])); 95 | 96 | 97 | return NULL; 98 | }; 99 | 100 | 101 | -------------------------------------------------------------------------------- /include/dpMM/distribution.hpp: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2015, Julian Straub 2 | * Licensed under the MIT license. See the license file LICENSE. 3 | */ 4 | 5 | #pragma once 6 | 7 | #include 8 | #include 9 | 10 | #include 11 | #include 12 | 13 | #include 14 | 15 | #ifndef PI 16 | # define PI 3.141592653589793 17 | #endif 18 | #define LOG_PI 1.1447298858494002 19 | #define LOG_2 0.69314718055994529 20 | #define LOG_2PI 1.8378770664093453 21 | 22 | using namespace Eigen; 23 | 24 | template 25 | class Distribution 26 | { 27 | public: 28 | Distribution(boost::mt19937* pRndGen) : pRndGen_(pRndGen) 29 | {}; 30 | virtual ~Distribution() 31 | {}; 32 | 33 | // virtual logProb() 34 | boost::mt19937* pRndGen_; 35 | private: 36 | }; 37 | 38 | 39 | template 40 | inline Matrix counts(const Matrix & z, T2 K) 41 | { 42 | Matrix N(K); 43 | N.setZero(K); 44 | for (T2 i=0; i 0.); 62 | double lgam_p = p*(p-1.)*0.25*LOG_PI; 63 | for (uint32_t i=1; i models_; 49 | 50 | MatrixXd x_; 51 | VectorXu z_; // indicators 52 | Dist H_; // 53 | }; 54 | 55 | // ---------------- impl ----------------------------------------------------- 56 | template 57 | void DpStickMM::initialize(const MatrixXd& x) 58 | { 59 | uint32_t K0=1; 60 | x_ = x; 61 | z_.setZero(x.cols(),1); 62 | for (uint32_t k=0; k1) 68 | { 69 | VectorXd pi(K0); 70 | pi.setOnes(); 71 | pi /= static_cast(K0); 72 | Catd cat(pi,H_.pRndGen_); 73 | for (uint32_t i=0; i 79 | VectorXd DpStickMM::getCounts() 80 | { 81 | VectorXd counts(getK()); 82 | counts.setZero(); 83 | //TODO 84 | // for(uint32_t k=0; kcount(); 86 | return counts; 87 | }; 88 | 89 | template 90 | void DpStickMM::sampleLabels() 91 | { 92 | double N = z_.size(); 93 | for(uint32_t i=0; i, Randi Cabezas 2 | * Licensed under the MIT license. See the license file LICENSE. 3 | */ 4 | 5 | #pragma once 6 | 7 | #include 8 | 9 | #include 10 | #include 11 | 12 | #include 13 | #include 14 | 15 | #include 16 | #include 17 | 18 | using namespace Eigen; 19 | using std::endl; 20 | using std::cout; 21 | 22 | template 23 | class IW : public Distribution 24 | { 25 | public: 26 | Matrix Delta_; 27 | T nu_; 28 | uint32_t D_; 29 | 30 | IW(const Matrix& Delta, T nu, boost::mt19937 *pRndGen); 31 | IW(const Matrix& Delta, T nu, const Matrix& scatter, 32 | const Matrix& mean, T counts, boost::mt19937 *pRndGen); 33 | IW(const IW& iw); 34 | ~IW(); 35 | 36 | IW* copy(); 37 | 38 | IW posterior(const Matrix& x, const VectorXu& z, 39 | uint32_t k, uint32_t zDivider=1); 40 | IW posterior(const Matrix& outer, T count) const; 41 | IW posterior() const ; 42 | void resetSufficientStatistics(); 43 | 44 | Matrix sample(); 45 | // Normal sample(); 46 | T logPdf(const Matrix& Sigma) const; 47 | T logPdf(const Normal& normal) const; 48 | T logLikelihoodMarginalized() const; // log pdf of SS under NIW prior 49 | T logLikelihoodMarginalized(const Matrix& Scatter, 50 | T count) const; 51 | 52 | Matrix mode() const; 53 | 54 | const Matrix& scatter() const {return scatter_;}; 55 | Matrix& scatter() {return scatter_;}; 56 | const Matrix& mean() const {return mean_;}; 57 | Matrix& mean() {return mean_;}; 58 | T count() const {return count_;}; 59 | T& count() {return count_;}; 60 | 61 | private: 62 | boost::random::normal_distribution<> gauss_; 63 | 64 | // sufficient statistics 65 | Matrix scatter_; 66 | Matrix mean_; 67 | T count_; 68 | }; 69 | 70 | typedef IW IWd; 71 | typedef IW IWf; 72 | 73 | /* prior for spherical covariances (i.e. \Sigma = \sigma^2 I) */ 74 | template 75 | class IW_spherical : public Distribution 76 | { 77 | public: 78 | T delta_; 79 | T nu_; 80 | uint32_t D_; 81 | 82 | IW_spherical(T delta, T nu, uint32_t D, boost::mt19937 *pRndGen); 83 | IW_spherical(const IW_spherical& iw); 84 | ~IW_spherical(); 85 | 86 | IW_spherical* copy(); 87 | 88 | IW_spherical posterior(const Matrix& x, 89 | const VectorXu& z, uint32_t k, uint32_t zDivider=1); 90 | // T sample(); 91 | // T logPdf(T sigma); 92 | //// T logPdf(const Normal& normal); 93 | 94 | private: 95 | boost::random::normal_distribution<> gauss_; 96 | }; 97 | 98 | // ---------------------------------------------------------------------------- 99 | -------------------------------------------------------------------------------- /include/dpMM/iwTangent.hpp: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2015, Julian Straub 2 | * Licensed under the MIT license. See the license file LICENSE. 3 | */ 4 | #pragma once 5 | 6 | #include 7 | 8 | #include 9 | #include 10 | 11 | #include 12 | #include 13 | 14 | #include 15 | #include 16 | #include 17 | #include 18 | #include 19 | #include 20 | 21 | using namespace Eigen; 22 | using std::endl; 23 | using std::cout; 24 | 25 | /* Actually just places an IW prior on covariances in the tangent 26 | * plane. 27 | * 28 | * The point of tangentcy has to be set "manually". This makes the 29 | * clase usefull for models that externaly update the point of tangency 30 | * such as the Manhattan Frame 31 | */ 32 | template 33 | class IwTangent : public BaseMeasure 34 | { 35 | public: 36 | 37 | IW iw0_; // IW prior on the covariance of the normal in T_\muS^D 38 | Sphere S_; 39 | NormalSphere normalS_; // normal on sphere 40 | 41 | IwTangent(const IW& iw, boost::mt19937* pRndGen); 42 | ~IwTangent(); 43 | 44 | virtual BaseMeasure* copy(); 45 | virtual IwTangent* copyNative(); 46 | 47 | virtual baseMeasureType getBaseMeasureType() const {return(NIW_TANGENT); } 48 | 49 | /* for any point on the sphere; maps into T_muS and rotates north first */ 50 | virtual T logLikelihood(const Matrix& x) const ; 51 | virtual T logLikelihood(const Matrix& x, uint32_t i) const 52 | {return logLikelihood(x.col(i));}; 53 | // right now this does not support actual scatter! it supports 54 | // weighted directional data though. count is the weight 55 | // [counts,karcherMean,scatter around KarcherMean] 56 | virtual T logLikelihoodFromSS(const Matrix& x) const; 57 | /* assumes x is already in T_northS */ 58 | virtual T logLikelihoodNorth(const Matrix& x) const ; 59 | 60 | void posterior(const Matrix& x, const VectorXu& z, 61 | uint32_t k); 62 | void posterior(const shared_ptr >& cldp, uint32_t k); 63 | /* assumes the x are already in T_northS correctly */ 64 | void posteriorFromPtsInTpS(const Matrix& x, 65 | const VectorXu& z, uint32_t k); 66 | // right now this does not support actual scatter! it supports 67 | // weighted directional data though. count is the weight 68 | // [counts,karcherMean,scatter around KarcherMean] 69 | void posteriorFromSS(const vector >&x, const 70 | VectorXu& z, uint32_t k); 71 | void posteriorFromSS(const Matrix &x); 72 | 73 | void sample(); 74 | 75 | T logPdfUnderPrior() const; 76 | T logPdfUnderPriorMarginalized() const; 77 | // T logPdfUnderPriorMarginalizedMerged(const shared_ptr >& other) const; 78 | 79 | void print() const; 80 | virtual uint32_t getDim() const {return(uint32_t(normalS_.D_));}; 81 | 82 | // virtual IwTangent* merge(const IwTangent& other); 83 | // void fromMerge(const IwTangent& niwA, const IwTangent& niwB); 84 | 85 | const Matrix& scatter() const {return iw0_.scatter();}; 86 | Matrix& scatter() {return iw0_.scatter();}; 87 | T count() const {return iw0_.count();}; 88 | T& count() {return iw0_.count();}; 89 | 90 | const Matrix& Sigma() const {return normalS_.Sigma();}; 91 | 92 | const Matrix& getMean() const {return normalS_.getMean();}; 93 | void setMean(const Matrix& mean) {return normalS_.setMean(mean);}; 94 | 95 | private: 96 | 97 | // void computeMergedSS( const IwTangent& niwA, 98 | // const IwTangent& niwB, Matrix& scatterM, 99 | // Matrix& muM, T& countM) const; 100 | 101 | 102 | }; 103 | 104 | typedef IwTangent IwTangentd; 105 | typedef IwTangent IwTangentf; 106 | 107 | -------------------------------------------------------------------------------- /include/dpMM/mult.hpp: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2015, Julian Straub 2 | * Licensed under the MIT license. See the license file LICENSE. 3 | */ 4 | #pragma once 5 | 6 | #include 7 | 8 | //#include 9 | //#include 10 | #include 11 | 12 | #include 13 | #include 14 | 15 | using namespace Eigen; 16 | using std::cout; 17 | using std::endl; 18 | 19 | #ifdef WIN32 20 | using boost::math::lgamma; 21 | #endif 22 | 23 | template 24 | class Mult : public Distribution 25 | { 26 | public: 27 | uint32_t K_; 28 | Matrix pdf_; 29 | 30 | /* constructor from pdf */ 31 | Mult(const Matrix& pdf, boost::mt19937 *pRndGen); 32 | /* constructor from indicators - estimates from counts */ 33 | Mult(const VectorXu& z, boost::mt19937 *pRndGen); 34 | /* copy constructor */ 35 | Mult(const Mult& other); 36 | virtual ~Mult(); 37 | 38 | uint32_t sample(); 39 | void sample(VectorXu& z); 40 | 41 | T logPdf(const Matrix& x) const; 42 | T logPdfOfSS(const Matrix& x) const {return logPdf(x);}; 43 | 44 | const Matrix& pdf() const {return pdf_;}; 45 | void pdf(const Matrix& pdf){ 46 | pdf_ = pdf; 47 | }; 48 | 49 | void print() const; 50 | 51 | private: 52 | boost::uniform_01 unif_; 53 | }; 54 | 55 | typedef Mult Multf; 56 | typedef Mult Multd; 57 | 58 | -------------------------------------------------------------------------------- /include/dpMM/niw.hpp: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2015, Julian Straub , Randi Cabezas 2 | * Licensed under the MIT license. See the license file LICENSE. 3 | */ 4 | 5 | #pragma once 6 | 7 | #include 8 | 9 | #include 10 | #include 11 | 12 | #include 13 | #include 14 | 15 | #include 16 | #include 17 | 18 | using namespace Eigen; 19 | using std::endl; 20 | using std::cout; 21 | using std::vector; 22 | 23 | template 24 | class NIW : public Distribution 25 | { 26 | public: 27 | Matrix Delta_; 28 | Matrix theta_; 29 | T nu_,kappa_; 30 | uint32_t D_; 31 | 32 | NIW(const Matrix& Delta, 33 | const Matrix& theta, T nu, T kappa, 34 | boost::mt19937 *pRndGen); 35 | NIW(const NIW& niw); 36 | ~NIW(); 37 | 38 | NIW* copy(); 39 | 40 | NIW posterior(const Matrix& x, const VectorXu& z, 41 | uint32_t k); 42 | NIW posterior(const vector >&x, const 43 | VectorXu& z, uint32_t k); 44 | // assumes vector [N, sum(x), flatten(sum(outer(x,x)))] 45 | NIW posteriorFromSS(const Matrix& x); 46 | NIW posteriorFromSS(const vector >&x, const 47 | VectorXu& z, uint32_t k); 48 | 49 | NIW posterior() const; 50 | void resetSufficientStatistics(); 51 | void getSufficientStatistics(const Matrix &x, 52 | const VectorXu& z, uint32_t k); 53 | void getSufficientStatistics(const vector > &x, 54 | const VectorXu& z, uint32_t k); 55 | T logProb(const Matrix& x_i) const; 56 | T logPosteriorProb(const Matrix& x, VectorXu& z, uint32_t k, 57 | uint32_t i); 58 | 59 | Normal sample(); 60 | Normal sampleFromPosterior(); 61 | 62 | T logPdf(const Normal& normal) const; 63 | T logPdfMarginalized() const; // log pdf of SS under NIW prior 64 | T logPdfUnderPriorMarginalizedMerged(const NIW& other) const; 65 | 66 | T logLikelihoodMarginalized(const Matrix& Scatter, 67 | const Matrix& mean, T count) const; 68 | void print() const; 69 | 70 | virtual NIW* merge(const NIW& other); 71 | void fromMerge(const NIW& niwA, const NIW& niwB); 72 | 73 | const Matrix& scatter() const {return scatter_;}; 74 | Matrix& scatter() {return scatter_;}; 75 | const Matrix& mean() const {return mean_;}; 76 | Matrix& mean() {return mean_;}; 77 | T count() const {return count_;}; 78 | T& count() {return count_;}; 79 | 80 | void computeMergedSS( const NIW& niwA, 81 | const NIW& niwB, Matrix& scatterM, 82 | Matrix& muM, T& countM) const; 83 | 84 | private: 85 | boost::random::normal_distribution<> gauss_; 86 | 87 | // sufficient statistics 88 | Matrix scatter_; 89 | Matrix mean_; 90 | T count_; 91 | 92 | }; 93 | 94 | typedef NIW NIWd; 95 | typedef NIW NIWf; 96 | 97 | -------------------------------------------------------------------------------- /include/dpMM/niwSphere.hpp: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2015, Julian Straub 2 | * Licensed under the MIT license. See the license file LICENSE. 3 | */ 4 | #pragma once 5 | 6 | #include 7 | 8 | #include 9 | #include 10 | 11 | #include 12 | #include 13 | 14 | #include 15 | #include 16 | #include 17 | #include 18 | #include 19 | #include 20 | #include 21 | 22 | using namespace Eigen; 23 | using std::endl; 24 | using std::cout; 25 | 26 | /* Actually just places an IW prior on covariances in the tangent plane */ 27 | template 28 | class NiwSphere : public BaseMeasure 29 | { 30 | public: 31 | 32 | IW iw0_; // IW prior on the covariance of the normal in T_\muS^D 33 | Sphere S_; 34 | NormalSphere normalS_; // normal on sphere 35 | 36 | NiwSphere(const IW& iw, boost::mt19937* pRndGen); 37 | ~NiwSphere(); 38 | 39 | virtual BaseMeasure* copy(); 40 | virtual NiwSphere* copyNative(); 41 | 42 | virtual baseMeasureType getBaseMeasureType() const {return(NIW_SPHERE); } 43 | 44 | /* for any point on the sphere; maps into T_muS and rotates north first */ 45 | virtual T logLikelihood(const Matrix& x) const ; 46 | virtual T logLikelihood(const Matrix& x, uint32_t i) const 47 | {return logLikelihood(x.col(i));}; 48 | // right now this does not support actual scatter! it supports 49 | // weighted directional data though. count is the weight 50 | // [counts,karcherMean,scatter around KarcherMean] 51 | virtual T logLikelihoodFromSS(const Matrix& x) const; 52 | /* assumes x is already in T_northS */ 53 | virtual T logLikelihoodNorth(const Matrix& x) const ; 54 | 55 | void posterior(const Matrix& x, const VectorXu& z, 56 | uint32_t k); 57 | void posterior(const shared_ptr >& cldp, uint32_t k); 58 | /* assumes the x are already in T_northS correctly */ 59 | void posteriorFromPtsInTpS(const Matrix& x, 60 | const VectorXu& z, uint32_t k); 61 | // right now this does not support actual scatter! it supports 62 | // weighted directional data though. count is the weight 63 | // [counts,karcherMean,scatter around KarcherMean] 64 | void posteriorFromSS(const vector >&x, const 65 | VectorXu& z, uint32_t k); 66 | void posteriorFromSS(const Matrix &x); 67 | 68 | void sample(); 69 | 70 | T logPdfUnderPrior() const; 71 | T logPdfUnderPriorMarginalized() const; 72 | T logPdfUnderPriorMarginalizedMerged(const shared_ptr >& other) const; 73 | 74 | void print() const; 75 | virtual uint32_t getDim() const {return(uint32_t(normalS_.D_));}; 76 | 77 | virtual NiwSphere* merge(const NiwSphere& other); 78 | void fromMerge(const NiwSphere& niwA, const NiwSphere& niwB); 79 | 80 | const Matrix& scatter() const {return iw0_.scatter();}; 81 | Matrix& scatter() {return iw0_.scatter();}; 82 | T count() const {return iw0_.count();}; 83 | T& count() {return iw0_.count();}; 84 | 85 | const Matrix& Sigma() const {return normalS_.Sigma();}; 86 | 87 | const Matrix& getMean() const {return normalS_.getMean();}; 88 | void setMean(const Matrix& mean) {return normalS_.setMean(mean);}; 89 | 90 | private: 91 | 92 | void computeMergedSS( const NiwSphere& niwA, 93 | const NiwSphere& niwB, Matrix& scatterM, 94 | Matrix& muM, T& countM) const; 95 | 96 | 97 | }; 98 | 99 | typedef NiwSphere NiwSphered; 100 | typedef NiwSphere NiwSpheref; 101 | 102 | -------------------------------------------------------------------------------- /include/dpMM/niwSphereFull.hpp: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2015, Julian Straub 2 | * Licensed under the MIT license. See the license file LICENSE. 3 | */ 4 | #pragma once 5 | 6 | #include 7 | 8 | #include 9 | #include 10 | 11 | #include 12 | #include 13 | 14 | #include 15 | #include 16 | #include 17 | #include 18 | #include 19 | #include 20 | #include 21 | 22 | using namespace Eigen; 23 | using std::endl; 24 | using std::cout; 25 | 26 | 27 | template 28 | class NiwSphereFull : public BaseMeasure 29 | { 30 | public: 31 | 32 | uint32_t D_; 33 | IW iw0_; // IW prior on the covariance of the normal in T_\muS^D 34 | Sphere S_; 35 | NormalSphere normalS_; // sampled normal on sphere - distribution of data 36 | 37 | NiwSphereFull(const IW& iw, boost::mt19937* pRndGen); 38 | ~NiwSphereFull(); 39 | 40 | virtual baseMeasureType getBaseMeasureType() const {return(NIW_SPHERE_FULL); } 41 | 42 | virtual BaseMeasure* copy(); 43 | virtual NiwSphereFull* copyNative(); 44 | 45 | /* for any point on the sphere; maps into T_muS and rotates north first */ 46 | virtual T logLikelihood(const Matrix& x) const ; 47 | virtual T logLikelihood(const Matrix& x, uint32_t i) const 48 | {return logLikelihood(x.col(i));}; 49 | /* assumes x is already in T_northS */ 50 | virtual T logLikelihoodNorth(const Matrix& x) const ; 51 | 52 | void posterior(const Matrix& x, const VectorXu& z, 53 | uint32_t k); 54 | void posterior(const shared_ptr >& cldp, uint32_t k); 55 | /* assumes the x are already in T_northS correctly */ 56 | void posteriorFromPtsInTpS(const Matrix& x, 57 | const VectorXu& z, uint32_t k, uint32_t zDivider=1); 58 | 59 | void sampleMergedParams(); 60 | /* samples Cov and then proposes means (covs are always accepted!) */ 61 | void sample(); 62 | /* proposes means and covariances jointly (and rejects them jointly as well)*/ 63 | void sample_2(); 64 | 65 | T logPdfUnderPrior() const; 66 | T logPdfUnderPriorMarginalized() const; 67 | T logPdfUnderPriorMarginalizedMerged(const shared_ptr >& other) const; 68 | T qRandomMuProposal() const; 69 | 70 | void print() const; 71 | 72 | virtual NiwSphereFull* merge(const NiwSphereFull& other); 73 | void fromMerge(const NiwSphereFull& niwA, const NiwSphereFull& niwB); 74 | 75 | const Matrix& scatter() const {return iw0_.scatter();}; 76 | Matrix& scatter() {return iw0_.scatter();}; 77 | const Matrix& mean() const {return iw0_.mean();}; 78 | Matrix& mean() {return iw0_.mean();}; 79 | T count() const {return iw0_.count();}; 80 | T& count() {return iw0_.count();}; 81 | 82 | const Matrix& Sigma() const {return normalS_.Sigma();}; 83 | 84 | const Matrix& getMean() const {return normalS_.getMean();}; 85 | const Matrix& getMeanKarch() const {return meanKarch_;}; 86 | // this is the sample mean 87 | void setMeanKarch(const Matrix& mean) { 88 | meanKarch_ = mean; 89 | }; 90 | void setMean(const Matrix& mean) {normalS_.setMean(mean);}; 91 | virtual uint32_t getDim() const {return(D_);}; 92 | private: 93 | 94 | void computeMergedSS( const NiwSphereFull& niwA, 95 | const NiwSphereFull& niwB, Matrix& scatterM, 96 | Matrix& meanM, 97 | Matrix& muM, T& countM) const; 98 | 99 | Matrix meanKarch_; 100 | 101 | }; 102 | 103 | typedef NiwSphereFull NiwSphereFulld; 104 | typedef NiwSphereFull NiwSphereFullf; 105 | 106 | -------------------------------------------------------------------------------- /include/dpMM/normal.hpp: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2015, Julian Straub 2 | * Licensed under the MIT license. See the license file LICENSE. 3 | */ 4 | 5 | #pragma once 6 | 7 | #include 8 | #include 9 | #include 10 | 11 | #include 12 | 13 | #include 14 | 15 | #include 16 | 17 | using namespace Eigen; 18 | using std::cout; 19 | using std::endl; 20 | using std::min; 21 | 22 | #ifdef BOOST_OLD 23 | using boost::normal_distribution; 24 | #else 25 | using boost::random::normal_distribution; 26 | #endif 27 | 28 | template 29 | class Normal : public Distribution 30 | { 31 | public: 32 | uint32_t D_; 33 | Matrix mu_; 34 | 35 | Normal(const Matrix& mu, const Matrix& Sigma, 36 | boost::mt19937 *pRndGen); 37 | Normal(const Matrix& Sigma, boost::mt19937 *pRndGen); 38 | Normal(uint32_t D, boost::mt19937 *pRndGen); 39 | Normal(const Normal& other); 40 | ~Normal(); 41 | 42 | T logPdf(const Matrix& x) const; 43 | T logPdfSlower(const Matrix& x) const; 44 | T logPdf(const Matrix& scatter, 45 | const Matrix& mean, T count) const; 46 | T logPdfSlower(const Matrix& scatter, 47 | const Matrix& mean, T count) const; 48 | T logPdf(const Matrix& scatter, T count) const; 49 | 50 | Matrix sample(); 51 | 52 | void print() const; 53 | 54 | const Matrix& Sigma() const {return Sigma_;}; 55 | void setSigma(const Matrix& Sigma) 56 | { Sigma_ = Sigma; SigmaLDLT_.compute(Sigma_); 57 | logDetSigma_ = ((Sigma_.eigenvalues()).array().log().sum()).real();}; 58 | T logDetSigma() const {return logDetSigma_;}; 59 | const LDLT >& SigmaLDLT() const {return SigmaLDLT_;}; 60 | 61 | private: 62 | 63 | Matrix Sigma_; 64 | // helpers for fast computation 65 | T logDetSigma_; 66 | LDLT > SigmaLDLT_; 67 | 68 | normal_distribution<> gauss_; 69 | }; 70 | 71 | typedef Normal Normald; 72 | typedef Normal Normalf; 73 | 74 | template 75 | inline Matrix sampleClusters( 76 | Matrix& x, VectorXu& z, uint32_t K); 77 | 78 | template 79 | inline Matrix sampleClusters( 80 | Matrix& x, VectorXu& z, uint32_t K) 81 | { 82 | uint32_t N = x.cols(); 83 | uint32_t D = x.rows(); 84 | boost::mt19937 rndGen(9119); 85 | 86 | Matrix Sigma = Matrix::Identity(D,D); 87 | Sigma *= 5.0; 88 | Normal meanPrior(Sigma,&rndGen); 89 | 90 | Sigma *= 1.0/20.; 91 | Matrix mus(D,K); 92 | for(uint32_t k=0; k gauss_k(mus.col(k),Sigma,&rndGen); 96 | for (uint32_t i=k*(N/K); i 2 | * Licensed under the MIT license. See the license file LICENSE. 3 | */ 4 | 5 | 6 | #pragma once 7 | 8 | #include 9 | 10 | template 11 | class SufficientStatistics 12 | { 13 | 14 | }; 15 | 16 | /* sufficient statistics for gaussian distribution 17 | * has outer product, sum over data and count 18 | */ 19 | template 20 | class ssGauss : public SufficientStatistics 21 | { 22 | 23 | }; 24 | 25 | /* sufficient statistics for categorical distribution 26 | * mainly just counts 27 | */ 28 | template 29 | class ssCat : public SufficientStatistics 30 | { 31 | 32 | }; 33 | -------------------------------------------------------------------------------- /include/dpMM/timerLog.hpp: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2015, Julian Straub 2 | * Licensed under the MIT license. See the license file LICENSE. 3 | */ 4 | #pragma once 5 | 6 | #include 7 | #include 8 | #include 9 | #include 10 | 11 | #include 12 | 13 | using std::string; 14 | using std::ofstream; 15 | using std::vector; 16 | 17 | class TimerLog : public Timer 18 | { 19 | public: 20 | TimerLog(string path, uint32_t N, string name="Timer0") 21 | : Timer(), path_(path), name_(name), fout_(path_.data(),ofstream::out), 22 | t0s_(N), dts_(N,0),tSums_(N,0), tSquareSums_(N,0), Ns_(N,0) 23 | { 24 | tic(); 25 | }; 26 | virtual ~TimerLog() {fout_.close();}; 27 | 28 | virtual void tic(int32_t id=-1) 29 | { 30 | timeval t0 = this->getTimeOfDay(); 31 | if(id < 0){ 32 | for(int32_t i=0; i(t0s_.size()); ++i) t0s_[i] = t0; 33 | } else if( 0<= id && id < static_cast(t0s_.size())) 34 | t0s_[id] = t0; 35 | else{ // add a new timer 36 | t0s_.push_back(t0); 37 | dts_.push_back(0.); 38 | tSums_.push_back(0.); 39 | tSquareSums_.push_back(0.); 40 | Ns_.push_back(0.); 41 | } 42 | }; 43 | 44 | virtual void toc(int32_t id=-1) 45 | { 46 | timeval tE = this->getTimeOfDay(); 47 | if(id < 0) 48 | { 49 | for(int32_t i=0; i(dts_.size()); ++i) 50 | { 51 | dts_[i] = this->getDtMs(t0s_[i],tE); 52 | tSums_[i] += dts_[i]; 53 | tSquareSums_[i] += dts_[i]*dts_[i]; 54 | Ns_[i] ++; 55 | } 56 | } else if( 0<= id && id < static_cast(t0s_.size())) 57 | { 58 | dts_[id] = this->getDtMs(t0s_[id],tE); 59 | tSums_[id] += dts_[id]; 60 | tSquareSums_[id] += dts_[id]*dts_[id]; 61 | Ns_[id] ++; 62 | } 63 | }; 64 | 65 | virtual void toctic(int32_t id0, int32_t id1) 66 | { 67 | toc(id0);tic(id1); 68 | }; 69 | 70 | virtual void logCycle() 71 | { 72 | for(uint32_t i=0; i(dts_.size()); ++i) 87 | { 88 | double mean = tSums_[i]/Ns_[i]; 89 | double var = tSquareSums_[i]/Ns_[i] - mean*mean; 90 | meanTotal += mean; 91 | varTotal += var; 92 | cout< total/cycle: "< t0s_; // starts for all timings 102 | vector dts_; // dts 103 | vector tSums_; // sum over the time 104 | vector tSquareSums_; // sum over squares over the time 105 | vector Ns_; // counts of observations for each dt 106 | }; 107 | 108 | -------------------------------------------------------------------------------- /include/dpMM/typedef.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2015, Julian Straub , Randi Cabezas 2 | * Licensed under the MIT license. See the license file LICENSE. 3 | */ 4 | 5 | //#ifdef __APPLE__ || WIN32 6 | #ifndef __linux__ 7 | typedef unsigned int uint; 8 | #endif 9 | -------------------------------------------------------------------------------- /include/dpMM/unifSphere.hpp: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2015, Julian Straub 2 | * Licensed under the MIT license. See the license file LICENSE. 3 | */ 4 | #pragma once 5 | 6 | #include 7 | #include 8 | #include 9 | 10 | using namespace Eigen; 11 | 12 | template 13 | class UnifSphere : public BaseMeasure 14 | { 15 | public: 16 | 17 | uint32_t D_; // dimensionality of the space in which the sphere lies 18 | Sphere S_; 19 | 20 | UnifSphere(uint32_t D); 21 | ~UnifSphere(); 22 | 23 | virtual baseMeasureType getBaseMeasureType() const {return(UNIF_SPHERE); } 24 | 25 | virtual BaseMeasure* copy(); 26 | 27 | virtual T logLikelihood(const Matrix& x) const; 28 | virtual T logLikelihood(const Matrix& x, uint32_t i) const 29 | {return logLikelihood(x.col(i));}; 30 | virtual void posterior(const Matrix& x, 31 | const VectorXu& z, uint32_t k); 32 | virtual T logPdfUnderPrior() const; 33 | void print() const {cout<<"Unif Sphere in D="< UnifSphered; 40 | typedef UnifSphere UnifSpheref; 41 | 42 | // --------------------------------------------------------------------------- 43 | template 44 | UnifSphere::UnifSphere(uint32_t D) 45 | : D_(D), S_(D) 46 | {}; 47 | template 48 | UnifSphere::~UnifSphere() 49 | {}; 50 | 51 | template 52 | BaseMeasure* UnifSphere::copy() 53 | { 54 | return new UnifSphere(D_); 55 | }; 56 | 57 | template 58 | T UnifSphere::logLikelihood(const Matrix& x) const 59 | { 60 | return - S_.logSurfaceArea(); 61 | }; 62 | 63 | template 64 | void UnifSphere::posterior(const Matrix& x, 65 | const VectorXu& z, uint32_t k) 66 | { 67 | // nothing seince we have no priors 68 | }; 69 | 70 | template 71 | T UnifSphere::logPdfUnderPrior() const 72 | { 73 | return 0.0; 74 | }; 75 | 76 | -------------------------------------------------------------------------------- /include/dpMM/vmfBaseMeasure.hpp: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2015, Julian Straub , Randi Cabezas 2 | * Licensed under the MIT license. See the license file LICENSE. 3 | */ 4 | 5 | 6 | #pragma once 7 | 8 | #include 9 | 10 | #include 11 | #include 12 | 13 | /* 14 | * vmf base measure; uses monte carlo integration for p(x|hyperparams) 15 | * http://eprints.pascal-network.org/archive/00007206/01/iMMM.pdf 16 | */ 17 | template 18 | class vMFbase : public BaseMeasure 19 | { 20 | public: 21 | vMFbase(const vMFpriorFull& vmfPrior); 22 | vMFbase(const vMFbase& vmf); 23 | ~vMFbase(); 24 | 25 | virtual BaseMeasure* copy(); 26 | virtual vMFbase* copyNative(); 27 | 28 | T logLikelihood(const Matrix& x) const; 29 | T logLikelihood(const Matrix& x, uint32_t i) const 30 | {return logLikelihood(x.col(i));}; 31 | void posterior(const Matrix& x, const VectorXu& z, 32 | uint32_t k); 33 | void posterior(const vector >&x, const VectorXu& z, 34 | uint32_t k); 35 | void sample(); 36 | 37 | T logPdfUnderPrior() const; 38 | virtual T logPdfUnderPriorMarginalized() const; 39 | 40 | virtual T logPdfUnderPriorMarginalized(const Matrix& x); 41 | 42 | // virtual NiwSampled* merge(const NiwSampled& other); 43 | // void fromMerge(const NiwSampled& niwA, const NiwSampled& niwB); 44 | 45 | void print() const; 46 | virtual uint32_t getDim() const {return(uint32_t(vmf_.D_));}; 47 | 48 | // const Matrix& scatter() const {return niw0_.scatter();}; 49 | // const Matrix& mean() const {return niw0_.mean();}; 50 | // T count() const {return niw0_.count();}; 51 | //// T& count() {return niw0_.count_;}; 52 | const Matrix& getMean() const {return vmf_.mu_;}; 53 | const T tau() const {return vmf_.tau();}; 54 | 55 | vMFpriorFull vmfPrior_; 56 | vMF vmf_; 57 | private: 58 | 59 | }; 60 | 61 | // ------------------------- impl ------------------------------------------- 62 | 63 | template 64 | vMFbase::vMFbase(const vMFpriorFull& vmfPrior) 65 | : vmfPrior_(vmfPrior), vmf_(vmfPrior_.sample()) 66 | {}; 67 | 68 | template 69 | vMFbase::vMFbase(const vMFbase& base) 70 | : vmfPrior_(base.vmfPrior_), vmf_(base.vmf_) 71 | {}; 72 | 73 | 74 | template 75 | vMFbase::~vMFbase() 76 | {}; 77 | 78 | template 79 | BaseMeasure* vMFbase::copy() 80 | { 81 | return new vMFbase(*this); 82 | }; 83 | 84 | template 85 | vMFbase* vMFbase::copyNative() 86 | { 87 | return new vMFbase(*this); 88 | }; 89 | 90 | template 91 | T vMFbase::logLikelihood(const Matrix& x) const 92 | { 93 | // cout< 98 | void vMFbase::posterior(const Matrix& x, const VectorXu& z, 99 | uint32_t k) 100 | { 101 | vmfPrior_.getSufficientStatistics(x,z,k); 102 | // needs current vmf since it samples tau|mu_old and then mu|tau 103 | vmf_ = vmfPrior_.sampleFromPosterior(vmf_); 104 | }; 105 | 106 | template 107 | void vMFbase::posterior(const vector >&x, const VectorXu& z, 108 | uint32_t k) 109 | { 110 | }; 111 | 112 | template 113 | void vMFbase::sample() 114 | { 115 | }; 116 | 117 | template 118 | void vMFbase::print() const 119 | { 120 | vmf_.print(); 121 | }; 122 | 123 | template 124 | T vMFbase::logPdfUnderPrior() const 125 | { 126 | return 0.; 127 | }; 128 | 129 | template 130 | T vMFbase::logPdfUnderPriorMarginalized() const 131 | { 132 | return 0.; 133 | }; 134 | 135 | template 136 | T vMFbase::logPdfUnderPriorMarginalized(const Matrix& x) 137 | { 138 | // approximate the log pdf under the prior via monte carlo sampling 139 | T logPdfMarg = 0; 140 | uint32_t N = 3; 141 | //#pragma omp parallel for reduction(+:logPdfMarg) 142 | for(uint32_t t=0; t vmf = vmfPrior_.sample(); 145 | logPdfMarg = logPdfMarg + vmf.logPdf(x); 146 | } 147 | return logPdfMarg/T(N); 148 | }; 149 | 150 | -------------------------------------------------------------------------------- /include/dpMM/vmfBaseMeasure3D.hpp: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2017, Julian Straub , Randi Cabezas 2 | * Licensed under the MIT license. See the license file LICENSE. 3 | */ 4 | 5 | 6 | #pragma once 7 | 8 | #include 9 | 10 | #include 11 | #include 12 | 13 | /* 14 | * vmf base measure; uses closed form for marginal data density 15 | * (J. Straub, "Nonparamatric Directional Perception", 2017) 16 | */ 17 | template 18 | class vMFbase3D : public BaseMeasure 19 | { 20 | public: 21 | vMFbase3D(const vMFprior& vmfPrior); 22 | vMFbase3D(const vMFbase3D& vmf); 23 | ~vMFbase3D(); 24 | 25 | virtual BaseMeasure* copy(); 26 | virtual vMFbase3D* copyNative(); 27 | 28 | T logLikelihood(const Matrix& x) const; 29 | T logLikelihood(const Matrix& x, uint32_t i) const 30 | {return logLikelihood(x.col(i));}; 31 | void posterior(const Matrix& x, const VectorXu& z, 32 | uint32_t k); 33 | void posterior(const vector >&x, const VectorXu& z, 34 | uint32_t k); 35 | void sample(); 36 | 37 | T logPdfUnderPrior() const; 38 | virtual T logPdfUnderPriorMarginalized() const; 39 | 40 | virtual T logPdfUnderPriorMarginalized(const Matrix& x); 41 | 42 | // virtual NiwSampled* merge(const NiwSampled& other); 43 | // void fromMerge(const NiwSampled& niwA, const NiwSampled& niwB); 44 | 45 | void print() const; 46 | virtual uint32_t getDim() const {return(uint32_t(vmf_.D_));}; 47 | 48 | // const Matrix& scatter() const {return niw0_.scatter();}; 49 | // const Matrix& mean() const {return niw0_.mean();}; 50 | // T count() const {return niw0_.count();}; 51 | //// T& count() {return niw0_.count_;}; 52 | const Matrix& getMean() const {return vmf_.mu_;}; 53 | const T tau() const {return vmf_.tau();}; 54 | 55 | vMFprior vmfPrior_; 56 | vMF vmf_; 57 | private: 58 | 59 | }; 60 | 61 | // ------------------------- impl ------------------------------------------- 62 | 63 | template 64 | vMFbase3D::vMFbase3D(const vMFprior& vmfPrior) 65 | : vmfPrior_(vmfPrior), vmf_(vmfPrior_.sample()) 66 | {}; 67 | 68 | template 69 | vMFbase3D::vMFbase3D(const vMFbase3D& base) 70 | : vmfPrior_(base.vmfPrior_), vmf_(base.vmf_) 71 | {}; 72 | 73 | 74 | template 75 | vMFbase3D::~vMFbase3D() 76 | {}; 77 | 78 | template 79 | BaseMeasure* vMFbase3D::copy() 80 | { 81 | return new vMFbase3D(*this); 82 | }; 83 | 84 | template 85 | vMFbase3D* vMFbase3D::copyNative() 86 | { 87 | return new vMFbase3D(*this); 88 | }; 89 | 90 | template 91 | T vMFbase3D::logLikelihood(const Matrix& x) const 92 | { 93 | // cout< 98 | void vMFbase3D::posterior(const Matrix& x, const VectorXu& z, 99 | uint32_t k) 100 | { 101 | vmfPrior_.getSufficientStatistics(x,z,k); 102 | std::cout << vmfPrior_.xSum_.transpose() << " " << vmfPrior_.count_ << std::endl; 103 | vmf_ = vmfPrior_.sampleFromPosterior(); 104 | }; 105 | 106 | template 107 | void vMFbase3D::posterior(const vector >&x, const VectorXu& z, 108 | uint32_t k) 109 | { 110 | }; 111 | 112 | template 113 | void vMFbase3D::sample() 114 | { 115 | vmf_ = vmfPrior_.sample(); 116 | }; 117 | 118 | template 119 | void vMFbase3D::print() const 120 | { 121 | vmf_.print(); 122 | }; 123 | 124 | template 125 | T vMFbase3D::logPdfUnderPrior() const 126 | { 127 | return 0.; 128 | }; 129 | 130 | template 131 | T vMFbase3D::logPdfUnderPriorMarginalized() const 132 | { 133 | return vmfPrior_.logPdfMarginalized(); 134 | }; 135 | 136 | template 137 | T vMFbase3D::logPdfUnderPriorMarginalized(const Matrix& x) 138 | { 139 | return vmfPrior_.logMarginal(x); 140 | }; 141 | 142 | -------------------------------------------------------------------------------- /include/dpmmSubclusters/normal.cpp: -------------------------------------------------------------------------------- 1 | // ============================================================================= 2 | // == normal.cpp 3 | // == -------------------------------------------------------------------------- 4 | // == A class for a Normal distribution 5 | // == -------------------------------------------------------------------------- 6 | // == Copyright 2013. MIT. All Rights Reserved. 7 | // == Written by Jason Chang 11-03-2013 8 | // == -------------------------------------------------------------------------- 9 | // == If this code is used, the following should be cited: 10 | // == 11 | // == [1] J. Chang and J. W. Fisher II, "Parallel Sampling of DP Mixtures 12 | // == Models using Sub-Cluster Splits". Neural Information Processing 13 | // == Systems (NIPS 2013), Lake Tahoe, NV, USA, Dec 2013. 14 | // ============================================================================= 15 | 16 | #include "normal.h" 17 | 18 | #ifndef pi 19 | #define pi 3.14159265 20 | #endif 21 | 22 | #ifndef logpi 23 | #define logpi 1.144729885849 24 | #endif 25 | 26 | // -------------------------------------------------------------------------- 27 | // -- normal 28 | // -- constructor; initializes to empty 29 | // -------------------------------------------------------------------------- 30 | normal::normal() : D(0), D2(0), mean(NULL), cov(NULL), prec(NULL), logDetCov(0) 31 | { 32 | } 33 | 34 | // -------------------------------------------------------------------------- 35 | // -- normal 36 | // -- copy constructor; 37 | // -------------------------------------------------------------------------- 38 | normal::normal(const normal& that) 39 | { 40 | copy(that); 41 | } 42 | // -------------------------------------------------------------------------- 43 | // -- operator= 44 | // -- assignment operator 45 | // -------------------------------------------------------------------------- 46 | normal& normal::operator=(const normal& that) 47 | { 48 | if (this != &that) 49 | { 50 | if (D==that.D) 51 | { 52 | logDetCov = that.logDetCov; 53 | memcpy(mean, that.mean, sizeof(double)*D); 54 | memcpy(cov, that.cov, sizeof(double)*D2); 55 | memcpy(prec, that.prec, sizeof(double)*D2); 56 | } 57 | else 58 | { 59 | cleanup(); 60 | copy(that); 61 | } 62 | } 63 | return *this; 64 | } 65 | // -------------------------------------------------------------------------- 66 | // -- copy 67 | // -- returns a copy of this 68 | // -------------------------------------------------------------------------- 69 | void normal::copy(const normal& that) 70 | { 71 | D = that.D; 72 | D2 = that.D2; 73 | logDetCov = that.logDetCov; 74 | mean = allocate_memory(D); 75 | cov = allocate_memory(D2); 76 | prec = allocate_memory(D2); 77 | memcpy(mean, that.mean, sizeof(double)*D); 78 | memcpy(cov, that.cov, sizeof(double)*D2); 79 | memcpy(prec, that.prec, sizeof(double)*D2); 80 | } 81 | 82 | // -------------------------------------------------------------------------- 83 | // -- normal 84 | // -- constructor; intializes to all the values given 85 | // -------------------------------------------------------------------------- 86 | normal::normal(int _D) 87 | { 88 | D = _D; 89 | D2 = D*D; 90 | mean = allocate_memory(D); 91 | cov = allocate_memory(D2); 92 | prec = allocate_memory(D2); 93 | } 94 | 95 | // -------------------------------------------------------------------------- 96 | // -- ~normal 97 | // -- destructor 98 | // -------------------------------------------------------------------------- 99 | normal::~normal() 100 | { 101 | cleanup(); 102 | } 103 | // -------------------------------------------------------------------------- 104 | // -- ~cleanup 105 | // -- deletes all the memory allocated by this 106 | // -------------------------------------------------------------------------- 107 | void normal::cleanup() 108 | { 109 | if (mean) deallocate_memory(mean); mean = NULL; 110 | if (cov) deallocate_memory(cov); cov = NULL; 111 | if (prec) deallocate_memory(prec); prec = NULL; 112 | } 113 | 114 | -------------------------------------------------------------------------------- /include/dpmmSubclusters/normal.h: -------------------------------------------------------------------------------- 1 | // ============================================================================= 2 | // == normal.h 3 | // == -------------------------------------------------------------------------- 4 | // == A class for a Normal distribution 5 | // == -------------------------------------------------------------------------- 6 | // == Copyright 2013. MIT. All Rights Reserved. 7 | // == Written by Jason Chang 11-03-2013 8 | // == -------------------------------------------------------------------------- 9 | // == If this code is used, the following should be cited: 10 | // == 11 | // == [1] J. Chang and J. W. Fisher II, "Parallel Sampling of DP Mixtures 12 | // == Models using Sub-Cluster Splits". Neural Information Processing 13 | // == Systems (NIPS 2013), Lake Tahoe, NV, USA, Dec 2013. 14 | // ============================================================================= 15 | 16 | #ifndef _NORMAL_H_INCLUDED_ 17 | #define _NORMAL_H_INCLUDED_ 18 | 19 | //#include "matrix.h" 20 | //#include "mex.h" 21 | #include 22 | //#include "array.h" 23 | 24 | //#include "helperMEX.h" 25 | //#include "debugMEX.h" 26 | 27 | #include "dpmmSubclusters/linear_algebra.h" 28 | #include "dpmmSubclusters/myfuncs.h" 29 | 30 | #ifndef log2pi 31 | #define log2pi 1.837877066409 32 | #endif 33 | 34 | class normal 35 | { 36 | public: 37 | // instantiated gaussian parameters 38 | int D; 39 | int D2; 40 | arr(double) mean; 41 | arr(double) cov; 42 | arr(double) prec; 43 | double logDetCov; 44 | 45 | public: 46 | // -------------------------------------------------------------------------- 47 | // -- normal 48 | // -- constructor; initializes to empty 49 | // -------------------------------------------------------------------------- 50 | normal(); 51 | // -------------------------------------------------------------------------- 52 | // -- normal 53 | // -- copy constructor; 54 | // -------------------------------------------------------------------------- 55 | normal(const normal& that); 56 | // -------------------------------------------------------------------------- 57 | // -- operator= 58 | // -- assignment operator 59 | // -------------------------------------------------------------------------- 60 | normal& operator=(const normal& that); 61 | // -------------------------------------------------------------------------- 62 | // -- copy 63 | // -- returns a copy of this 64 | // -------------------------------------------------------------------------- 65 | void copy(const normal& that); 66 | // -------------------------------------------------------------------------- 67 | // -- normal 68 | // -- constructor; intializes to all the values given 69 | // -------------------------------------------------------------------------- 70 | normal(int _D); 71 | 72 | // -------------------------------------------------------------------------- 73 | // -- ~normal 74 | // -- destructor 75 | // -------------------------------------------------------------------------- 76 | virtual ~normal(); 77 | 78 | // -------------------------------------------------------------------------- 79 | // -- ~cleanup 80 | // -- deletes all the memory allocated by this 81 | // -------------------------------------------------------------------------- 82 | virtual void cleanup(); 83 | 84 | double predictive_loglikelihood(arr(double) data) const; 85 | double data_loglikelihood(int N, arr(double) t, arr(double) T, arr(double) tempVec) const; 86 | double Jdivergence(const normal &other); 87 | 88 | friend class niw_sampled; 89 | friend class niwSphere_sampled; 90 | friend class cluster_sampled; 91 | }; 92 | 93 | 94 | inline double normal::predictive_loglikelihood(arr(double) data) const 95 | { 96 | return -0.5*xmut_A_xmu(data, mean, prec, D) - 0.5*logDetCov - 0.5*D*log2pi; 97 | } 98 | 99 | 100 | inline double normal::data_loglikelihood(int N, arr(double) t, arr(double) T, arr(double) tempVec) const 101 | { 102 | if (N==0) 103 | return 0; 104 | for (int d=0; d 5 | 6 | #include "tableFuncs.h" 7 | 8 | inline double total_logcategorical(arr(double) probabilities, int K, double maxProb) 9 | { 10 | double totalProb = 0; 11 | for (int k=0; kmaxVal) 69 | { 70 | maxVal = probabilities[a]; 71 | k = a; 72 | } 73 | } 74 | return k; 75 | } 76 | 77 | inline int max_categorical(arr(double) probabilities, int K, double totalProb, gsl_rng *r) 78 | { 79 | return max_categorical(probabilities, K); 80 | } 81 | #endif 82 | -------------------------------------------------------------------------------- /include/dpmmSubclustersV2/README: -------------------------------------------------------------------------------- 1 | 2 | 3 | use sample_labels_2, propose_splits2, propose_merges2 4 | these are newer split merge moves that should be stand alone and are improved over the ones described in NIPS 2013 5 | the theory for these is described in Jasons thesis for DPs and for HDPs in the (not yet published ICML). 6 | 7 | 8 | -------------------------------------------------------------------------------- /include/mmf/mf.hpp: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2015, Julian Straub Licensed 2 | * under the MIT license. See the license file LICENSE. 3 | */ 4 | 5 | #pragma once 6 | 7 | #include 8 | 9 | #include 10 | #include 11 | 12 | template 13 | class MF : public Distribution 14 | { 15 | public: 16 | 17 | // MF(const Matrix& R, const NormalSphere& TGs, 18 | // boost::mt19937 *pRndGen); 19 | // MF(); 20 | MF(const Matrix& R, 21 | const Cat& pi, 22 | const std::vector >& TGs); 23 | // boost::mt19937 *pRndGen); 24 | MF(const MF& mf); 25 | ~MF(); 26 | 27 | T logPdf(const Matrix& x) const; 28 | 29 | const Matrix& R() const {return R_;}; 30 | const Cat& Pi() const {return pi_;}; 31 | const Matrix& Sigma(uint32_t j) const 32 | {return TGs_[j].Sigma();}; 33 | const std::vector >& TGs() const 34 | {return TGs_;}; 35 | 36 | void print() const; 37 | 38 | // boost::mt19937 *pRndGen_; 39 | protected: 40 | Matrix R_; 41 | std::vector > TGs_; 42 | Cat pi_; 43 | }; 44 | 45 | 46 | // ------------------------------------------------------ 47 | 48 | //template 49 | //MF::MF(const Matrix& R, const NormalSphere& TG, 50 | // boost::mt19937 *pRndGen) 51 | // : R_(R), TGs_(6,TG), pRndGen_(pRndGen) 52 | //{}; 53 | template 54 | MF::MF(const Matrix& R, 55 | const Cat& pi, 56 | const std::vector >& TGs) 57 | // boost::mt19937 *pRndGen) 58 | : Distribution(NULL), 59 | R_(R), TGs_(TGs), pi_(pi) 60 | // pRndGen_(pRndGen) 61 | {}; 62 | 63 | //template 64 | //MF::MF() 65 | // : Distribution(NULL), 66 | // TGs_(TGs), pi_(pi) 67 | //{ 68 | // R_ = Matrix::Identity(); 69 | // for(uint32_t k=0; k<6; ++k) 70 | // TGs_.push_back(NormalSphere()); 71 | // 72 | //}; 73 | 74 | template 75 | MF::MF(const MF& mf) 76 | : Distribution(NULL), 77 | R_(mf.R()), TGs_(mf.TGs()), pi_(mf.Pi()) //, pRndGen_(mf.pRndGen_) 78 | {}; 79 | 80 | template 81 | MF::~MF() 82 | {}; 83 | 84 | template 85 | T MF::logPdf(const Matrix& x) const 86 | { 87 | Matrix logPdf(6); 88 | logPdf.fill(0.); 89 | for(uint32_t k=0; k<6; ++k) 90 | { 91 | logPdf(k)= pi_.logPdf(k) + TGs_[k].logPdf(x); 92 | // cout<< (pi_.logPdf(k) + TGs_[k].logPdf(x)) << "\t"; 93 | } 94 | // cout<<" -> "<(logPdf); 96 | }; 97 | 98 | template 99 | void MF::print() const 100 | { 101 | cout<<" -- MF: R, pi"< 111 | //MF::() 112 | //{}; 113 | //template 114 | //MF::() 115 | //{}; 116 | //template 117 | //MF::() 118 | //{}; 119 | //template 120 | //MF::() 121 | //{}; 122 | //template 123 | //MF::() 124 | //{}; 125 | -------------------------------------------------------------------------------- /include/mmf/optimizationSO3.hpp: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2015, Julian Straub Licensed 2 | * under the MIT license. See the license file LICENSE. 3 | */ 4 | #pragma once 5 | 6 | #include 7 | #include 8 | #include 9 | #include 10 | #include 11 | #include 12 | #include 13 | #include 14 | 15 | // CUDA runtime 16 | #include 17 | // Utilities and system includes 18 | //#include 19 | #include 20 | 21 | #include 22 | #include 23 | 24 | using namespace Eigen; 25 | using namespace std; 26 | 27 | extern void robustSquaredAngleCostFctGPU(float *h_cost, float *d_cost, 28 | float *d_x, float* d_weights, uint32_t *d_z, float *d_mu, float sigma_sq, 29 | int N); 30 | 31 | extern void robustSquaredAngleCostFctAssignmentGPU(float *h_cost, float *d_cost, 32 | uint32_t *h_W, uint32_t *d_W, float *d_x, float* d_weights, 33 | uint32_t *d_z, float *d_mu, float sigma_sq, int N); 34 | 35 | extern void robustSquaredAngleCostFctJacobianGPU(float *h_J, float *d_J, 36 | float *d_x, float *d_weights, uint32_t *d_z, float *d_mu, float sigma_sq, 37 | int N); 38 | 39 | extern void meanInTpS2GPU(float *h_p, float *d_p, float *h_mu_karch, 40 | float *d_mu_karch, float *d_q, uint32_t *d_z, float* d_weights,int N); 41 | 42 | extern void sufficientStatisticsOnTpS2GPU(float *h_p, float *d_p, float 43 | *h_Rnorths, float *d_Rnorths, float *d_q, uint32_t *d_z ,int N, float 44 | *h_SSs, float *d_SSs); 45 | 46 | extern void loadRGBvaluesForMFaxes(); 47 | 48 | namespace mmf{ 49 | 50 | class OptSO3 51 | { 52 | protected: 53 | float *d_cost, *d_J, *d_mu_; 54 | // float *h_errs_; 55 | uint32_t *d_N_; 56 | float t_max_, dt_; 57 | 58 | jsc::ClDataGpu cld_; 59 | 60 | public: 61 | // float *d_errs_; 62 | // float *d_q_ 63 | float *d_weights_; 64 | const float sigma_sq_; 65 | // uint32_t *d_z, *h_z; 66 | 67 | float dtPrep_; // time for preparation (here assignemnts) 68 | float dtCG_; // time for cunjugate gradient 69 | 70 | uint32_t t_; // timestep 71 | Matrix3f Rprev_; // previous rotation 72 | 73 | // t_max and dt define the number linesearch steps, and how fine 74 | // grained to search 75 | OptSO3(float sigma, float t_max = 1.0f, float dt = 0.1f, 76 | float *d_weights =NULL) 77 | : d_cost(NULL), d_J(NULL), d_mu_(NULL), d_N_(NULL), 78 | t_max_(t_max),dt_(dt), cld_(3,6), 79 | // d_q_(d_q), 80 | d_weights_(d_weights), 81 | sigma_sq_(sigma*sigma), dtPrep_(0.0f), dtCG_(0.0f), 82 | t_(0), Rprev_(Matrix3f::Identity()) 83 | {init();}; 84 | 85 | virtual ~OptSO3(); 86 | 87 | double D_KL_axisUnif(); 88 | float *getErrs(int N); 89 | 90 | // uses uncompressed normals 91 | virtual void updateExternalGpuNormals(float* d_q, uint32_t N, 92 | uint32_t step, uint32_t offset = 0) { 93 | cld_.updateData(d_q,N,step,offset); }; 94 | virtual double conjugateGradientCUDA(Matrix3f& R, uint32_t maxIter=100); 95 | 96 | /* return a skew symmetric matrix from A */ 97 | Matrix3f enforceSkewSymmetry(const Matrix3f &A) const 98 | {return 0.5*(A-A.transpose());}; 99 | 100 | float dtPrep(void) const { return dtPrep_;}; 101 | float dtCG(void) const { return dtCG_;}; 102 | 103 | const VectorXf& counts() {return this->cld_.counts();}; 104 | const VectorXu& z() {return this->cld_.z();}; 105 | const spMatrixXf& x() {return this->cld_.x();}; 106 | uint32_t N() const {return this->cld_.N();}; 107 | 108 | protected: 109 | virtual float conjugateGradientPreparation_impl(Matrix3f& R, uint32_t& N); 110 | virtual float conjugateGradientCUDA_impl(Matrix3f& R, float res0, uint32_t N, uint32_t maxIter=100); 111 | virtual void conjugateGradientPostparation_impl(Matrix3f& R){;}; 112 | /* evaluate cost function for a given assignment of npormals to axes */ 113 | virtual float evalCostFunction(Matrix3f& R); 114 | /* compute Jacobian */ 115 | virtual void computeJacobian(Matrix3f&J, Matrix3f& R, float N); 116 | /* recompute assignment based on rotation R and return residual as well */ 117 | virtual float computeAssignment(Matrix3f& R, uint32_t& N); 118 | /* updates G and H from rotation R and jacobian J 119 | */ 120 | virtual void updateGandH(Matrix3f& G, Matrix3f& G_prev, Matrix3f& H, 121 | const Matrix3f& R, const Matrix3f& J, const Matrix3f& M_t_min, 122 | bool resetH); 123 | /* performs line search starting at R in direction of H 124 | * returns min of cost function and updates R, and M_t_min 125 | */ 126 | virtual float linesearch(Matrix3f& R, Matrix3f& M_t_min, const 127 | Matrix3f& H, float N, float t_max=1.0f, float dt=0.1f); 128 | /* mainly init GPU arrays */ 129 | virtual void init(); 130 | /* copy rotation to device */ 131 | void Rot2Device(Matrix3f& R); 132 | /* convert a Rotation matrix R to a MF representaiton of the axes */ 133 | void Rot2M(Matrix3f& R, float *mu); 134 | //deprecated 135 | void rectifyRotation(Matrix3f& R); 136 | }; 137 | } 138 | -------------------------------------------------------------------------------- /include/mmf/optimizationSO3_approx.hpp: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2015, Julian Straub Licensed 2 | * under the MIT license. See the license file LICENSE. 3 | */ 4 | #pragma once 5 | 6 | #include 7 | #include 8 | #include 9 | #include 10 | #include 11 | #include 12 | 13 | // CUDA runtime 14 | #include 15 | // Utilities and system includes 16 | //#include 17 | #include 18 | 19 | //#include 20 | 21 | using namespace Eigen; 22 | using std::min; 23 | using std::max; 24 | using std::cout; 25 | using std::endl; 26 | 27 | template 28 | class OptSO3ApproxCpu 29 | { 30 | public: 31 | OptSO3ApproxCpu(T t_max = 5.0, T dt = 0.05) 32 | : t_max_(t_max), dt_(dt), t_(0) 33 | { 34 | R_ = Matrix::Identity(); 35 | }; 36 | 37 | virtual ~OptSO3ApproxCpu() 38 | { }; 39 | 40 | // virtual T conjugateGradient(Matrix& R, uint32_t maxIter=100); 41 | virtual T conjugateGradient(Matrix& R, 42 | const Matrix& qKarch, 43 | const Matrix& Ns, 44 | uint32_t maxIter=100); 45 | 46 | /* return a skew symmetric matrix from A */ 47 | Matrix enforceSkewSymmetry(const Matrix &A) const 48 | {return 0.5*(A-A.transpose());}; 49 | 50 | const Matrix& R() const {return R_;}; 51 | /* matrix of the 6 directions of the MF */ 52 | Matrix M() const; 53 | 54 | static Matrix Rot2M(const Matrix& R); 55 | 56 | protected: 57 | T t_max_, dt_; 58 | uint32_t t_; // timestep 59 | Matrix R_; // previous rotation 60 | Matrix qKarch_; // karcher means for all axes 61 | Matrix Ns_; // number of normals for each axis 62 | 63 | virtual void conjugateGradientPostparation_impl(Matrix& R); 64 | virtual T conjugateGradient_impl(Matrix& R, T res0, 65 | uint32_t maxIter=100); 66 | /* 67 | * evaluate cost function for a given assignment of npormals to axes 68 | */ 69 | virtual T evalCostFunction(Matrix& R); 70 | /* compute Jacobian */ 71 | virtual void computeJacobian(Matrix&J, Matrix& R); 72 | 73 | /* 74 | * updates G and H from rotation R and jacobian J 75 | */ 76 | virtual void updateGandH(Matrix& G, Matrix& G_prev, 77 | Matrix& H, const Matrix& R, const Matrix& J, 78 | const Matrix& M_t_min, bool resetH); 79 | /* 80 | * performs line search starting at R in direction of H returns min 81 | * of cost function and updates R, and M_t_min 82 | */ 83 | virtual T linesearch(Matrix& R, Matrix& M_t_min, const 84 | Matrix& H, T t_max=1.0, T dt=0.1); 85 | /* convert a Rotation matrix R to a MF representaiton of the axes */ 86 | void Rot2M(Matrix& R, T *mu); 87 | }; 88 | 89 | -------------------------------------------------------------------------------- /include/nvidia/cuda_global.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2015, Julian Straub 2 | * Licensed under the MIT license. See the license file LICENSE. 3 | */ 4 | 5 | #pragma once 6 | 7 | #include 8 | #include 9 | #include 10 | #include 11 | 12 | #define PI 3.141592653589793 13 | #define DIM 3 14 | 15 | #define MIN_DOT -0.95 16 | #define MAX_DOT 0.95 17 | 18 | #define MAX_UINT32 4294967295 19 | #define INVALID_LABEL MAX_UINT32 //4294967294 20 | 21 | #if DIM==3 22 | template 23 | __device__ inline void Log_p(T *p, T *q, T *x) 24 | { 25 | T dot = min(1.0,max(-1.0,q[0]*p[0] + q[1]*p[1] + q[2]*p[2])); 26 | // 2nd order taylor expansions for the limit cases obtained via mathematica 27 | T invSinc = 0.0; 28 | if(static_cast(MIN_DOT) < dot && dot < static_cast(MAX_DOT)) 29 | invSinc = acos(dot)/sqrt(1.-dot*dot); 30 | else if(dot <= static_cast(MIN_DOT)) 31 | invSinc = PI/(sqrt(2.)*sqrt(dot+1.)) -1. + PI*sqrt(dot+1.)/(4.*sqrt(2.)) 32 | -(dot+1.)/3. + 3.*PI*(dot+1.)*sqrt(dot+1.)/(32.*sqrt(2.)) 33 | - 2./15.*(dot+1.)*(dot+1.); 34 | else if(dot >= static_cast(MAX_DOT)) 35 | invSinc = 1. - (dot-1)/3. + 2./5.*(dot-1.)*(dot-1.); 36 | x[0] = (q[0]-p[0]*dot)*invSinc; 37 | x[1] = (q[1]-p[1]*dot)*invSinc; 38 | x[2] = (q[2]-p[2]*dot)*invSinc; 39 | } 40 | 41 | 42 | template 43 | __device__ inline void Ab(T *A, T *b) 44 | { 45 | 46 | }; 47 | 48 | /* computes b^TAb; 49 | * assumes that A and b are in one piece in memory 50 | * written up for row-major A; but works for col major as well since 51 | * (b^TAb)^T = b^TA^Tb and row -> col major is transposing 52 | */ 53 | template 54 | __device__ inline T bTAb_3D(T *A, T *b) 55 | { 56 | return b[0]*b[0]*A[0] + b[0]*b[1]*A[1] + b[0]*b[2]*A[2] 57 | +b[1]*b[0]*A[3] + b[1]*b[1]*A[4] + b[1]*b[2]*A[5] 58 | +b[2]*b[0]*A[6] + b[2]*b[1]*A[7] + b[2]*b[2]*A[8]; 59 | }; 60 | 61 | /* computes b^TAb; 62 | * assumes that A and b are in one piece in memory 63 | * written up for row-major A; but works for col major as well since 64 | * (b^TAb)^T = b^TA^Tb and row -> col major is transposing 65 | */ 66 | template 67 | __device__ inline T bTAb_2D(T *A, T *b) 68 | { 69 | return b[0]*b[0]*A[0] + b[0]*b[1]*A[1] 70 | +b[1]*b[0]*A[2] + b[1]*b[1]*A[3]; 71 | }; 72 | 73 | #else 74 | template 75 | __device__ inline void Log_p(T *p, T *q, T *x) 76 | { 77 | #pragma unroll 78 | for(int i=1; i 1.e-8) 88 | sinc = theta/sinf(theta); 89 | #pragma unroll 90 | for(int i=0; i col major is transposing 98 | */ 99 | // TODO 100 | //__device__ inline void bTAb(T *A, T *b) 101 | //{ 102 | // return b[0]*b[0]*A[0] + b[0]*b[1]*A[1] + b[0]*b[2]*A[2] 103 | // +b[1]*b[0]*A[3] + b[1]*b[1]*A[4] + b[1]*b[2]*A[5] 104 | // +b[2]*b[0]*A[6] + b[2]*b[1]*A[7] + b[2]*b[2]*A[8]; 105 | //}; 106 | #endif 107 | 108 | /* just base function - empty because we are specializing if you look down */ 109 | template 110 | __device__ inline T atomicAdd_(T* address, T val) 111 | {}; 112 | 113 | /* atomic add for double */ 114 | template<> 115 | __device__ inline double atomicAdd_(double* address, double val) 116 | { 117 | unsigned long long int* address_as_ull = 118 | (unsigned long long int*)address; 119 | unsigned long long int old = *address_as_ull, assumed; 120 | do { 121 | assumed = old; 122 | old = atomicCAS(address_as_ull, assumed,__double_as_longlong(val + 123 | __longlong_as_double(assumed))); 124 | } while (assumed != old); 125 | return __longlong_as_double(old); 126 | }; 127 | 128 | template<> 129 | __device__ inline float atomicAdd_(float* address, float val) 130 | { 131 | return atomicAdd(address,val); 132 | }; 133 | 134 | //template<> 135 | //__device__ inline float atomicAdd_(int* address, int val) 136 | //{ 137 | // return atomicAdd(address,val); 138 | //}; 139 | 140 | 141 | -------------------------------------------------------------------------------- /mathematica/changeOfVariablesJacobian.nb: -------------------------------------------------------------------------------- 1 | (* Content-type: application/vnd.wolfram.mathematica *) 2 | 3 | (*** Wolfram Notebook File ***) 4 | (* http://www.wolfram.com/nb *) 5 | 6 | (* CreatedBy='Mathematica 8.0' *) 7 | 8 | (*CacheID: 234*) 9 | (* Internal cache information: 10 | NotebookFileLineBreakTest 11 | NotebookFileLineBreakTest 12 | NotebookDataPosition[ 157, 7] 13 | NotebookDataLength[ 1434, 54] 14 | NotebookOptionsPosition[ 1151, 40] 15 | NotebookOutlinePosition[ 1491, 55] 16 | CellTagsIndexPosition[ 1448, 52] 17 | WindowFrame->Normal*) 18 | 19 | (* Beginning of Notebook Content *) 20 | Notebook[{ 21 | Cell[BoxData[ 22 | RowBox[{"Derivative", "[", 23 | RowBox[{ 24 | RowBox[{ 25 | RowBox[{"ArcCos", "[", 26 | RowBox[{ 27 | RowBox[{"a", "*", "x"}], "+", 28 | RowBox[{"b", "*", "y"}]}], "]"}], "/", 29 | RowBox[{"Sin", "[", 30 | RowBox[{"ArcCos", "[", 31 | RowBox[{ 32 | RowBox[{"a", "*", "x"}], "+", 33 | RowBox[{"b", "*", "y"}]}], "]"}], "]"}]}], ",", "x"}], "]"}]], "Input",\ 34 | 35 | CellChangeTimes->{{3.608380161778493*^9, 3.6083802208515253`*^9}, { 36 | 3.608380333407675*^9, 3.608380355802525*^9}}], 37 | 38 | Cell[BoxData[""], "Input", 39 | CellChangeTimes->{{3.608380338747663*^9, 3.608380341780439*^9}}] 40 | }, 41 | WindowSize->{740, 867}, 42 | WindowMargins->{{Automatic, -2235}, {53, Automatic}}, 43 | FrontEndVersion->"8.0 for Linux x86 (64-bit) (February 23, 2011)", 44 | StyleDefinitions->"Default.nb" 45 | ] 46 | (* End of Notebook Content *) 47 | 48 | (* Internal cache information *) 49 | (*CellTagsOutline 50 | CellTagsIndex->{} 51 | *) 52 | (*CellTagsIndex 53 | CellTagsIndex->{} 54 | *) 55 | (*NotebookFileOutline 56 | Notebook[{ 57 | Cell[557, 20, 495, 15, 30, "Input"], 58 | Cell[1055, 37, 92, 1, 30, InheritFromParent] 59 | } 60 | ] 61 | *) 62 | 63 | (* End of internal cache information *) 64 | -------------------------------------------------------------------------------- /python/dpmmSampler.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2015, Julian Straub 2 | # Licensed under the MIT license. See the license file LICENSE. 3 | import numpy as np 4 | import subprocess as subp 5 | 6 | import matplotlib.pyplot as plt 7 | 8 | import re, argparse, os 9 | 10 | parser = argparse.ArgumentParser(description = 'DpMM sampler') 11 | parser.add_argument('-i','--input', default="../data/rndSphereDataIwUncertain.csv", help='input csv file N rows and D columns.') 12 | parser.add_argument('-b','--base', default="DpNiwSphereFull",help="Basemeasure to use. Supported right now are: DpNiw (DP-GMM) and DpNiwSphereFull (DP-TGMM).") 13 | parser.add_argument('-T', type=int, default=100, help='number of sampler iterations') 14 | args = parser.parse_args() 15 | 16 | dataPath = args.input 17 | base = args.base 18 | 19 | x=np.loadtxt(dataPath,delimiter=' ') 20 | N = x.shape[1] 21 | D = x.shape[0] 22 | 23 | T=args.T # number of sampler iterations 24 | alpha = 1.0 # alpha concentration parameter of the DP 25 | K = 1 # initial number of clusters 26 | nu = D+1.01 27 | 28 | 29 | if base == 'DpNiw': 30 | kappa = D+3.0 31 | theta = np.ones(D)*0.0#np.mean(x, axis=1) #np.ones(D)*0.0 32 | Delta = nu* (1.*np.pi)/180. * np.eye(D) 33 | params = np.array([nu,kappa]) 34 | params = np.r_[params,theta.ravel(),Delta.ravel()] 35 | elif base == 'DpNiwSphereFull': 36 | Delta = nu* (1.*np.pi)/180. * np.eye(D-1) 37 | params = np.array([nu]) 38 | params = np.r_[params,Delta.ravel()] 39 | 40 | args = [os.path.dirname(os.path.realpath(__file__))+'/../build/dpmmSampler', 41 | '-N {}'.format(N), 42 | '-D {}'.format(D), 43 | '-K {}'.format(K), 44 | '-T {}'.format(T), 45 | '-a {}'.format(alpha), 46 | '--base '+base, 47 | '-i {}'.format(dataPath), 48 | '-o {}'.format(re.sub('csv','lbl',dataPath)), 49 | '-p '+' '.join([str(p) for p in params])] 50 | 51 | print ' '.join(args) 52 | print ' --------------------- ' 53 | ret = subp.call(' '.join(args),shell=True) 54 | print ret 55 | if not ret: 56 | print "Please make sure the sampler is compiled and located at ./build/dpmmSampler" 57 | 58 | z = np.loadtxt(re.sub('csv','lbl',dataPath),dtype=int,delimiter=' ') 59 | z = z/2 # to get from subcluster indices to cluster indices 60 | Ks = np.array([np.unique(z[t,:]).size for t in range(T)]) 61 | 62 | logLikes = np.loadtxt(re.sub('csv','lbl',dataPath)+'_jointLikelihood.csv',delimiter=' ') 63 | print logLikes.shape 64 | print logLikes 65 | 66 | fig = plt.figure() 67 | plt.subplot(2,1,1) 68 | plt.plot(np.arange(T), Ks) 69 | plt.ylabel("number of clusters K") 70 | plt.xlabel("iteration") 71 | plt.subplot(2,1,2) 72 | plt.plot(np.arange(T+1), logLikes) 73 | plt.ylabel("log likelihood") 74 | plt.xlabel("iteration") 75 | plt.show() 76 | -------------------------------------------------------------------------------- /python/evalCompareMethodsOnNYU2.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2015, Julian Straub 2 | # Licensed under the MIT license. See the license file LICENSE. 3 | import numpy as np 4 | import cv2 5 | import os 6 | import fnmatch 7 | 8 | 9 | 10 | cfg=dict() 11 | cfg['path'] = '/data/vision/scratch/fisher/jstraub/dpMM/nyu2' 12 | cfg['base'] = ['DpNiw' , 'DpNiwSphereFull', 'spkm']; 13 | 14 | index = open('/data/vision/fisher/data1/nyu_depth_v2/index.txt') 15 | for i,name in enumerate(index): 16 | name =name[:-1] 17 | found = [None for base in cfg['base']] 18 | for file in os.listdir(cfg['path']): 19 | if not fnmatch.fnmatch(file, '*lbls.png'): 20 | continue 21 | # print file 22 | for j,base in enumerate(cfg['base']): 23 | # print '{}*{}*.png'.format(name,base) 24 | if fnmatch.fnmatch(file, '{}*{}-*.png'.format(name,base)): 25 | found[j] = file 26 | # print file 27 | if not any(f is None for f in found): #found[0] is None and not found[1] is None: 28 | print found 29 | I = cv2.imread(os.path.join(cfg['path'],found[0])) 30 | for f in found[1::]: 31 | I = np.r_[I,cv2.imread(os.path.join(cfg['path'],f))] 32 | # print found 33 | # I0 = cv2.imread(os.path.join(cfg['path'],found[0])) 34 | # I1 = cv2.imread(os.path.join(cfg['path'],found[1])) 35 | # print I0.shape 36 | # print np.c_[I0,I1].shape 37 | # print np.r_[I0,I1].shape 38 | cv2.imshow(' vs. '.join(cfg['base']),I) 39 | cv2.waitKey() 40 | -------------------------------------------------------------------------------- /python/evalHeldout.py: -------------------------------------------------------------------------------- 1 | import time 2 | import numpy as np 3 | import subprocess as subp 4 | 5 | # render and plot without X 6 | #import matplotlib as mpl 7 | #mpl.use('Agg') 8 | 9 | if False: 10 | x = np.loadtxt(rootPath+dataPath) 11 | ho = np.loadtxt(rootPath+heldoutPath) 12 | import matplotlib.pyplot as plt 13 | plt.figure() 14 | plt.plot(x[:,0],x[:,1],'.') 15 | plt.plot(ho[:,0],ho[:,1],'r.') 16 | plt.show() 17 | 18 | reRun = False 19 | reRun = True 20 | plotZ = True 21 | plotZ = False 22 | plotHo = True 23 | plotHo = False 24 | 25 | cfg =dict() 26 | cfg['K'] = 10; 27 | cfg['T'] = 5000 28 | cfg['J'] = 1 29 | cfg['N'] = 100000 30 | cfg['Nho'] = 10000 31 | cfg['D'] = D = 2 32 | cfg['base'] = "DpNiw" 33 | 34 | genSynth = False 35 | if genSynth: 36 | # import ipdb 37 | x = np.c_[np.random.randn(2,100)*0.2,np.random.randn(2,100)*0.2+4.].T 38 | x = x[np.random.permutation(200),:] 39 | # ipdb.set_trace() 40 | np.savetxt("./synth.csv",x[:180,:],fmt='%.18e', delimiter=' ') 41 | np.savetxt("./synthHo.csv",x[180::,:],fmt='%.18e', delimiter=' ') 42 | rootPath = './' 43 | dataPath = 'synth.csv' 44 | heldoutPath = 'synthHo.csv' 45 | cfg['K'] = 1; 46 | cfg['T'] = 100 47 | cfg['J'] = 1 48 | cfg['N'] = 180 49 | cfg['Nho'] = 20 50 | 51 | alpha = [5.5]*cfg['K'] 52 | 53 | nu = 4. 54 | Delta = nu * np.eye(D) 55 | kappa = 0.001 56 | thetaa = np.zeros(D) 57 | params = np.array([nu,kappa]) 58 | params = np.r_[params,thetaa.ravel(),Delta.ravel()] 59 | 60 | if plotZ or plotHo: 61 | import matplotlib.pyplot as plt 62 | if plotHo: 63 | fig = plt.figure(1) 64 | # hoLogLikes = np.zeros 65 | for i in range(30): 66 | if not genSynth: 67 | rootPath = "/scratch/amps/" 68 | rootPath = "/data/vision/scratch/fisher/jstraub/amps/" 69 | dataPath = "train-{:03d}.log".format(i) 70 | heldoutPath = "test-{:03d}.log".format(i) 71 | outName = rootPath+'results/'+dataPath+"_out" 72 | args = ['../build/dpmmSampler', 73 | '--seed {}'.format(int(time.time()*100000) - 100000*int(time.time())), 74 | # '-s', # print silhouette 75 | '-N {}'.format(cfg['N']), 76 | '--Nho {}'.format(cfg['Nho']), 77 | '-D {}'.format(cfg['D']), 78 | '-K {}'.format(cfg['K']), 79 | '-T {}'.format(cfg['T']), 80 | '--alpha '+' '.join([str(a) for a in alpha]), 81 | #'--base NiwSphereUnifNoise', 82 | '--base '+cfg['base'], 83 | '--rowData', 84 | '-i {}'.format(rootPath+dataPath), 85 | '--heldout {}'.format(rootPath+heldoutPath), 86 | '-o {}'.format(outName+'.lbl'), 87 | '--params '+' '.join(['{:.9f}'.format(p) for p in params])] 88 | if reRun: 89 | print ' '.join(args) 90 | print ' --------------------- ' 91 | time.sleep(3) 92 | err = subp.call(' '.join(args),shell=True) 93 | if plotHo: 94 | hoLogLike = np.loadtxt(outName+'.lbl'+"_hoLogLike.csv") 95 | #print hoLogLike[:,0].T 96 | plt.figure(1) 97 | plt.plot(np.cumsum(hoLogLike[:,1])/1000.,hoLogLike[:,0]) 98 | if plotZ: 99 | T = cfg['T'] 100 | x = np.loadtxt(rootPath+dataPath) 101 | z = np.loadtxt(outName+'.lbl').astype(np.int)[-1,:]/2 102 | means = np.loadtxt(outName+'.lbl_means.csv') 103 | covs = np.loadtxt(outName+'.lbl_covs.csv') 104 | K = np.unique(z).max()+1 105 | print "K=",K 106 | fig2 = plt.figure(2) 107 | for k in range(K): 108 | if np.count_nonzero(z==k) >0: 109 | plt.plot(x[z==k,0],x[z==k,1],'.') 110 | mean = means[(T-1)*2:T*2, k*3+2]; 111 | print mean 112 | plt.plot(mean[0],mean[1],'xr') 113 | cov = covs[(T-1)*2:T*2, (k*3+2)*D:(k*3+3)*D]; 114 | L = np.linalg.cholesky(cov) 115 | print cov 116 | c = np.zeros((2,40)) 117 | for i,theta in enumerate(np.linspace(0,np.pi*2,40)): 118 | c[0,i] = np.cos(theta) 119 | c[1,i] = np.sin(theta) 120 | c = (3*(L.dot(c)).T + mean).T 121 | plt.plot(c[0,:],c[1,:],'r') 122 | plt.savefig(outName+'.lbl.png',dpi=300,figure=fig2) 123 | if plotHo: 124 | plt.figure(1) 125 | plt.savefig(rootPath+'results/hologLikes.png',figure=fig) 126 | 127 | -------------------------------------------------------------------------------- /python/evalHeldoutMnistSun.py: -------------------------------------------------------------------------------- 1 | import time 2 | import numpy as np 3 | import subprocess as subp 4 | 5 | # render and plot without X 6 | #import matplotlib as mpl 7 | #mpl.use('Agg') 8 | 9 | reRun = False 10 | reRun = True 11 | plotHo = True 12 | plotHo = False 13 | 14 | cfg =dict() 15 | cfg['K'] = 1; 16 | cfg['T'] = 2000 17 | cfg['J'] = 1 18 | cfg['D'] = D = 20 19 | cfg['base'] = "DpNiw" 20 | 21 | alpha = [5.]*cfg['K'] 22 | 23 | 24 | if plotHo: 25 | fig = plt.figure(1) 26 | # hoLogLikes = np.zeros 27 | rootPath = "/scratch/amps/mnistsun/" 28 | rootPath = "/data/vision/scratch/fisher/jstraub/amps/mnistsun/" 29 | for dataSet in ['lf3','mnist20','sun20']: 30 | dataPath = dataSet+"_train.txt" 31 | x = np.loadtxt(rootPath+dataPath) 32 | heldoutPath = dataSet+"_test.txt" 33 | ho = np.loadtxt(rootPath+heldoutPath) 34 | cfg['N'] = x.shape[0] 35 | cfg['D'] = D = x.shape[1] 36 | cfg['Nho'] = ho.shape[0] 37 | 38 | if dataSet in ['mnist20','sun20']: 39 | nu = D+2. 40 | Delta = nu * np.eye(D) * 1e6 41 | kappa = 0.001 42 | thetaa = np.zeros(D) 43 | params = np.array([nu,kappa]) 44 | params = np.r_[params,thetaa.ravel(),Delta.ravel()] 45 | elif dataSet in ['lf3']: 46 | nu = D+2. 47 | Delta = nu * np.eye(D)*0.1 48 | kappa = 0.01 49 | thetaa = np.zeros(D) 50 | params = np.array([nu,kappa]) 51 | params = np.r_[params,thetaa.ravel(),Delta.ravel()] 52 | 53 | outName = rootPath+'results/'+dataPath+"_out" 54 | args = ['../build/dpmmSampler', 55 | '--seed {}'.format(int(time.time()*100000) - 100000*int(time.time())), 56 | # '-s', # print silhouette 57 | '-N {}'.format(cfg['N']), 58 | '--Nho {}'.format(cfg['Nho']), 59 | '-D {}'.format(cfg['D']), 60 | '-K {}'.format(cfg['K']), 61 | '-T {}'.format(cfg['T']), 62 | '--alpha '+' '.join([str(a) for a in alpha]), 63 | #'--base NiwSphereUnifNoise', 64 | '--base '+cfg['base'], 65 | '--rowData', 66 | '-i {}'.format(rootPath+dataPath), 67 | '--heldout {}'.format(rootPath+heldoutPath), 68 | '-o {}'.format(outName+'.lbl'), 69 | '--params '+' '.join(['{:.9f}'.format(p) for p in params])] 70 | if reRun: 71 | print ' '.join(args) 72 | print ' --------------------- ' 73 | time.sleep(2) 74 | err = subp.call(' '.join(args),shell=True) 75 | if plotHo: 76 | hoLogLike = np.loadtxt(outName+'.lbl'+"_hoLogLike.csv") 77 | #print hoLogLike[:,0].T 78 | plt.figure(1) 79 | plt.plot(np.cumsum(hoLogLike[:,1])/1000.,hoLogLike[:,0]) 80 | if plotHo: 81 | plt.savefig(rootPath+'results/'+dataSet+'hologLikes.png',figure=fig) 82 | 83 | -------------------------------------------------------------------------------- /python/figures/TpS.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jstraub/dpMM/538c432d5f98c040d5c1adb072e545e38f97fc69/python/figures/TpS.png -------------------------------------------------------------------------------- /python/figures/TpS2clusters.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jstraub/dpMM/538c432d5f98c040d5c1adb072e545e38f97fc69/python/figures/TpS2clusters.png -------------------------------------------------------------------------------- /python/figures/TpSGaussian.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jstraub/dpMM/538c432d5f98c040d5c1adb072e545e38f97fc69/python/figures/TpSGaussian.png -------------------------------------------------------------------------------- /python/figures/plotTpS.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2015, Julian Straub 2 | # Licensed under the MIT license. See the license file LICENSE. 3 | 4 | import mayavi.mlab as mlab 5 | import numpy as np 6 | from scipy.linalg import solve, inv, norm 7 | 8 | from vpCluster.manifold.sphere import * 9 | 10 | 11 | def plotGaussianTpS2(R): 12 | Rr,Th = np.meshgrid(np.linspace(0,0.5,100),np.linspace(-np.pi,np.pi,100)) 13 | # X,Y = np.meshgrid(np.linspace(-0.5,0.5,100),np.linspace(-.5,.5,100)) 14 | X,Y = Rr*np.cos(Th),Rr*np.sin(Th) 15 | # color according to covariance S 16 | S = np.eye(2)*0.03 17 | pts = np.c_[X.ravel(),Y.ravel()] 18 | C = -0.5*(pts.T*np.dot(inv(S),pts.T)).sum(axis=0) 19 | C = np.exp(np.reshape(C,X.shape)) 20 | Z = C*0.5 + 1.001 21 | 22 | p3 = np.c_[X.ravel(), Y.ravel(), Z.ravel()].T 23 | print p3.shape 24 | p3 = R.dot(p3) 25 | X = np.reshape(p3[0,:],X.shape) 26 | Y = np.reshape(p3[1,:],Y.shape) 27 | Z = np.reshape(p3[2,:],Z.shape) 28 | 29 | return X,Y,Z,C 30 | 31 | def plotTangentSpace(R,rad=1.0): 32 | 33 | # plot the tangent space 34 | Rr,Th = np.meshgrid(np.linspace(0,rad,100),np.linspace(-np.pi,np.pi,100)) 35 | X,Y = Rr*np.cos(Th),Rr*np.sin(Th) 36 | # X,Y = np.meshgrid(np.linspace(-1.,1.0,100),np.linspace(-1.,1.0,100)) 37 | Z = np.ones(X.shape) 38 | p3 = np.c_[X.ravel(), Y.ravel(), Z.ravel()].T 39 | p3 = R.dot(p3) 40 | X = np.reshape(p3[0,:],X.shape) 41 | Y = np.reshape(p3[1,:],Y.shape) 42 | Z = np.reshape(p3[2,:],Z.shape) 43 | 44 | return X,Y,Z 45 | 46 | mfColor = [] 47 | mfColor.append((232/255.0,65/255.0,32/255.0)) # red 48 | mfColor.append((32/255.0,232/255.0,59/255.0)) # green 49 | mfColor.append((32/255.0,182/255.0,232/255.0)) # tuerkis 50 | mfColor.append((232/255.0,139/255.0,32/255.0)) # orange 51 | 52 | saveFigs = False 53 | 54 | figm = mlab.figure(bgcolor=(1.0,1.0,1.0)) 55 | 56 | o = np.array([0.05,0.05,0.05]) 57 | 58 | # plot the sphere 59 | M = Sphere(2) 60 | #M.plot(figm,1.0) 61 | #M.plotFanzy(figm,1.0) 62 | M.plot(figm,1.0) 63 | R0 = np.eye(3) 64 | 65 | # plot the MF 66 | #plotMF(figm,np.eye(3)) 67 | 68 | # compute p, q and x 69 | p = np.array([0.0,0.0,1.0]) 70 | t = np.linspace(0.0,np.pi/3.5,200) 71 | q = np.zeros((3,t.size)) 72 | q[2,:] = np.cos(t) 73 | q[1,:] = np.sin(t) 74 | x = M.Log_p(p,q) 75 | 76 | # plot the end points p,q,x 77 | s = 0.1 78 | mlab.points3d([p[0]],[p[1]],[p[2]],color=mfColor[1],scale_factor=s) 79 | mlab.points3d(q[0,-1],q[1,-1],q[2,-1],color=mfColor[1],scale_factor=s) 80 | 81 | #s = 0.3 82 | #mlab.text3d(q[0,-1]-o[0], q[1,-1]+o[0], q[2,-1]-o[2],'q',color=(0,0,0),scale=s) 83 | #mlab.text3d(p[0]+o[0], p[1]+o[1], p[2]+o[2],'p',color=(0,0,0),scale=s) 84 | 85 | mlab.points3d(q[0,:],q[1,:],q[2,:],color=mfColor[0],mode='sphere',scale_factor=0.03) 86 | #mlab.show(stop=True) 87 | 88 | # plot the tangent space 89 | X,Y,Z = plotTangentSpace(R0) 90 | mlab.mesh(X,Y,Z,color=mfColor[2], opacity=0.5) 91 | 92 | # plot the trace along manifold and in tangent space 93 | mlab.points3d(x[0,:]+p[0],x[1,:]+p[1],x[2,:]+p[2],color=mfColor[0],mode='sphere',scale_factor=0.03) 94 | # plot the angle 95 | #mlab.points3d(q[0,:],q[1,:],q[2,:],color=(0.0,0.0,1.0),mode='sphere',scale_factor=0.01) 96 | 97 | s = 0.1 98 | mlab.points3d(x[0,-1]+p[0],x[1,-1]+p[1],x[2,-1]+p[2],color=mfColor[1],scale_factor=s) 99 | 100 | # plot descriptive text 101 | #s = 0.3 102 | #mlab.text3d(x[0,-1]+p[0]+o[0], x[1,-1]+p[1]+o[1], x[2,-1]+p[2]+o[2],'x',color=(0,0,0),scale=s) 103 | if saveFigs: 104 | mlab.savefig('./TpS.png',figure=figm,size=(1200,1200)) 105 | 106 | figm = mlab.figure(bgcolor=(1.0,1.0,1.0)) 107 | M.plot(figm,1.0) 108 | X,Y,Z = plotTangentSpace(R0) 109 | mlab.mesh(X,Y,Z,color=mfColor[2], opacity=0.5) 110 | X,Y,Z,C = plotGaussianTpS2(R0) 111 | mlab.mesh(X,Y,Z,scalars=C, colormap='hot', opacity=1., figure=figm) 112 | if saveFigs: 113 | mlab.savefig('./TpSGaussian.png',figure=figm,size=(1200,1200)) 114 | 115 | figm = mlab.figure(bgcolor=(1.0,1.0,1.0)) 116 | s = 0.1 117 | M.plot(figm,1.0) 118 | theta = np.pi/4. 119 | Rx = np.array([[1,0,0],[0,np.cos(theta),np.sin(theta)],[0,-np.sin(theta),np.cos(theta)]]) 120 | Rxn = np.array([[1,0,0],[0,np.cos(-theta),np.sin(-theta)],[0,-np.sin(-theta),np.cos(-theta)]]) 121 | X,Y,Z = plotTangentSpace(R0,1.0) 122 | mlab.mesh(X,Y,Z,color=mfColor[2], opacity=0.5) 123 | mlab.points3d([0],[0],[1],color=mfColor[2],scale_factor=s) 124 | mlab.points3d([0],[theta],[1],color=mfColor[3],scale_factor=s) 125 | mlab.points3d([0],[-theta],[1],color=mfColor[3],scale_factor=s) 126 | 127 | X,Y,Z = plotTangentSpace(Rx,0.6) 128 | mlab.mesh(X,Y,Z,color=mfColor[3], opacity=0.5) 129 | mlab.points3d([Rx[0,2]],[Rx[1,2]],[Rx[2,2]],color=mfColor[3],scale_factor=s) 130 | X,Y,Z = plotTangentSpace(Rxn,0.6) 131 | mlab.mesh(X,Y,Z,color=mfColor[3], opacity=0.5) 132 | mlab.points3d([Rxn[0,2]],[Rxn[1,2]],[Rxn[2,2]],color=mfColor[3],scale_factor=s) 133 | #X,Y,Z,C = plotGaussianTpS2(R0) 134 | #mlab.mesh(X,Y,Z,scalars=C, colormap='hot', opacity=1., figure=figm) 135 | if saveFigs: 136 | mlab.savefig('./TpS2clusters.png',figure=figm,size=(1200,1200)) 137 | 138 | mlab.show() 139 | -------------------------------------------------------------------------------- /python/manifold: -------------------------------------------------------------------------------- 1 | ../../vpCluster/manifold -------------------------------------------------------------------------------- /python/pytagcloudLocal/colors.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2015, Julian Straub 2 | # Licensed under the MIT license. See the license file LICENSE. 3 | COLOR_SCHEMES = { 4 | 'oldschool': ((59,76,76), (125,140,116), (217,175,95), (127,92,70), (51,36,35)), 5 | 'citrus': ((34,51,49), (70,102,66), (153,142,61), (229,156,44), (255,116,37)), 6 | 'goldfish': ((229,106,0), (204,199,148), (153,145,124), (88,89,86), (48,49,51)), 7 | 'audacity': ((181,40,65), (255,192,81), (255,137,57), (232,95,77), (89,0,81)), 8 | } 9 | -------------------------------------------------------------------------------- /python/pytagcloudLocal/fonts/Cantarell-Regular.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jstraub/dpMM/538c432d5f98c040d5c1adb072e545e38f97fc69/python/pytagcloudLocal/fonts/Cantarell-Regular.ttf -------------------------------------------------------------------------------- /python/pytagcloudLocal/fonts/Cardo99s.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jstraub/dpMM/538c432d5f98c040d5c1adb072e545e38f97fc69/python/pytagcloudLocal/fonts/Cardo99s.ttf -------------------------------------------------------------------------------- /python/pytagcloudLocal/fonts/Coustard-Regular.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jstraub/dpMM/538c432d5f98c040d5c1adb072e545e38f97fc69/python/pytagcloudLocal/fonts/Coustard-Regular.ttf -------------------------------------------------------------------------------- /python/pytagcloudLocal/fonts/CrimsonText-Roman.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jstraub/dpMM/538c432d5f98c040d5c1adb072e545e38f97fc69/python/pytagcloudLocal/fonts/CrimsonText-Roman.ttf -------------------------------------------------------------------------------- /python/pytagcloudLocal/fonts/Cuprum.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jstraub/dpMM/538c432d5f98c040d5c1adb072e545e38f97fc69/python/pytagcloudLocal/fonts/Cuprum.ttf -------------------------------------------------------------------------------- /python/pytagcloudLocal/fonts/DroidSans.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jstraub/dpMM/538c432d5f98c040d5c1adb072e545e38f97fc69/python/pytagcloudLocal/fonts/DroidSans.ttf -------------------------------------------------------------------------------- /python/pytagcloudLocal/fonts/IMFeENrm28P.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jstraub/dpMM/538c432d5f98c040d5c1adb072e545e38f97fc69/python/pytagcloudLocal/fonts/IMFeENrm28P.ttf -------------------------------------------------------------------------------- /python/pytagcloudLocal/fonts/Inconsolata.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jstraub/dpMM/538c432d5f98c040d5c1adb072e545e38f97fc69/python/pytagcloudLocal/fonts/Inconsolata.ttf -------------------------------------------------------------------------------- /python/pytagcloudLocal/fonts/JosefinSansStd-Light.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jstraub/dpMM/538c432d5f98c040d5c1adb072e545e38f97fc69/python/pytagcloudLocal/fonts/JosefinSansStd-Light.ttf -------------------------------------------------------------------------------- /python/pytagcloudLocal/fonts/Lobster.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jstraub/dpMM/538c432d5f98c040d5c1adb072e545e38f97fc69/python/pytagcloudLocal/fonts/Lobster.ttf -------------------------------------------------------------------------------- /python/pytagcloudLocal/fonts/Molengo-Regular.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jstraub/dpMM/538c432d5f98c040d5c1adb072e545e38f97fc69/python/pytagcloudLocal/fonts/Molengo-Regular.ttf -------------------------------------------------------------------------------- /python/pytagcloudLocal/fonts/Neucha.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jstraub/dpMM/538c432d5f98c040d5c1adb072e545e38f97fc69/python/pytagcloudLocal/fonts/Neucha.ttf -------------------------------------------------------------------------------- /python/pytagcloudLocal/fonts/Neuton.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jstraub/dpMM/538c432d5f98c040d5c1adb072e545e38f97fc69/python/pytagcloudLocal/fonts/Neuton.ttf -------------------------------------------------------------------------------- /python/pytagcloudLocal/fonts/OldStandard-Regular.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jstraub/dpMM/538c432d5f98c040d5c1adb072e545e38f97fc69/python/pytagcloudLocal/fonts/OldStandard-Regular.ttf -------------------------------------------------------------------------------- /python/pytagcloudLocal/fonts/PT_Sans-Regular.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jstraub/dpMM/538c432d5f98c040d5c1adb072e545e38f97fc69/python/pytagcloudLocal/fonts/PT_Sans-Regular.ttf -------------------------------------------------------------------------------- /python/pytagcloudLocal/fonts/Philosopher.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jstraub/dpMM/538c432d5f98c040d5c1adb072e545e38f97fc69/python/pytagcloudLocal/fonts/Philosopher.ttf -------------------------------------------------------------------------------- /python/pytagcloudLocal/fonts/ReenieBeanie.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jstraub/dpMM/538c432d5f98c040d5c1adb072e545e38f97fc69/python/pytagcloudLocal/fonts/ReenieBeanie.ttf -------------------------------------------------------------------------------- /python/pytagcloudLocal/fonts/Tangerine_Regular.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jstraub/dpMM/538c432d5f98c040d5c1adb072e545e38f97fc69/python/pytagcloudLocal/fonts/Tangerine_Regular.ttf -------------------------------------------------------------------------------- /python/pytagcloudLocal/fonts/Vollkorn-Regular.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jstraub/dpMM/538c432d5f98c040d5c1adb072e545e38f97fc69/python/pytagcloudLocal/fonts/Vollkorn-Regular.ttf -------------------------------------------------------------------------------- /python/pytagcloudLocal/fonts/YanoneKaffeesatz-Regular.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jstraub/dpMM/538c432d5f98c040d5c1adb072e545e38f97fc69/python/pytagcloudLocal/fonts/YanoneKaffeesatz-Regular.ttf -------------------------------------------------------------------------------- /python/pytagcloudLocal/fonts/fonts.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "name": "Nobile", 4 | "ttf": "nobile.ttf", 5 | "web": "http://fonts.googleapis.com/css?family=Nobile" 6 | }, 7 | { 8 | "name": "Old Standard TT", 9 | "ttf": "OldStandard-Regular.ttf", 10 | "web": "http://fonts.googleapis.com/css?family=Old+Standard+TT" 11 | }, 12 | { 13 | "name": "Cantarell", 14 | "ttf": "Cantarell-Regular.ttf", 15 | "web": "http://fonts.googleapis.com/css?family=Cantarell" 16 | }, 17 | { 18 | "name": "Reenie Beanie", 19 | "ttf": "ReenieBeanie.ttf", 20 | "web": "http://fonts.googleapis.com/css?family=Reenie+Beanie" 21 | }, 22 | { 23 | "name": "Cuprum", 24 | "ttf": "Cuprum.ttf", 25 | "web": "http://fonts.googleapis.com/css?family=Cuprum" 26 | }, 27 | { 28 | "name": "Molengo", 29 | "ttf": "Molengo-Regular.ttf", 30 | "web": "http://fonts.googleapis.com/css?family=Molengo" 31 | }, 32 | { 33 | "name": "Neucha", 34 | "ttf": "Neucha.ttf", 35 | "web": "http://fonts.googleapis.com/css?family=Neucha" 36 | }, 37 | { 38 | "name": "Philosopher", 39 | "ttf": "Philosopher.ttf", 40 | "web": "http://fonts.googleapis.com/css?family=Philosopher" 41 | }, 42 | { 43 | "name": "Yanone Kaffeesatz", 44 | "ttf": "YanoneKaffeesatz-Regular.ttf", 45 | "web": "http://fonts.googleapis.com/css?family=Yanone+Kaffeesatz" 46 | }, 47 | { 48 | "name": "Cardo", 49 | "ttf": "Cardo99s.ttf", 50 | "web": "http://fonts.googleapis.com/css?family=Cardo" 51 | }, 52 | { 53 | "name": "Neuton", 54 | "ttf": "Neuton.ttf", 55 | "web": "http://fonts.googleapis.com/css?family=Neuton" 56 | }, 57 | { 58 | "name": "Inconsolata", 59 | "ttf": "Inconsolata.ttf", 60 | "web": "http://fonts.googleapis.com/css?family=Inconsolata" 61 | }, 62 | { 63 | "name": "Crimson Text", 64 | "ttf": "CrimsonText-Roman.ttf", 65 | "web": "http://fonts.googleapis.com/css?family=Crimson+Text" 66 | }, 67 | { 68 | "name": "Josefin Sans", 69 | "ttf": "JosefinSansStd-Light.ttf", 70 | "web": "http://fonts.googleapis.com/css?family=Josefin+Sans" 71 | }, 72 | { 73 | "name": "Droid Sans", 74 | "ttf": "DroidSans.ttf", 75 | "web": "http://fonts.googleapis.com/css?family=Droid+Sans" 76 | }, 77 | { 78 | "name": "Lobster", 79 | "ttf": "Lobster.ttf", 80 | "web": "http://fonts.googleapis.com/css?family=Lobster" 81 | }, 82 | { 83 | "name": "IM Fell DW Pica", 84 | "ttf": "IMFeENrm28P.ttf", 85 | "web": "http://fonts.googleapis.com/css?family=IM+Fell+DW+Pica" 86 | }, 87 | { 88 | "name": "Vollkorn", 89 | "ttf": "Vollkorn-Regular.ttf", 90 | "web": "http://fonts.googleapis.com/css?family=Vollkorn" 91 | }, 92 | { 93 | "name": "Tangerine", 94 | "ttf": "Tangerine_Regular.ttf", 95 | "web": "http://fonts.googleapis.com/css?family=Tangerine" 96 | }, 97 | { 98 | "name": "Coustard", 99 | "ttf": "Coustard-Regular.ttf", 100 | "web": "http://fonts.googleapis.com/css?family=Coustard" 101 | }, 102 | { 103 | "name": "PT Sans Regular", 104 | "ttf": "PT_Sans-Regular.ttf", 105 | "web": "http://fonts.googleapis.com/css?family=PT+Sans" 106 | } 107 | ] -------------------------------------------------------------------------------- /python/pytagcloudLocal/fonts/nobile.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jstraub/dpMM/538c432d5f98c040d5c1adb072e545e38f97fc69/python/pytagcloudLocal/fonts/nobile.ttf -------------------------------------------------------------------------------- /python/pytagcloudLocal/lang/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jstraub/dpMM/538c432d5f98c040d5c1adb072e545e38f97fc69/python/pytagcloudLocal/lang/__init__.py -------------------------------------------------------------------------------- /python/pytagcloudLocal/lang/counter.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | import re 3 | from pytagcloud.lang.stopwords import StopWords 4 | from operator import itemgetter 5 | 6 | def get_tag_counts(text): 7 | """ 8 | Search tags in a given text. The language detection is based on stop lists. 9 | This implementation is inspired by https://github.com/jdf/cue.language. Thanks Jonathan Feinberg. 10 | """ 11 | words = map(lambda x:x.lower(), re.findall(r'\w+', text, re.UNICODE)) 12 | 13 | s = StopWords() 14 | s.load_language(s.guess(words)) 15 | 16 | counted = {} 17 | 18 | for word in words: 19 | if not s.is_stop_word(word) and len(word) > 1: 20 | if counted.has_key(word): 21 | counted[word] += 1 22 | else: 23 | counted[word] = 1 24 | 25 | return sorted(counted.iteritems(), key=itemgetter(1), reverse=True) 26 | -------------------------------------------------------------------------------- /python/pytagcloudLocal/lang/stop/arabic: -------------------------------------------------------------------------------- 1 | إلى 2 | أو 3 | إننا 4 | إن 5 | أن 6 | ب 7 | ا 8 | أ 9 | ، 10 | عشر 11 | عبد 12 | عدد 13 | عدة 14 | عشرة 15 | عدم 16 | عام 17 | عاما 18 | عرفات 19 | عن 20 | عند 21 | عمان 22 | عندما 23 | على 24 | علي 25 | عليه 26 | عليها 27 | عملية 28 | زيارة 29 | سبتمبر 30 | ساراييفو 31 | سنة 32 | سوريا 33 | سنوات 34 | تشرين 35 | تم 36 | تموز 37 | ضد 38 | بعد 39 | بعض 40 | اعادة 41 | اعلن 42 | اعلنت 43 | حزب 44 | حزيران 45 | بسبب 46 | اسرائيل 47 | حسين 48 | حتى 49 | اتفاق 50 | صرب 51 | اذا 52 | احد 53 | اثر 54 | غزة 55 | برس 56 | باسم 57 | اجتماع 58 | غدا 59 | شخصا 60 | صباح 61 | اطار 62 | اربعة 63 | بغداد 64 | اخرى 65 | باريس 66 | رابين 67 | شرق 68 | بان 69 | ابو 70 | اجل 71 | غير 72 | حركة 73 | رئيس 74 | جديدة 75 | اطلاق 76 | بشكل 77 | بطولة 78 | صحيفة 79 | حاليا 80 | بن 81 | به 82 | ثم 83 | اف 84 | ان 85 | او 86 | اي 87 | بها 88 | جهة 89 | صفر 90 | حيث 91 | اكد 92 | الا 93 | اما 94 | العسكرية 95 | العراق 96 | العاصمة 97 | العربية 98 | العراقي 99 | العراقية 100 | العام 101 | العالم 102 | العلاقات 103 | العمل 104 | امس 105 | السعودية 106 | الساعة 107 | السبت 108 | السابق 109 | روسيا 110 | السلطة 111 | السلطات 112 | السلام 113 | التعاون 114 | التحرير 115 | التى 116 | التي 117 | اكتوبر 118 | دورة 119 | اكثر 120 | ايار 121 | ايضا 122 | الجزائر 123 | حماس 124 | الاسرائيلي 125 | الاسرائيلية 126 | الاسبوع 127 | الاسلحة 128 | الاسلامية 129 | ذكرت 130 | الاتحاد 131 | الاتفاق 132 | ثلاثة 133 | الحرب 134 | الاحد 135 | الذاتي 136 | الشرطة 137 | الاربعاء 138 | الغربية 139 | الخارجية 140 | الاردن 141 | الشرق 142 | ايران 143 | الحدود 144 | الرئيس 145 | الاخيرة 146 | الثاني 147 | الثانية 148 | الاثنين 149 | شمال 150 | بيان 151 | دمشق 152 | الذى 153 | الذي 154 | الان 155 | امام 156 | ايام 157 | خلال 158 | الشيخ 159 | الجيش 160 | الدور 161 | الضفة 162 | الجمعة 163 | بيريز 164 | الاوسط 165 | الروسي 166 | البوسنة 167 | الروسية 168 | بيروت 169 | الانتخابات 170 | البلاد 171 | الدفاع 172 | الثلثاء 173 | الانباء 174 | الثلاثاء 175 | الاوروبي 176 | حوالى 177 | الذين 178 | الدول 179 | الحكم 180 | الامم 181 | الامن 182 | الاول 183 | الدولة 184 | الخليج 185 | الخميس 186 | الاميركي 187 | الاميركية 188 | الدولي 189 | الاولى 190 | الدولية 191 | الحكومة 192 | بين 193 | ذلك 194 | دول 195 | دون 196 | حول 197 | حين 198 | الف 199 | الى 200 | انه 201 | اول 202 | ضمن 203 | جنوب 204 | دولة 205 | انها 206 | جميع 207 | الوزراء 208 | المتحدث 209 | المتحدة 210 | دولار 211 | النار 212 | الوضع 213 | القدس 214 | المحتلة 215 | المصدر 216 | المباراة 217 | المصري 218 | الماضي 219 | المصرية 220 | المرحلة 221 | القدم 222 | اللجنة 223 | المجلس 224 | الفرنسي 225 | الفرنسية 226 | القاهرة 227 | المدينة 228 | المانيا 229 | الوطنية 230 | المجموعة 231 | الفلسطيني 232 | الفلسطينية 233 | الفلسطينيين 234 | الوقت 235 | المقرر 236 | القوات 237 | النهائي 238 | المقبل 239 | المنطقة 240 | الولايات 241 | المفاوضات 242 | الملك 243 | اليمن 244 | اليوم 245 | ايلول 246 | الكويت 247 | ـ 248 | ف 249 | و 250 | و6 251 | قد 252 | لا 253 | ما 254 | مع 255 | وزارة 256 | وزير 257 | مساء 258 | قتل 259 | كرة 260 | مصر 261 | هذا 262 | فاز 263 | كأس 264 | ياسر 265 | قرار 266 | مصدر 267 | واحد 268 | قطاع 269 | مصادر 270 | مباراة 271 | مبارك 272 | واضاف 273 | واضافت 274 | فرانس 275 | واشنطن 276 | فان 277 | قبل 278 | قال 279 | كان 280 | لدى 281 | نحو 282 | هذه 283 | وان 284 | محمد 285 | واكد 286 | يذكر 287 | مجلس 288 | فرنسا 289 | كريستوفر 290 | كانت 291 | واوضح 292 | لبنان 293 | مايو 294 | مدينة 295 | مجموعة 296 | كانون 297 | فى 298 | في 299 | كل 300 | لم 301 | لن 302 | له 303 | من 304 | هو 305 | هي 306 | قوة 307 | كما 308 | لها 309 | منذ 310 | وقد 311 | ولا 312 | نفسه 313 | موسكو 314 | مقتل 315 | لقاء 316 | لكرة 317 | نقطة 318 | قوات 319 | مقابل 320 | لندن 321 | هناك 322 | وقال 323 | وكان 324 | منطقة 325 | منظمة 326 | نهاية 327 | وكالة 328 | وقالت 329 | وكانت 330 | للامم 331 | فيه 332 | كلم 333 | لكن 334 | وفي 335 | وقف 336 | ولم 337 | ومن 338 | وهو 339 | وهي 340 | يوم 341 | فيها 342 | منها 343 | مليار 344 | لوكالة 345 | يكون 346 | يمكن 347 | كلينتون 348 | مليون 349 | يوليو 350 | يونيو 351 | نيويورك 352 | -------------------------------------------------------------------------------- /python/pytagcloudLocal/lang/stop/catalan: -------------------------------------------------------------------------------- 1 | a 2 | abans 3 | ací 4 | ah 5 | així 6 | això 7 | al 8 | als 9 | aleshores 10 | algun 11 | alguna 12 | algunes 13 | alguns 14 | alhora 15 | allà 16 | allí 17 | allò 18 | altra 19 | altre 20 | altres 21 | amb 22 | ambdós 23 | ambdues 24 | apa 25 | aquell 26 | aquella 27 | aquelles 28 | aquells 29 | aquest 30 | aquesta 31 | aquestes 32 | aquests 33 | aquí 34 | baix 35 | cada 36 | cadascú 37 | cadascuna 38 | cadascunes 39 | cadascuns 40 | com 41 | contra 42 | d’un 43 | d’una 44 | d’unes 45 | d’uns 46 | dalt 47 | de 48 | del 49 | dels 50 | des 51 | després 52 | dins 53 | dintre 54 | donat 55 | doncs 56 | durant 57 | e 58 | eh 59 | el 60 | els 61 | em 62 | en 63 | encara 64 | ens 65 | entre 66 | érem 67 | eren 68 | éreu 69 | es 70 | és 71 | esta 72 | està 73 | estàvem 74 | estaven 75 | estàveu 76 | esteu 77 | et 78 | etc 79 | ets 80 | fins 81 | fora 82 | gairebé 83 | ha 84 | han 85 | has 86 | havia 87 | he 88 | hem 89 | heu 90 | hi 91 | ho 92 | i 93 | igual 94 | iguals 95 | ja 96 | l’hi 97 | la 98 | les 99 | li 100 | li’n 101 | llavors 102 | m’he 103 | ma 104 | mal 105 | malgrat 106 | mateix 107 | mateixa 108 | mateixes 109 | mateixos 110 | me 111 | mentre 112 | més 113 | meu 114 | meus 115 | meva 116 | meves 117 | molt 118 | molta 119 | moltes 120 | molts 121 | mon 122 | mons 123 | n’he 124 | n’hi 125 | ne 126 | ni 127 | no 128 | nogensmenys 129 | només 130 | nosaltres 131 | nostra 132 | nostre 133 | nostres 134 | o 135 | oh 136 | oi 137 | on 138 | pas 139 | pel 140 | pels 141 | per 142 | però 143 | perquè 144 | poc 145 | poca 146 | pocs 147 | poques 148 | potser 149 | propi 150 | qual 151 | quals 152 | quan 153 | quant 154 | que 155 | què 156 | quelcom 157 | qui 158 | quin 159 | quina 160 | quines 161 | quins 162 | s'ha 163 | s’han 164 | sa 165 | semblant 166 | semblants 167 | ses 168 | seu 169 | seus 170 | seva 171 | seva 172 | seves 173 | si 174 | sobre 175 | sobretot 176 | sóc 177 | solament 178 | sols 179 | son 180 | són 181 | sons 182 | sota 183 | sou 184 | t’ha 185 | t’han 186 | t’he 187 | ta 188 | tal 189 | també 190 | tampoc 191 | tan 192 | tant 193 | tanta 194 | tantes 195 | teu 196 | teus 197 | teva 198 | teves 199 | ton 200 | tons 201 | tot 202 | tota 203 | totes 204 | tots 205 | un 206 | una 207 | unes 208 | uns 209 | us 210 | va 211 | vaig 212 | vam 213 | van 214 | vas 215 | veu 216 | vosaltres 217 | vostra 218 | vostre 219 | vostres 220 | -------------------------------------------------------------------------------- /python/pytagcloudLocal/lang/stop/czech: -------------------------------------------------------------------------------- 1 | ačkoli 2 | ahoj 3 | ale 4 | anebo 5 | ano 6 | asi 7 | aspoň 8 | během 9 | bez 10 | beze 11 | blízko 12 | bohužel 13 | brzo 14 | bude 15 | budeme 16 | budeš 17 | budete 18 | budou 19 | budu 20 | byl 21 | byla 22 | byli 23 | bylo 24 | byly 25 | bys 26 | čau 27 | chce 28 | chceme 29 | chceš 30 | chcete 31 | chci 32 | chtějí 33 | chtít 34 | chut' 35 | chuti 36 | co 37 | čtrnáct 38 | čtyři 39 | dál 40 | dále 41 | daleko 42 | děkovat 43 | děkujeme 44 | děkuji 45 | den 46 | deset 47 | devatenáct 48 | devět 49 | do 50 | dobrý 51 | docela 52 | dva 53 | dvacet 54 | dvanáct 55 | dvě 56 | hodně 57 | já 58 | jak 59 | jde 60 | je 61 | jeden 62 | jedenáct 63 | jedna 64 | jedno 65 | jednou 66 | jedou 67 | jeho 68 | její 69 | jejich 70 | jemu 71 | jen 72 | jenom 73 | ještě 74 | jestli 75 | jestliže 76 | jí 77 | jich 78 | jím 79 | jimi 80 | jinak 81 | jsem 82 | jsi 83 | jsme 84 | jsou 85 | jste 86 | kam 87 | kde 88 | kdo 89 | kdy 90 | když 91 | ke 92 | kolik 93 | kromě 94 | která 95 | které 96 | kteří 97 | který 98 | kvůli 99 | má 100 | mají 101 | málo 102 | mám 103 | máme 104 | máš 105 | máte 106 | mé 107 | mě 108 | mezi 109 | mí 110 | mít 111 | mně 112 | mnou 113 | moc 114 | mohl 115 | mohou 116 | moje 117 | moji 118 | možná 119 | můj 120 | musí 121 | může 122 | my 123 | na 124 | nad 125 | nade 126 | nám 127 | námi 128 | naproti 129 | nás 130 | náš 131 | naše 132 | naši 133 | ne 134 | ně 135 | nebo 136 | nebyl 137 | nebyla 138 | nebyli 139 | nebyly 140 | něco 141 | nedělá 142 | nedělají 143 | nedělám 144 | neděláme 145 | neděláš 146 | neděláte 147 | nějak 148 | nejsi 149 | někde 150 | někdo 151 | nemají 152 | nemáme 153 | nemáte 154 | neměl 155 | němu 156 | není 157 | nestačí 158 | nevadí 159 | než 160 | nic 161 | nich 162 | ním 163 | nimi 164 | nula 165 | od 166 | ode 167 | on 168 | ona 169 | oni 170 | ono 171 | ony 172 | osm 173 | osmnáct 174 | pak 175 | patnáct 176 | pět 177 | po 178 | pořád 179 | potom 180 | pozdě 181 | před 182 | přes 183 | přese 184 | pro 185 | proč 186 | prosím 187 | prostě 188 | proti 189 | protože 190 | rovně 191 | se 192 | sedm 193 | sedmnáct 194 | šest 195 | šestnáct 196 | skoro 197 | smějí 198 | smí 199 | snad 200 | spolu 201 | sta 202 | sté 203 | sto 204 | ta 205 | tady 206 | tak 207 | takhle 208 | taky 209 | tam 210 | tamhle 211 | tamhleto 212 | tamto 213 | tě 214 | tebe 215 | tebou 216 | ted' 217 | tedy 218 | ten 219 | ti 220 | tisíc 221 | tisíce 222 | to 223 | tobě 224 | tohle 225 | toto 226 | třeba 227 | tři 228 | třináct 229 | trošku 230 | tvá 231 | tvé 232 | tvoje 233 | tvůj 234 | ty 235 | určitě 236 | už 237 | vám 238 | vámi 239 | vás 240 | váš 241 | vaše 242 | vaši 243 | ve 244 | večer 245 | vedle 246 | vlastně 247 | všechno 248 | všichni 249 | vůbec 250 | vy 251 | vždy 252 | za 253 | zač 254 | zatímco 255 | ze 256 | že 257 | -------------------------------------------------------------------------------- /python/pytagcloudLocal/lang/stop/danish: -------------------------------------------------------------------------------- 1 | og 2 | i 3 | jeg 4 | det 5 | at 6 | en 7 | den 8 | til 9 | er 10 | som 11 | på 12 | de 13 | med 14 | han 15 | af 16 | for 17 | ikke 18 | der 19 | var 20 | mig 21 | sig 22 | men 23 | et 24 | har 25 | om 26 | vi 27 | min 28 | havde 29 | ham 30 | hun 31 | nu 32 | over 33 | da 34 | fra 35 | du 36 | ud 37 | sin 38 | dem 39 | os 40 | op 41 | man 42 | hans 43 | hvor 44 | eller 45 | hvad 46 | skal 47 | selv 48 | her 49 | alle 50 | vil 51 | blev 52 | kunne 53 | ind 54 | når 55 | være 56 | dog 57 | noget 58 | ville 59 | jo 60 | deres 61 | efter 62 | ned 63 | skulle 64 | denne 65 | end 66 | dette 67 | mit 68 | også 69 | under 70 | have 71 | dig 72 | anden 73 | hende 74 | mine 75 | alt 76 | meget 77 | sit 78 | sine 79 | vor 80 | mod 81 | disse 82 | hvis 83 | din 84 | nogle 85 | hos 86 | blive 87 | mange 88 | ad 89 | bliver 90 | hendes 91 | været 92 | thi 93 | jer 94 | sådan 95 | -------------------------------------------------------------------------------- /python/pytagcloudLocal/lang/stop/dutch: -------------------------------------------------------------------------------- 1 | de 2 | en 3 | van 4 | ik 5 | te 6 | dat 7 | die 8 | in 9 | een 10 | hij 11 | het 12 | niet 13 | zijn 14 | is 15 | was 16 | op 17 | aan 18 | met 19 | als 20 | voor 21 | had 22 | er 23 | maar 24 | om 25 | hem 26 | dan 27 | zou 28 | of 29 | wat 30 | mijn 31 | men 32 | dit 33 | zo 34 | door 35 | over 36 | ze 37 | zich 38 | bij 39 | ook 40 | tot 41 | je 42 | mij 43 | uit 44 | der 45 | daar 46 | haar 47 | naar 48 | heb 49 | hoe 50 | heeft 51 | hebben 52 | deze 53 | u 54 | want 55 | nog 56 | zal 57 | me 58 | zij 59 | nu 60 | ge 61 | geen 62 | omdat 63 | iets 64 | worden 65 | toch 66 | al 67 | waren 68 | veel 69 | meer 70 | doen 71 | toen 72 | moet 73 | ben 74 | zonder 75 | kan 76 | hun 77 | dus 78 | alles 79 | onder 80 | ja 81 | eens 82 | hier 83 | wie 84 | werd 85 | altijd 86 | doch 87 | wordt 88 | wezen 89 | kunnen 90 | ons 91 | zelf 92 | tegen 93 | na 94 | reeds 95 | wil 96 | kon 97 | niets 98 | uw 99 | iemand 100 | geweest 101 | andere 102 | wij 103 | we 104 | z’n 105 | z'n 106 | zo’n 107 | zo'n 108 | -------------------------------------------------------------------------------- /python/pytagcloudLocal/lang/stop/english: -------------------------------------------------------------------------------- 1 | i 2 | me 3 | my 4 | myself 5 | we 6 | us 7 | our 8 | ours 9 | ourselves 10 | you 11 | your 12 | yours 13 | yourself 14 | yourselves 15 | he 16 | him 17 | his 18 | himself 19 | she 20 | her 21 | hers 22 | herself 23 | it 24 | its 25 | itself 26 | they 27 | them 28 | their 29 | theirs 30 | themselves 31 | what 32 | which 33 | who 34 | whom 35 | whose 36 | this 37 | that 38 | these 39 | those 40 | am 41 | is 42 | are 43 | was 44 | were 45 | be 46 | been 47 | being 48 | have 49 | has 50 | had 51 | having 52 | do 53 | does 54 | did 55 | doing 56 | will 57 | would 58 | should 59 | can 60 | could 61 | ought 62 | i'm 63 | you're 64 | he's 65 | she's 66 | it's 67 | we're 68 | they're 69 | i've 70 | you've 71 | we've 72 | they've 73 | i'd 74 | you'd 75 | he'd 76 | she'd 77 | we'd 78 | they'd 79 | i'll 80 | you'll 81 | he'll 82 | she'll 83 | we'll 84 | they'll 85 | isn't 86 | aren't 87 | wasn't 88 | weren't 89 | hasn't 90 | haven't 91 | hadn't 92 | doesn't 93 | don't 94 | didn't 95 | won't 96 | wouldn't 97 | shan't 98 | shouldn't 99 | can't 100 | cannot 101 | couldn't 102 | mustn't 103 | let's 104 | that's 105 | who's 106 | what's 107 | here's 108 | there's 109 | when's 110 | where's 111 | why's 112 | how's 113 | a 114 | an 115 | the 116 | and 117 | but 118 | if 119 | or 120 | because 121 | as 122 | until 123 | while 124 | of 125 | at 126 | by 127 | for 128 | with 129 | about 130 | against 131 | between 132 | into 133 | through 134 | during 135 | before 136 | after 137 | above 138 | below 139 | to 140 | from 141 | up 142 | upon 143 | down 144 | in 145 | out 146 | on 147 | off 148 | over 149 | under 150 | again 151 | further 152 | then 153 | once 154 | here 155 | there 156 | when 157 | where 158 | why 159 | how 160 | all 161 | any 162 | both 163 | each 164 | few 165 | more 166 | most 167 | other 168 | some 169 | such 170 | no 171 | nor 172 | not 173 | only 174 | own 175 | same 176 | so 177 | than 178 | too 179 | very 180 | say 181 | says 182 | said 183 | shall 184 | -------------------------------------------------------------------------------- /python/pytagcloudLocal/lang/stop/esperanto: -------------------------------------------------------------------------------- 1 | mi 2 | ni 3 | ci 4 | vi 5 | li 6 | ŝi 7 | ĝi 8 | si 9 | oni 10 | ili 11 | min 12 | nin 13 | cin 14 | vin 15 | lin 16 | ŝin 17 | ĝin 18 | sin 19 | onin 20 | ilin 21 | mia 22 | nia 23 | cia 24 | via 25 | lia 26 | ŝia 27 | ĝia 28 | sia 29 | onia 30 | ilia 31 | mian 32 | nian 33 | cian 34 | vian 35 | lian 36 | sian 37 | ĝian 38 | sian 39 | onian 40 | ilian 41 | estas 42 | estis 43 | estos 44 | kaj 45 | aŭ 46 | sed 47 | plus 48 | minus 49 | nek 50 | se 51 | ke 52 | ĉu 53 | kvazaŭ 54 | do 55 | ha 56 | he 57 | ho 58 | hu 59 | nu 60 | ve 61 | ankoraŭ 62 | jam 63 | ne 64 | nun 65 | ĵus 66 | tuj 67 | pli 68 | plej 69 | plu 70 | da 71 | de 72 | en 73 | je 74 | antaŭ 75 | post 76 | dum 77 | tio 78 | kio 79 | tiu 80 | kiu 81 | neniu 82 | nenio 83 | iu 84 | io 85 | ĉiu 86 | ĉio 87 | tion 88 | kion 89 | tiun 90 | kiun 91 | tiujn 92 | kiujn 93 | neniun 94 | nenion 95 | iujn 96 | ajn 97 | iun 98 | ion 99 | ĉiun 100 | ĉiujn 101 | ĉion 102 | for 103 | nur 104 | eĉ 105 | mem 106 | ja 107 | jes 108 | ĉi 109 | ĉu 110 | estus 111 | estu 112 | havas 113 | havis 114 | havos 115 | havus 116 | havu 117 | unu 118 | du 119 | tri 120 | kvar 121 | kvin 122 | ses 123 | sep 124 | ok 125 | naŭ 126 | dek 127 | unua 128 | dua 129 | tria 130 | kvara 131 | kvina 132 | sesa 133 | sepa 134 | oka 135 | naŭa 136 | deka 137 | sur 138 | sub 139 | super 140 | tra 141 | preter 142 | inter 143 | supren 144 | post 145 | antaŭ 146 | malantaŭ 147 | jes 148 | ne 149 | eble 150 | verŝajne 151 | nepre 152 | tute 153 | male 154 | bv 155 | bonvolu 156 | bonvole 157 | sed 158 | tamen 159 | kvankam 160 | malgraŭ 161 | ekzemple 162 | ekz 163 | k 164 | sinjoro 165 | sinjor' 166 | s-ro 167 | sinjorino 168 | s-no 169 | fraŭlino 170 | f-no 171 | doktoro 172 | doktor' 173 | d-ro 174 | ĝis 175 | bonan 176 | feliĉan 177 | adiaŭ 178 | la 179 | al 180 | por 181 | -------------------------------------------------------------------------------- /python/pytagcloudLocal/lang/stop/finnish: -------------------------------------------------------------------------------- 1 | olla 2 | olen 3 | olet 4 | on 5 | olemme 6 | olette 7 | ovat 8 | ole 9 | oli 10 | olisi 11 | olisit 12 | olisin 13 | olisimme 14 | olisitte 15 | olisivat 16 | olit 17 | olin 18 | olimme 19 | olitte 20 | olivat 21 | ollut 22 | olleet 23 | en 24 | et 25 | ei 26 | emme 27 | ette 28 | eivät 29 | minä 30 | minun 31 | minut 32 | minua 33 | minussa 34 | minusta 35 | minuun 36 | minulla 37 | minulta 38 | minulle 39 | sinä 40 | sinun 41 | sinut 42 | sinua 43 | sinussa 44 | sinusta 45 | sinuun 46 | sinulla 47 | sinulta 48 | sinulle 49 | hän 50 | hänen 51 | hänet 52 | häntä 53 | hänessä 54 | hänestä 55 | häneen 56 | hänellä 57 | häneltä 58 | hänelle 59 | me 60 | meidän 61 | meidät 62 | meitä 63 | meissä 64 | meistä 65 | meihin 66 | meillä 67 | meiltä 68 | meille 69 | te 70 | teidän 71 | teidät 72 | teitä 73 | teissä 74 | teistä 75 | teihin 76 | teillä 77 | teiltä 78 | teille 79 | he 80 | heidän 81 | heidät 82 | heitä 83 | heissä 84 | heistä 85 | heihin 86 | heillä 87 | heiltä 88 | heille 89 | tämä 90 | tämän 91 | tätä 92 | tässä 93 | tästä 94 | tähän 95 | tallä 96 | tältä 97 | tälle 98 | tänä 99 | täksi 100 | tuo 101 | tuon 102 | tuotä 103 | tuossa 104 | tuosta 105 | tuohon 106 | tuolla 107 | tuolta 108 | tuolle 109 | tuona 110 | tuoksi 111 | se 112 | sen 113 | sitä 114 | siinä 115 | siitä 116 | siihen 117 | sillä 118 | siltä 119 | sille 120 | sinä 121 | siksi 122 | nämä 123 | näiden 124 | näitä 125 | näissä 126 | näistä 127 | näihin 128 | näillä 129 | näiltä 130 | näille 131 | näinä 132 | näiksi 133 | nuo 134 | noiden 135 | noita 136 | noissa 137 | noista 138 | noihin 139 | noilla 140 | noilta 141 | noille 142 | noina 143 | noiksi 144 | ne 145 | niiden 146 | niitä 147 | niissä 148 | niistä 149 | niihin 150 | niillä 151 | niiltä 152 | niille 153 | niinä 154 | niiksi 155 | kuka 156 | kenen 157 | kenet 158 | ketä 159 | kenessä 160 | kenestä 161 | keneen 162 | kenellä 163 | keneltä 164 | kenelle 165 | kenenä 166 | keneksi 167 | ketkä 168 | keiden 169 | ketkä 170 | keitä 171 | keissä 172 | keistä 173 | keihin 174 | keillä 175 | keiltä 176 | keille 177 | keinä 178 | keiksi 179 | mikä 180 | minkä 181 | minkä 182 | mitä 183 | missä 184 | mistä 185 | mihin 186 | millä 187 | miltä 188 | mille 189 | minä 190 | miksi 191 | mitkä 192 | joka 193 | jonka 194 | jota 195 | jossa 196 | josta 197 | johon 198 | jolla 199 | jolta 200 | jolle 201 | jona 202 | joksi 203 | jotka 204 | joiden 205 | joita 206 | joissa 207 | joista 208 | joihin 209 | joilla 210 | joilta 211 | joille 212 | joina 213 | joiksi 214 | että 215 | ja 216 | jos 217 | koska 218 | kuin 219 | mutta 220 | niin 221 | sekä 222 | sillä 223 | tai 224 | vaan 225 | vai 226 | vaikka 227 | kanssa 228 | mukaan 229 | noin 230 | poikki 231 | yli 232 | kun 233 | niin 234 | nyt 235 | itse 236 | -------------------------------------------------------------------------------- /python/pytagcloudLocal/lang/stop/french: -------------------------------------------------------------------------------- 1 | ai 2 | au 3 | aux 4 | avec 5 | ce 6 | ces 7 | dans 8 | de 9 | des 10 | du 11 | elle 12 | en 13 | et 14 | eux 15 | il 16 | je 17 | la 18 | le 19 | les 20 | leur 21 | lui 22 | ma 23 | mais 24 | me 25 | même 26 | mes 27 | moi 28 | mon 29 | ne 30 | nos 31 | notre 32 | nous 33 | on 34 | ou 35 | par 36 | pas 37 | pour 38 | qu 39 | que 40 | qui 41 | sa 42 | se 43 | ses 44 | son 45 | sur 46 | ta 47 | te 48 | tes 49 | toi 50 | ton 51 | tu 52 | un 53 | une 54 | vos 55 | votre 56 | vous 57 | c 58 | d 59 | j 60 | l 61 | à 62 | m 63 | n 64 | s 65 | t 66 | y 67 | été 68 | étée 69 | étées 70 | étés 71 | étant 72 | étante 73 | étants 74 | étantes 75 | suis 76 | es 77 | est 78 | sommes 79 | êtes 80 | sont 81 | serai 82 | seras 83 | sera 84 | serons 85 | serez 86 | seront 87 | serais 88 | serait 89 | serions 90 | seriez 91 | seraient 92 | étais 93 | était 94 | étions 95 | étiez 96 | étaient 97 | fus 98 | fut 99 | fûmes 100 | fûtes 101 | furent 102 | sois 103 | soit 104 | soyons 105 | soyez 106 | soient 107 | fusse 108 | fusses 109 | fût 110 | fussions 111 | fussiez 112 | fussent 113 | ayant 114 | ayante 115 | ayantes 116 | ayants 117 | eu 118 | eue 119 | eues 120 | eus 121 | ai 122 | as 123 | avons 124 | avez 125 | ont 126 | aurai 127 | auras 128 | aura 129 | aurons 130 | aurez 131 | auront 132 | aurais 133 | aurait 134 | aurions 135 | auriez 136 | auraient 137 | avais 138 | avait 139 | avions 140 | aviez 141 | avaient 142 | eut 143 | eûmes 144 | eûtes 145 | eurent 146 | aie 147 | aies 148 | ait 149 | ayons 150 | ayez 151 | aient 152 | eusse 153 | eusses 154 | eût 155 | eussions 156 | eussiez 157 | eussent 158 | -------------------------------------------------------------------------------- /python/pytagcloudLocal/lang/stop/german: -------------------------------------------------------------------------------- 1 | aber 2 | alle 3 | allem 4 | allen 5 | aller 6 | alles 7 | als 8 | also 9 | am 10 | an 11 | ander 12 | andere 13 | anderem 14 | anderen 15 | anderer 16 | anderes 17 | anderm 18 | andern 19 | anders 20 | auch 21 | auf 22 | aus 23 | bei 24 | bin 25 | bis 26 | bist 27 | da 28 | damit 29 | dann 30 | das 31 | dass 32 | daß 33 | dasselbe 34 | dazu 35 | dein 36 | deine 37 | deinem 38 | deinen 39 | deiner 40 | deines 41 | dem 42 | demselben 43 | den 44 | denn 45 | denselben 46 | der 47 | derer 48 | derselbe 49 | derselben 50 | des 51 | desselben 52 | dessen 53 | dich 54 | die 55 | dies 56 | diese 57 | dieselbe 58 | dieselben 59 | diesem 60 | diesen 61 | dieser 62 | dieses 63 | dir 64 | doch 65 | dort 66 | du 67 | durch 68 | ein 69 | eine 70 | einem 71 | einen 72 | einer 73 | eines 74 | einige 75 | einigem 76 | einigen 77 | einiger 78 | einiges 79 | einmal 80 | er 81 | es 82 | etwas 83 | euch 84 | euer 85 | eure 86 | eurem 87 | euren 88 | eurer 89 | eures 90 | für 91 | gegen 92 | gewesen 93 | hab 94 | habe 95 | haben 96 | hat 97 | hatte 98 | hatten 99 | hier 100 | hin 101 | hinter 102 | ich 103 | ihm 104 | ihm 105 | ihn 106 | ihnen 107 | ihr 108 | ihre 109 | ihrem 110 | ihren 111 | ihrer 112 | ihres 113 | im 114 | in 115 | indem 116 | ins 117 | ist 118 | jede 119 | jedem 120 | jeden 121 | jeder 122 | jedes 123 | jene 124 | jenem 125 | jenen 126 | jener 127 | jenes 128 | jetzt 129 | kann 130 | kein 131 | keine 132 | keinem 133 | keinen 134 | keiner 135 | keines 136 | können 137 | könnte 138 | machen 139 | man 140 | manche 141 | manchem 142 | manchen 143 | mancher 144 | manches 145 | mein 146 | meine 147 | meinem 148 | meinen 149 | meiner 150 | meines 151 | mich 152 | mir 153 | mit 154 | muss 155 | musste 156 | nach 157 | nicht 158 | nichts 159 | noch 160 | nun 161 | nur 162 | ob 163 | oder 164 | ohne 165 | sehr 166 | sein 167 | seine 168 | seinem 169 | seinen 170 | seiner 171 | seines 172 | selbst 173 | sich 174 | sie 175 | sind 176 | so 177 | solche 178 | solchem 179 | solchen 180 | solcher 181 | solches 182 | soll 183 | sollte 184 | sondern 185 | sonst 186 | über 187 | um 188 | und 189 | uns 190 | unser 191 | unsere 192 | unserem 193 | unseren 194 | unseres 195 | unter 196 | viel 197 | vom 198 | von 199 | vor 200 | während 201 | war 202 | waren 203 | warst 204 | was 205 | weg 206 | weil 207 | weiter 208 | welche 209 | welchem 210 | welchen 211 | welcher 212 | welches 213 | wenn 214 | werde 215 | werden 216 | wie 217 | wieder 218 | will 219 | wir 220 | wird 221 | wirst 222 | wo 223 | wollen 224 | wollte 225 | würde 226 | würden 227 | zu 228 | zum 229 | zur 230 | zwar 231 | zwischen 232 | -------------------------------------------------------------------------------- /python/pytagcloudLocal/lang/stop/hebrew: -------------------------------------------------------------------------------- 1 | אני 2 | את 3 | אתה 4 | אנחנו 5 | אתן 6 | אתם 7 | הם 8 | הן 9 | היא 10 | הוא 11 | שלי 12 | שלו 13 | שלך 14 | שלכה 15 | שלה 16 | שלנו 17 | שלכם 18 | שלכן 19 | שלהם 20 | שלהן 21 | לי 22 | לו 23 | לה 24 | לנו 25 | לכם 26 | לכן 27 | להם 28 | להן 29 | אותה 30 | אותו 31 | זה 32 | זאת 33 | אלה 34 | אלו 35 | תחת 36 | מתחת 37 | מעל 38 | בין 39 | עם 40 | עד 41 | נגר 42 | על 43 | אל 44 | מול 45 | של 46 | אצל 47 | כמו 48 | אחר 49 | אותו 50 | בלי 51 | לפני 52 | אחרי 53 | מאחורי 54 | עלי 55 | עליו 56 | עליה 57 | עליך 58 | עלינו 59 | עליכם 60 | לעיכן 61 | עליהם 62 | עליהן 63 | כל 64 | כולם 65 | כולן 66 | כך 67 | ככה 68 | כזה 69 | זה 70 | זות 71 | אותי 72 | אותה 73 | אותם 74 | אותך 75 | אותו 76 | אותן 77 | אותנו 78 | ואת 79 | את 80 | אתכם 81 | אתכן 82 | איתי 83 | איתו 84 | איתך 85 | איתה 86 | איתם 87 | איתן 88 | איתנו 89 | איתכם 90 | איתכן 91 | יהיה 92 | תהיה 93 | היתי 94 | היתה 95 | היה 96 | להיות 97 | עצמי 98 | עצמו 99 | עצמה 100 | עצמם 101 | עצמן 102 | עצמנו 103 | עצמהם 104 | עצמהן 105 | מי 106 | מה 107 | איפה 108 | היכן 109 | במקוםשבו 110 | אם 111 | לאן 112 | למקוםשבו 113 | מקוםבו 114 | איזה 115 | מהיכן 116 | איך 117 | כיצד 118 | באיזומידה 119 | מתי 120 | בשעהש 121 | כאשר 122 | כש 123 | למרות 124 | לפני 125 | אחרי 126 | מאיזוסיבה 127 | הסיבהשבגללה 128 | למה 129 | מדוע 130 | לאיזותכלית 131 | כי 132 | יש 133 | אין 134 | אך 135 | מנין 136 | מאין 137 | מאיפה 138 | יכל 139 | יכלה 140 | יכלו 141 | יכול 142 | יכולה 143 | יכולים 144 | יכולות 145 | יוכלו 146 | יוכל 147 | מסוגל 148 | לא 149 | רק 150 | אולי 151 | אין 152 | לאו 153 | אי 154 | כלל 155 | נגד 156 | אם 157 | עם 158 | אל 159 | אלה 160 | אלו 161 | אף 162 | על 163 | מעל 164 | מתחת 165 | מצד 166 | בשביל 167 | לבין 168 | באמצע 169 | בתוך 170 | דרך 171 | מבעד 172 | באמצעות 173 | למעלה 174 | למטה 175 | מחוץ 176 | מן 177 | לעבר 178 | מכאן 179 | כאן 180 | הנה 181 | הרי 182 | פה 183 | שם 184 | אך 185 | ברם 186 | שוב 187 | אבל 188 | מבלי 189 | בלי 190 | מלבד 191 | רק 192 | בגלל 193 | מכיוון 194 | עד 195 | אשר 196 | ואילו 197 | למרות 198 | אס 199 | כמו 200 | כפי 201 | אז 202 | אחריכן 203 | לכן 204 | לפיכך 205 | מאד 206 | עז 207 | מעט 208 | מעטים 209 | במידה 210 | שוב 211 | יותרמדי 212 | גם 213 | כן 214 | נו 215 | אחר 216 | אחרת 217 | אחרים 218 | אחרות 219 | אשר 220 | או 221 | -------------------------------------------------------------------------------- /python/pytagcloudLocal/lang/stop/hindi: -------------------------------------------------------------------------------- 1 | के 2 | का 3 | एक 4 | में 5 | की 6 | है 7 | यह 8 | और 9 | से 10 | हैं 11 | को 12 | पर 13 | इस 14 | होता 15 | कि 16 | जो 17 | कर 18 | मे 19 | गया 20 | करने 21 | किया 22 | लिये 23 | अपने 24 | ने 25 | बनी 26 | नहीं 27 | तो 28 | ही 29 | या 30 | एवं 31 | दिया 32 | हो 33 | इसका 34 | था 35 | द्वारा 36 | हुआ 37 | तक 38 | साथ 39 | करना 40 | वाले 41 | बाद 42 | लिए 43 | आप 44 | कुछ 45 | सकते 46 | किसी 47 | ये 48 | इसके 49 | सबसे 50 | इसमें 51 | थे 52 | दो 53 | होने 54 | वह 55 | वे 56 | करते 57 | बहुत 58 | कहा 59 | वर्ग 60 | कई 61 | करें 62 | होती 63 | अपनी 64 | उनके 65 | थी 66 | यदि 67 | हुई 68 | जा 69 | ना 70 | इसे 71 | कहते 72 | जब 73 | होते 74 | कोई 75 | हुए 76 | व 77 | न 78 | अभी 79 | जैसे 80 | सभी 81 | करता 82 | उनकी 83 | तरह 84 | उस 85 | आदि 86 | कुल 87 | एस 88 | रहा 89 | इसकी 90 | सकता 91 | रहे 92 | उनका 93 | इसी 94 | रखें 95 | अपना 96 | पे 97 | उसके 98 | -------------------------------------------------------------------------------- /python/pytagcloudLocal/lang/stop/hungarian: -------------------------------------------------------------------------------- 1 | a 2 | ahogy 3 | ahol 4 | aki 5 | akik 6 | akkor 7 | alatt 8 | által 9 | általában 10 | amely 11 | amelyek 12 | amelyekben 13 | amelyeket 14 | amelyet 15 | amelynek 16 | ami 17 | amit 18 | amolyan 19 | amíg 20 | amikor 21 | át 22 | abban 23 | ahhoz 24 | annak 25 | arra 26 | arról 27 | az 28 | azok 29 | azon 30 | azt 31 | azzal 32 | azért 33 | aztán 34 | azután 35 | azonban 36 | bár 37 | be 38 | belül 39 | benne 40 | cikk 41 | cikkek 42 | cikkeket 43 | csak 44 | de 45 | e 46 | eddig 47 | egész 48 | egy 49 | egyes 50 | egyetlen 51 | egyéb 52 | egyik 53 | egyre 54 | ekkor 55 | el 56 | elég 57 | ellen 58 | elõ 59 | elõször 60 | elõtt 61 | elsõ 62 | én 63 | éppen 64 | ebben 65 | ehhez 66 | emilyen 67 | ennek 68 | erre 69 | ez 70 | ezt 71 | ezek 72 | ezen 73 | ezzel 74 | ezért 75 | és 76 | fel 77 | felé 78 | ha 79 | hanem 80 | hiszen 81 | hogy 82 | hogyan 83 | igen 84 | így 85 | illetve 86 | ill. 87 | ill 88 | ilyen 89 | ilyenkor 90 | inkább 91 | is 92 | ison 93 | ismét 94 | itt 95 | jó 96 | jól 97 | jobban 98 | kell 99 | kellett 100 | keresztül 101 | keressünk 102 | ki 103 | kívül 104 | között 105 | közül 106 | legalább 107 | lehet 108 | lehetett 109 | legyen 110 | lenne 111 | lenni 112 | lesz 113 | lett 114 | maga 115 | magát 116 | majd 117 | majd 118 | már 119 | más 120 | másik 121 | meg 122 | még 123 | mellett 124 | mert 125 | mely 126 | melyek 127 | mi 128 | mit 129 | míg 130 | miért 131 | milyen 132 | mikor 133 | minden 134 | mindent 135 | mindenki 136 | mindig 137 | mint 138 | mintha 139 | mivel 140 | most 141 | nagy 142 | nagyobb 143 | nagyon 144 | ne 145 | néha 146 | nekem 147 | neki 148 | nem 149 | néhány 150 | nélkül 151 | nincs 152 | olyan 153 | ott 154 | össze 155 | õ 156 | õk 157 | õket 158 | pedig 159 | persze 160 | rá 161 | s 162 | saját 163 | sem 164 | semmi 165 | sok 166 | sokat 167 | sokkal 168 | számára 169 | szemben 170 | szerint 171 | szinte 172 | talán 173 | tehát 174 | teljes 175 | tovább 176 | továbbá 177 | több 178 | úgy 179 | ugyanis 180 | új 181 | újabb 182 | újra 183 | után 184 | utána 185 | utolsó 186 | vagy 187 | vagyis 188 | valaki 189 | valami 190 | valamint 191 | való 192 | vagyok 193 | van 194 | vannak 195 | volt 196 | voltam 197 | voltak 198 | voltunk 199 | vissza 200 | vele 201 | viszont 202 | volna 203 | -------------------------------------------------------------------------------- /python/pytagcloudLocal/lang/stop/italian: -------------------------------------------------------------------------------- 1 | ad 2 | al 3 | allo 4 | ai 5 | agli 6 | all 7 | agl 8 | alla 9 | alle 10 | con 11 | col 12 | coi 13 | da 14 | dal 15 | dallo 16 | dai 17 | dagli 18 | dall 19 | dagl 20 | dalla 21 | dalle 22 | di 23 | del 24 | dello 25 | dei 26 | degli 27 | dell 28 | degl 29 | della 30 | delle 31 | in 32 | nel 33 | nello 34 | nei 35 | negli 36 | nell 37 | negl 38 | nella 39 | nelle 40 | su 41 | sul 42 | sullo 43 | sui 44 | sugli 45 | sull 46 | sugl 47 | sulla 48 | sulle 49 | per 50 | tra 51 | contro 52 | io 53 | tu 54 | lui 55 | lei 56 | noi 57 | voi 58 | loro 59 | mio 60 | mia 61 | miei 62 | mie 63 | tuo 64 | tua 65 | tuoi 66 | tue 67 | suo 68 | sua 69 | suoi 70 | sue 71 | nostro 72 | nostra 73 | nostri 74 | nostre 75 | vostro 76 | vostra 77 | vostri 78 | vostre 79 | mi 80 | ti 81 | ci 82 | vi 83 | lo 84 | la 85 | li 86 | le 87 | gli 88 | ne 89 | il 90 | un 91 | uno 92 | una 93 | ma 94 | ed 95 | se 96 | perché 97 | anche 98 | come 99 | dov 100 | dove 101 | che 102 | chi 103 | cui 104 | non 105 | più 106 | quale 107 | quanto 108 | quanti 109 | quanta 110 | quante 111 | quello 112 | quelli 113 | quella 114 | quelle 115 | questo 116 | questi 117 | questa 118 | queste 119 | si 120 | tutto 121 | tutti 122 | a 123 | c 124 | e 125 | i 126 | l 127 | o 128 | ho 129 | hai 130 | ha 131 | abbiamo 132 | avete 133 | hanno 134 | abbia 135 | abbiate 136 | abbiano 137 | avrò 138 | avrai 139 | avrà 140 | avremo 141 | avrete 142 | avranno 143 | avrei 144 | avresti 145 | avrebbe 146 | avremmo 147 | avreste 148 | avrebbero 149 | avevo 150 | avevi 151 | aveva 152 | avevamo 153 | avevate 154 | avevano 155 | ebbi 156 | avesti 157 | ebbe 158 | avemmo 159 | aveste 160 | ebbero 161 | avessi 162 | avesse 163 | avessimo 164 | avessero 165 | avendo 166 | avuto 167 | avuta 168 | avuti 169 | avute 170 | sono 171 | sei 172 | è 173 | siamo 174 | siete 175 | sia 176 | siate 177 | siano 178 | sarò 179 | sarai 180 | sarà 181 | saremo 182 | sarete 183 | saranno 184 | sarei 185 | saresti 186 | sarebbe 187 | saremmo 188 | sareste 189 | sarebbero 190 | ero 191 | eri 192 | era 193 | eravamo 194 | eravate 195 | erano 196 | fui 197 | fosti 198 | fu 199 | fummo 200 | foste 201 | furono 202 | fossi 203 | fosse 204 | fossimo 205 | fossero 206 | essendo 207 | faccio 208 | fai 209 | facciamo 210 | fanno 211 | faccia 212 | facciate 213 | facciano 214 | farò 215 | farai 216 | farà 217 | faremo 218 | farete 219 | faranno 220 | farei 221 | faresti 222 | farebbe 223 | faremmo 224 | fareste 225 | farebbero 226 | facevo 227 | facevi 228 | faceva 229 | facevamo 230 | facevate 231 | facevano 232 | feci 233 | facesti 234 | fece 235 | facemmo 236 | faceste 237 | fecero 238 | facessi 239 | facesse 240 | facessimo 241 | facessero 242 | facendo 243 | sto 244 | stai 245 | sta 246 | stiamo 247 | stanno 248 | stia 249 | stiate 250 | stiano 251 | starò 252 | starai 253 | starà 254 | staremo 255 | starete 256 | staranno 257 | starei 258 | staresti 259 | starebbe 260 | staremmo 261 | stareste 262 | starebbero 263 | stavo 264 | stavi 265 | stava 266 | stavamo 267 | stavate 268 | stavano 269 | stetti 270 | stesti 271 | stette 272 | stemmo 273 | steste 274 | stettero 275 | stessi 276 | stesse 277 | stessimo 278 | stessero 279 | stando 280 | -------------------------------------------------------------------------------- /python/pytagcloudLocal/lang/stop/latin: -------------------------------------------------------------------------------- 1 | a ab ac ad at atque aut autem cum de dum e et etiam ex haec hic hoc in ita me nec neque non per qua quae quam qui quidem quibus quo quod re rebus rem res sed si sic tamen tandem te ut vel est sunt erat erant -------------------------------------------------------------------------------- /python/pytagcloudLocal/lang/stop/norwegian: -------------------------------------------------------------------------------- 1 | og 2 | i 3 | jeg 4 | det 5 | at 6 | en 7 | et 8 | den 9 | til 10 | er 11 | som 12 | på 13 | de 14 | med 15 | han 16 | av 17 | ikke 18 | ikkje 19 | der 20 | så 21 | var 22 | meg 23 | seg 24 | men 25 | ett 26 | har 27 | om 28 | vi 29 | min 30 | mitt 31 | ha 32 | hadde 33 | hun 34 | nå 35 | over 36 | da 37 | ved 38 | fra 39 | du 40 | ut 41 | sin 42 | dem 43 | oss 44 | opp 45 | man 46 | kan 47 | hans 48 | hvor 49 | eller 50 | hva 51 | skal 52 | selv 53 | sjøl 54 | her 55 | alle 56 | vil 57 | bli 58 | ble 59 | blei 60 | blitt 61 | kunne 62 | inn 63 | når 64 | være 65 | kom 66 | noen 67 | noe 68 | ville 69 | dere 70 | som 71 | deres 72 | kun 73 | ja 74 | etter 75 | ned 76 | skulle 77 | denne 78 | for 79 | deg 80 | si 81 | sine 82 | sitt 83 | mot 84 | å 85 | meget 86 | hvorfor 87 | dette 88 | disse 89 | uten 90 | hvordan 91 | ingen 92 | din 93 | ditt 94 | blir 95 | samme 96 | hvilken 97 | hvilke 98 | sånn 99 | inni 100 | mellom 101 | vår 102 | hver 103 | hvem 104 | vors 105 | hvis 106 | både 107 | bare 108 | enn 109 | fordi 110 | før 111 | mange 112 | også 113 | slik 114 | vært 115 | være 116 | båe 117 | begge 118 | siden 119 | dykk 120 | dykkar 121 | dei 122 | deira 123 | deires 124 | deim 125 | di 126 | då 127 | eg 128 | ein 129 | eit 130 | eitt 131 | elles 132 | honom 133 | hjå 134 | ho 135 | hoe 136 | henne 137 | hennar 138 | hennes 139 | hoss 140 | hossen 141 | ikkje 142 | ingi 143 | inkje 144 | korleis 145 | korso 146 | kva 147 | kvar 148 | kvarhelst 149 | kven 150 | kvi 151 | kvifor 152 | me 153 | medan 154 | mi 155 | mine 156 | mykje 157 | no 158 | nokon 159 | noka 160 | nokor 161 | noko 162 | nokre 163 | si 164 | sia 165 | sidan 166 | so 167 | somt 168 | somme 169 | um 170 | upp 171 | vere 172 | vore 173 | verte 174 | vort 175 | varte 176 | vart 177 | -------------------------------------------------------------------------------- /python/pytagcloudLocal/lang/stop/polish: -------------------------------------------------------------------------------- 1 | ach 2 | aj 3 | albo 4 | bardzo 5 | bez 6 | bo 7 | być 8 | ci 9 | cię 10 | ciebie 11 | co 12 | czy 13 | daleko 14 | dla 15 | dlaczego 16 | dlatego 17 | do 18 | dobrze 19 | dokąd 20 | dość 21 | dużo 22 | dwa 23 | dwaj 24 | dwie 25 | dwoje 26 | dziś 27 | dzisiaj 28 | gdyby 29 | gdzie 30 | go 31 | ich 32 | ile 33 | im 34 | inny 35 | ja 36 | ją 37 | jak 38 | jakby 39 | jaki 40 | je 41 | jeden 42 | jedna 43 | jedno 44 | jego 45 | jej 46 | jemu 47 | jeśli 48 | jest 49 | jestem 50 | jeżeli 51 | już 52 | każdy 53 | kiedy 54 | kierunku 55 | kto 56 | ku 57 | lub 58 | ma 59 | mają 60 | mam 61 | mi 62 | mną 63 | mnie 64 | moi 65 | mój 66 | moja 67 | moje 68 | może 69 | mu 70 | my 71 | na 72 | nam 73 | nami 74 | nas 75 | nasi 76 | nasz 77 | nasza 78 | nasze 79 | natychmiast 80 | nią 81 | nic 82 | nich 83 | nie 84 | niego 85 | niej 86 | niemu 87 | nigdy 88 | nim 89 | nimi 90 | niż 91 | obok 92 | od 93 | około 94 | on 95 | ona 96 | one 97 | oni 98 | ono 99 | owszem 100 | po 101 | pod 102 | ponieważ 103 | przed 104 | przedtem 105 | są 106 | sam 107 | sama 108 | się 109 | skąd 110 | tak 111 | taki 112 | tam 113 | ten 114 | to 115 | tobą 116 | tobie 117 | tu 118 | tutaj 119 | twoi 120 | twój 121 | twoja 122 | twoje 123 | ty 124 | wam 125 | wami 126 | was 127 | wasi 128 | wasz 129 | wasza 130 | wasze 131 | we 132 | więc 133 | wszystko 134 | wtedy 135 | wy 136 | żaden 137 | zawsze 138 | że 139 | -------------------------------------------------------------------------------- /python/pytagcloudLocal/lang/stop/portuguese: -------------------------------------------------------------------------------- 1 | de 2 | a 3 | o 4 | que 5 | e 6 | do 7 | da 8 | em 9 | um 10 | para 11 | pra 12 | com 13 | não 14 | uma 15 | os 16 | no 17 | se 18 | na 19 | por 20 | mais 21 | as 22 | dos 23 | como 24 | mas 25 | ao 26 | ele 27 | das 28 | à 29 | seu 30 | sua 31 | ou 32 | quando 33 | muito 34 | nos 35 | já 36 | eu 37 | também 38 | só 39 | pelo 40 | pela 41 | até 42 | isso 43 | ela 44 | entre 45 | depois 46 | sem 47 | mesmo 48 | aos 49 | seus 50 | quem 51 | nas 52 | me 53 | esse 54 | eles 55 | você 56 | essa 57 | num 58 | nem 59 | suas 60 | meu 61 | às 62 | minha 63 | numa 64 | pelos 65 | elas 66 | qual 67 | nós 68 | lhe 69 | deles 70 | essas 71 | esses 72 | pelas 73 | este 74 | dele 75 | tu 76 | te 77 | vocês 78 | vos 79 | lhes 80 | meus 81 | minhas 82 | teu 83 | tua 84 | teus 85 | tuas 86 | nosso 87 | nossa 88 | nossos 89 | nossas 90 | dela 91 | delas 92 | esta 93 | estes 94 | estas 95 | aquele 96 | aquela 97 | aqueles 98 | aquelas 99 | isto 100 | aquilo 101 | estou 102 | está 103 | estamos 104 | estão 105 | estive 106 | esteve 107 | estivemos 108 | estiveram 109 | estava 110 | estávamos 111 | estavam 112 | estivera 113 | estivéramos 114 | esteja 115 | estejamos 116 | estejam 117 | estivesse 118 | estivéssemos 119 | estivessem 120 | estiver 121 | estivermos 122 | estiverem 123 | hei 124 | há 125 | havemos 126 | hão 127 | houve 128 | houvemos 129 | houveram 130 | houvera 131 | houvéramos 132 | haja 133 | hajamos 134 | hajam 135 | houvesse 136 | houvéssemos 137 | houvessem 138 | houver 139 | houvermos 140 | houverem 141 | houverei 142 | houverá 143 | houveremos 144 | houverão 145 | houveria 146 | houveríamos 147 | houveriam 148 | sou 149 | somos 150 | são 151 | era 152 | éramos 153 | eram 154 | fui 155 | foi 156 | fomos 157 | foram 158 | fora 159 | fôramos 160 | seja 161 | sejamos 162 | sejam 163 | fosse 164 | fôssemos 165 | fossem 166 | for 167 | formos 168 | forem 169 | serei 170 | será 171 | seremos 172 | serão 173 | seria 174 | seríamos 175 | seriam 176 | tenho 177 | tem 178 | temos 179 | tém 180 | tinha 181 | tínhamos 182 | tinham 183 | tive 184 | teve 185 | tivemos 186 | tiveram 187 | tivera 188 | tivéramos 189 | tenha 190 | tenhamos 191 | tenham 192 | tivesse 193 | tivéssemos 194 | tivessem 195 | tiver 196 | tivermos 197 | tiverem 198 | terei 199 | terá 200 | teremos 201 | terão 202 | teria 203 | teríamos 204 | teriam 205 | -------------------------------------------------------------------------------- /python/pytagcloudLocal/lang/stop/romanian: -------------------------------------------------------------------------------- 1 | a 2 | abia 3 | acea 4 | aceasta 5 | această 6 | aceea 7 | acei 8 | aceia 9 | acel 10 | acela 11 | acele 12 | acelea 13 | acest 14 | acesta 15 | aceste 16 | acestea 17 | aceşti 18 | aceştia 19 | acolo 20 | acord 21 | acum 22 | ai 23 | aia 24 | aibă 25 | aici 26 | al 27 | ăla 28 | ale 29 | alea 30 | ălea 31 | altceva 32 | altcineva 33 | am 34 | ar 35 | are 36 | aş 37 | aşadar 38 | asemenea 39 | asta 40 | ăsta 41 | astăzi 42 | astea 43 | ăstea 44 | ăştia 45 | asupra 46 | aţi 47 | au 48 | avea 49 | avem 50 | aveţi 51 | azi 52 | bine 53 | bucur 54 | bună 55 | ca 56 | că 57 | căci 58 | când 59 | care 60 | cărei 61 | căror 62 | cărui 63 | cât 64 | câte 65 | câţi 66 | către 67 | câtva 68 | caut 69 | ce 70 | cel 71 | ceva 72 | chiar 73 | cinci 74 | cînd 75 | cine 76 | cineva 77 | cît 78 | cîte 79 | cîţi 80 | cîtva 81 | contra 82 | cu 83 | cum 84 | cumva 85 | curând 86 | curînd 87 | da 88 | dă 89 | dacă 90 | dar 91 | dată 92 | datorită 93 | dau 94 | de 95 | deci 96 | deja 97 | deoarece 98 | departe 99 | deşi 100 | din 101 | dinaintea 102 | dintr- 103 | dintre 104 | doi 105 | doilea 106 | două 107 | drept 108 | după 109 | ea 110 | ei 111 | el 112 | ele 113 | eram 114 | este 115 | eşti 116 | eu 117 | face 118 | fără 119 | fata 120 | fi 121 | fie 122 | fiecare 123 | fii 124 | fim 125 | fiţi 126 | fiu 127 | frumos 128 | graţie 129 | halbă 130 | iar 131 | ieri 132 | îi 133 | îl 134 | îmi 135 | împotriva 136 | în 137 | înainte 138 | înaintea 139 | încât 140 | încît 141 | încotro 142 | între 143 | întrucât 144 | întrucît 145 | îţi 146 | la 147 | lângă 148 | le 149 | li 150 | lîngă 151 | lor 152 | lui 153 | mă 154 | mai 155 | mâine 156 | mea 157 | mei 158 | mele 159 | mereu 160 | meu 161 | mi 162 | mie 163 | mîine 164 | mine 165 | mult 166 | multă 167 | mulţi 168 | mulţumesc 169 | ne 170 | nevoie 171 | nicăieri 172 | nici 173 | nimeni 174 | nimeri 175 | nimic 176 | nişte 177 | noastră 178 | noastre 179 | noi 180 | noroc 181 | noştri 182 | nostru 183 | nouă 184 | nu 185 | opt 186 | ori 187 | oricând 188 | oricare 189 | oricât 190 | orice 191 | oricînd 192 | oricine 193 | oricît 194 | oricum 195 | oriunde 196 | până 197 | patra 198 | patru 199 | patrulea 200 | pe 201 | pentru 202 | peste 203 | pic 204 | pînă 205 | poate 206 | pot 207 | prea 208 | prima 209 | primul 210 | prin 211 | printr- 212 | puţin 213 | puţina 214 | puţină 215 | rog 216 | sa 217 | să 218 | săi 219 | sale 220 | şapte 221 | şase 222 | sau 223 | său 224 | se 225 | şi 226 | sînt 227 | sîntem 228 | sînteţi 229 | spate 230 | spre 231 | ştiu 232 | sub 233 | sunt 234 | suntem 235 | sunteţi 236 | sută 237 | ta 238 | tăi 239 | tale 240 | tău 241 | te 242 | ţi 243 | ţie 244 | timp 245 | tine 246 | toată 247 | toate 248 | tot 249 | toţi 250 | totuşi 251 | trei 252 | treia 253 | treilea 254 | tu 255 | un 256 | una 257 | unde 258 | undeva 259 | unei 260 | uneia 261 | unele 262 | uneori 263 | unii 264 | unor 265 | unora 266 | unu 267 | unui 268 | unuia 269 | unul 270 | vă 271 | vi 272 | voastră 273 | voastre 274 | voi 275 | voştri 276 | vostru 277 | vouă 278 | vreme 279 | vreo 280 | vreun 281 | zece 282 | zero 283 | zi 284 | zice 285 | -------------------------------------------------------------------------------- /python/pytagcloudLocal/lang/stop/slovak: -------------------------------------------------------------------------------- 1 | a 2 | aby 3 | aj 4 | ako 5 | aký 6 | ale 7 | alebo 8 | ani 9 | avšak 10 | ba 11 | bez 12 | buï 13 | cez 14 | èi 15 | èí 16 | èo 17 | do 18 | ho 19 | hoci 20 | i 21 | ich 22 | im 23 | ja 24 | jeho 25 | jej 26 | jemu 27 | ju 28 | k 29 | kam 30 | kde 31 | keï 32 | kedže 33 | kto 34 | ktorý 35 | ku 36 | lebo 37 | ma 38 | mi 39 | mòa 40 | mne 41 | mnou 42 | môj 43 | mu 44 | my 45 | na 46 | nad 47 | nám 48 | nami 49 | nás 50 | náš 51 | neho 52 | nej 53 | nemu 54 | nielen 55 | nich 56 | nim 57 | ním 58 | no 59 | òom 60 | òou 61 | òu 62 | o 63 | od 64 | on 65 | ona 66 | oni 67 | ono 68 | ony 69 | po 70 | pod 71 | pre 72 | pred 73 | pri 74 | s 75 | sa 76 | seba 77 | sem 78 | so 79 | svoj 80 | tá 81 | a 82 | taký 83 | tam 84 | teba 85 | tebe 86 | tebou 87 | tej 88 | ten 89 | ti 90 | tie 91 | to 92 | toho 93 | tomu 94 | tou 95 | tvoj 96 | ty 97 | tým 98 | v 99 | vám 100 | vami 101 | vás 102 | váš 103 | veï 104 | vo 105 | však 106 | vy 107 | z 108 | za 109 | zo 110 | že -------------------------------------------------------------------------------- /python/pytagcloudLocal/lang/stop/slovenian: -------------------------------------------------------------------------------- 1 | a 2 | ali 3 | april 4 | avgust 5 | b 6 | bi 7 | bil 8 | bila 9 | bile 10 | bili 11 | bilo 12 | biti 13 | blizu 14 | bo 15 | bodo 16 | bojo 17 | bolj 18 | bom 19 | bomo 20 | boste 21 | boš 22 | bova 23 | brez 24 | c 25 | cel 26 | cela 27 | celi 28 | celo 29 | č 30 | če 31 | često 32 | četrta 33 | četrtek 34 | četrti 35 | četrto 36 | čez 37 | čigav 38 | d 39 | da 40 | daleč 41 | dan 42 | danes 43 | datum 44 | december 45 | deset 46 | deseta 47 | deseti 48 | deseto 49 | devet 50 | deveta 51 | deveti 52 | deveto 53 | do 54 | dober 55 | dobra 56 | dobri 57 | dobro 58 | dokler 59 | dol 60 | dolg 61 | dolga 62 | dolgi 63 | dovolj 64 | drug 65 | druga 66 | drugi 67 | drugo 68 | dva 69 | dve 70 | e 71 | eden 72 | en 73 | ena 74 | ene 75 | eni 76 | enkrat 77 | eno 78 | etc. 79 | f 80 | februar 81 | g 82 | g. 83 | ga 84 | ga. 85 | gor 86 | gospa 87 | gospod 88 | h 89 | halo 90 | i 91 | idr. 92 | ii 93 | iii 94 | in 95 | iv 96 | ix 97 | iz 98 | j 99 | januar 100 | jaz 101 | je 102 | ji 103 | jih 104 | jim 105 | jo 106 | julij 107 | junij 108 | jutri 109 | k 110 | kadarkoli 111 | kaj 112 | kajti 113 | kako 114 | kakor 115 | kamor 116 | kamorkoli 117 | kar 118 | karkoli 119 | katerikoli 120 | kdaj 121 | kdo 122 | kdorkoli 123 | ker 124 | ki 125 | kje 126 | kjer 127 | kjerkoli 128 | ko 129 | koder 130 | koderkoli 131 | koga 132 | komu 133 | kot 134 | kratek 135 | kratka 136 | kratke 137 | kratki 138 | l 139 | lahka 140 | lahke 141 | lahki 142 | lahko 143 | le 144 | lep 145 | lepa 146 | lepe 147 | lepi 148 | lepo 149 | leto 150 | m 151 | maj 152 | majhen 153 | majhna 154 | majhni 155 | malce 156 | malo 157 | manj 158 | marec 159 | me 160 | med 161 | medtem 162 | mene 163 | mesec 164 | me 165 | mi 166 | midva 167 | midve 168 | mnogo 169 | moj 170 | moja 171 | moje 172 | mora 173 | morajo 174 | moram 175 | moramo 176 | moraš 177 | morate 178 | morem 179 | mu 180 | n 181 | na 182 | nad 183 | naj 184 | najina 185 | najino 186 | najmanj 187 | naju 188 | največ 189 | nam 190 | narobe 191 | nas 192 | naš 193 | naša 194 | naše 195 | nato 196 | nazaj 197 | ne 198 | nedavno 199 | nedelja 200 | nek 201 | neka 202 | nekaj 203 | nekatere 204 | nekateri 205 | nekatero 206 | nekdo 207 | neke 208 | nekega 209 | neki 210 | nekje 211 | neko 212 | nekoč 213 | nekoga 214 | ni 215 | nič 216 | nikamor 217 | nikdar 218 | nikjer 219 | nikoli 220 | nje 221 | njega 222 | njegov 223 | njegova 224 | njegovo 225 | njej 226 | njemu 227 | njen 228 | njena 229 | njeno 230 | nji 231 | njih 232 | njihov 233 | njihova 234 | njihovo 235 | njiju 236 | njim 237 | njo 238 | njo 239 | njun 240 | njuna 241 | njuno 242 | no 243 | nocoj 244 | november 245 | npr. 246 | o 247 | ob 248 | oba 249 | obe 250 | oboje 251 | od 252 | odprt 253 | odprta 254 | odprti 255 | okoli 256 | oktober 257 | on 258 | onadva 259 | one 260 | oni 261 | onidve 262 | osem 263 | osma 264 | osmi 265 | osmo 266 | oz. 267 | p 268 | pa 269 | pet 270 | peta 271 | petek 272 | peti 273 | peto 274 | po 275 | pod 276 | pogosto 277 | poleg 278 | poln 279 | polna 280 | polni 281 | polno 282 | ponavadi 283 | ponedeljek 284 | ponovno 285 | potem 286 | povsod 287 | pozdravljen 288 | pozdravljeni 289 | prav 290 | prava 291 | prave 292 | pravi 293 | pravo 294 | prazen 295 | prazna 296 | prazno 297 | prbl. 298 | pribl. 299 | precej 300 | pred 301 | prej 302 | preko 303 | pri 304 | približno 305 | primer 306 | pripravljen 307 | pripravljena 308 | pripravljeni 309 | proti 310 | prva 311 | prvi 312 | prvo 313 | r 314 | ravno 315 | reč 316 | redko 317 | res 318 | s 319 | saj 320 | sam 321 | sama 322 | same 323 | sami 324 | samo 325 | se 326 | sebe 327 | sebi 328 | sedaj 329 | sedem 330 | sedma 331 | sedmi 332 | sedmo 333 | sem 334 | september 335 | seveda 336 | si 337 | sicer 338 | skoraj 339 | skozi 340 | slab 341 | smo 342 | so 343 | sobota 344 | spet 345 | sreda 346 | srednja 347 | srednji 348 | sta 349 | ste 350 | stran 351 | stvar 352 | sva 353 | š 354 | šest 355 | šesta 356 | šesti 357 | šesto 358 | štiri 359 | t 360 | ta 361 | tak 362 | taka 363 | take 364 | taki 365 | tako 366 | takoj 367 | tam 368 | te 369 | tebe 370 | tebi 371 | tega 372 | težak 373 | težka 374 | težki 375 | težko 376 | ti 377 | tista 378 | tiste 379 | tisti 380 | tisto 381 | tj. 382 | tja 383 | to 384 | toda 385 | torek 386 | tretja 387 | tretje 388 | tretji 389 | tri 390 | tu 391 | tudi 392 | tukaj 393 | tvoj 394 | tvoja 395 | tvoje 396 | u 397 | v 398 | vaju 399 | vam 400 | vas 401 | vaš 402 | vaša 403 | vaše 404 | včasih 405 | včeraj 406 | ve 407 | več 408 | vedno 409 | velik 410 | velika 411 | veliki 412 | veliko 413 | vendar 414 | ves 415 | vi 416 | vidva 417 | vii 418 | viii 419 | visok 420 | visoka 421 | visoke 422 | visoki 423 | vsa 424 | vsaj 425 | vsak 426 | vsake 427 | vsaka 428 | vsakdo 429 | vsaki 430 | vsakomur 431 | vse 432 | vsega 433 | vsi 434 | vso 435 | x 436 | z 437 | za 438 | zadaj 439 | zadnji 440 | zakaj 441 | zaprta 442 | zaprti 443 | zaprto 444 | zdaj 445 | zelo 446 | zunaj 447 | ž 448 | že 449 | -------------------------------------------------------------------------------- /python/pytagcloudLocal/lang/stop/spanish: -------------------------------------------------------------------------------- 1 | de 2 | la 3 | que 4 | el 5 | en 6 | y 7 | a 8 | los 9 | del 10 | se 11 | las 12 | por 13 | un 14 | para 15 | con 16 | no 17 | una 18 | su 19 | al 20 | lo 21 | como 22 | más 23 | pero 24 | sus 25 | le 26 | ya 27 | o 28 | este 29 | sí 30 | porque 31 | esta 32 | entre 33 | cuando 34 | muy 35 | sin 36 | sobre 37 | también 38 | me 39 | hasta 40 | hay 41 | donde 42 | quien 43 | desde 44 | todo 45 | nos 46 | durante 47 | todos 48 | uno 49 | les 50 | ni 51 | contra 52 | otros 53 | ese 54 | eso 55 | ante 56 | ellos 57 | e 58 | esto 59 | mí 60 | antes 61 | algunos 62 | qué 63 | unos 64 | yo 65 | otro 66 | otras 67 | otra 68 | él 69 | tanto 70 | esa 71 | estos 72 | mucho 73 | quienes 74 | nada 75 | muchos 76 | cual 77 | poco 78 | ella 79 | estar 80 | estas 81 | algunas 82 | algo 83 | nosotros 84 | mi 85 | mis 86 | tú 87 | te 88 | ti 89 | tu 90 | tus 91 | ellas 92 | nosotras 93 | vosotros 94 | vosotras 95 | os 96 | mío 97 | mía 98 | míos 99 | mías 100 | tuyo 101 | tuya 102 | tuyos 103 | tuyas 104 | suyo 105 | suya 106 | suyos 107 | suyas 108 | nuestro 109 | nuestra 110 | nuestros 111 | nuestras 112 | vuestro 113 | vuestra 114 | vuestros 115 | vuestras 116 | esos 117 | esas 118 | estoy 119 | estás 120 | está 121 | estamos 122 | estáis 123 | están 124 | esté 125 | estés 126 | estemos 127 | estéis 128 | estén 129 | estaré 130 | estarás 131 | estará 132 | estaremos 133 | estaréis 134 | estarán 135 | estaría 136 | estarías 137 | estaríamos 138 | estaríais 139 | estarían 140 | estaba 141 | estabas 142 | estábamos 143 | estabais 144 | estaban 145 | estuve 146 | estuviste 147 | estuvo 148 | estuvimos 149 | estuvisteis 150 | estuvieron 151 | estuviera 152 | estuvieras 153 | estuviéramos 154 | estuvierais 155 | estuvieran 156 | estuviese 157 | estuvieses 158 | estuviésemos 159 | estuvieseis 160 | estuviesen 161 | estando 162 | estado 163 | estada 164 | estados 165 | estadas 166 | estad 167 | he 168 | has 169 | ha 170 | hemos 171 | habéis 172 | han 173 | haya 174 | hayas 175 | hayamos 176 | hayáis 177 | hayan 178 | habré 179 | habrás 180 | habrá 181 | habremos 182 | habréis 183 | habrán 184 | habría 185 | habrías 186 | habríamos 187 | habríais 188 | habrían 189 | había 190 | habías 191 | habíamos 192 | habíais 193 | habían 194 | hube 195 | hubiste 196 | hubo 197 | hubimos 198 | hubisteis 199 | hubieron 200 | hubiera 201 | hubieras 202 | hubiéramos 203 | hubierais 204 | hubieran 205 | hubiese 206 | hubieses 207 | hubiésemos 208 | hubieseis 209 | hubiesen 210 | habiendo 211 | habido 212 | habida 213 | habidos 214 | habidas 215 | soy 216 | eres 217 | es 218 | somos 219 | sois 220 | son 221 | sea 222 | seas 223 | seamos 224 | seáis 225 | sean 226 | seré 227 | serás 228 | será 229 | seremos 230 | seréis 231 | serán 232 | sería 233 | serías 234 | seríamos 235 | seríais 236 | serían 237 | era 238 | eras 239 | éramos 240 | erais 241 | eran 242 | fui 243 | fuiste 244 | fue 245 | fuimos 246 | fuisteis 247 | fueron 248 | fuera 249 | fueras 250 | fuéramos 251 | fuerais 252 | fueran 253 | fuese 254 | fueses 255 | fuésemos 256 | fueseis 257 | fuesen 258 | siendo 259 | sido 260 | tengo 261 | tienes 262 | tiene 263 | tenemos 264 | tenéis 265 | tienen 266 | tenga 267 | tengas 268 | tengamos 269 | tengáis 270 | tengan 271 | tendré 272 | tendrás 273 | tendrá 274 | tendremos 275 | tendréis 276 | tendrán 277 | tendría 278 | tendrías 279 | tendríamos 280 | tendríais 281 | tendrían 282 | tenía 283 | tenías 284 | teníamos 285 | teníais 286 | tenían 287 | tuve 288 | tuviste 289 | tuvo 290 | tuvimos 291 | tuvisteis 292 | tuvieron 293 | tuviera 294 | tuvieras 295 | tuviéramos 296 | tuvierais 297 | tuvieran 298 | tuviese 299 | tuvieses 300 | tuviésemos 301 | tuvieseis 302 | tuviesen 303 | teniendo 304 | tenido 305 | tenida 306 | tenidos 307 | tenidas 308 | tened 309 | -------------------------------------------------------------------------------- /python/pytagcloudLocal/lang/stop/swedish: -------------------------------------------------------------------------------- 1 | och 2 | det 3 | att 4 | i 5 | en 6 | jag 7 | hon 8 | som 9 | han 10 | på 11 | den 12 | med 13 | var 14 | sig 15 | för 16 | så 17 | till 18 | är 19 | men 20 | ett 21 | om 22 | hade 23 | de 24 | av 25 | icke 26 | mig 27 | du 28 | henne 29 | då 30 | sin 31 | nu 32 | har 33 | inte 34 | hans 35 | honom 36 | skulle 37 | hennes 38 | där 39 | min 40 | man 41 | ej 42 | vid 43 | kunde 44 | något 45 | från 46 | ut 47 | när 48 | efter 49 | upp 50 | vi 51 | dem 52 | vara 53 | vad 54 | över 55 | än 56 | dig 57 | kan 58 | sina 59 | här 60 | ha 61 | mot 62 | alla 63 | under 64 | någon 65 | eller 66 | allt 67 | mycket 68 | sedan 69 | ju 70 | denna 71 | själv 72 | detta 73 | åt 74 | utan 75 | varit 76 | hur 77 | ingen 78 | mitt 79 | ni 80 | bli 81 | blev 82 | oss 83 | din 84 | dessa 85 | några 86 | deras 87 | blir 88 | mina 89 | samma 90 | vilken 91 | er 92 | sådan 93 | vår 94 | blivit 95 | dess 96 | inom 97 | mellan 98 | sådant 99 | varför 100 | varje 101 | vilka 102 | ditt 103 | vem 104 | vilket 105 | sitta 106 | sådana 107 | vart 108 | dina 109 | vars 110 | vårt 111 | våra 112 | ert 113 | era 114 | vilkas 115 | -------------------------------------------------------------------------------- /python/pytagcloudLocal/lang/stop/turkish: -------------------------------------------------------------------------------- 1 | altmış 2 | altı 3 | ama 4 | bana 5 | bazı 6 | belki 7 | ben 8 | benden 9 | beni 10 | benim 11 | beþ 12 | bi 13 | bin 14 | bir 15 | biri 16 | birkaç 17 | birkez 18 | birşey 19 | birşeyi 20 | biz 21 | bizden 22 | bizi 23 | bizim 24 | bu 25 | buna 26 | bunda 27 | bundan 28 | bunu 29 | bunun 30 | da 31 | daha 32 | dahi 33 | de 34 | defa 35 | diye 36 | diğer 37 | doksan 38 | dokuz 39 | dört 40 | elli 41 | en gibi 42 | gibi 43 | hem 44 | hep 45 | hepsi 46 | her 47 | hiç 48 | iki 49 | ile 50 | ise 51 | için 52 | katrilyon 53 | kez 54 | ki 55 | kim 56 | kimden 57 | kime 58 | kimi 59 | kırk 60 | mi 61 | milyar 62 | milyon 63 | mu 64 | mü 65 | mı 66 | nasıl 67 | ne 68 | neden 69 | nerde 70 | nerede 71 | nereye 72 | niye 73 | niçin 74 | o 75 | on 76 | ona 77 | ondan 78 | onlar 79 | onlardan 80 | onlari 81 | onların 82 | onu 83 | otuz 84 | sanki 85 | sekiz 86 | seksen 87 | sen 88 | senden 89 | seni 90 | senin 91 | siz 92 | sizden 93 | sizi 94 | sizin 95 | trilyon 96 | tüm 97 | ve 98 | veya 99 | ya 100 | yani 101 | yedi 102 | yetmiş 103 | yirmi 104 | yüz 105 | çok 106 | çünkü 107 | üç 108 | şey 109 | şeyden 110 | şeyi 111 | şeyler 112 | şu 113 | şuna 114 | şunda 115 | şundan 116 | şunu 117 | acaba 118 | -------------------------------------------------------------------------------- /python/pytagcloudLocal/lang/stopwords.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | import os 3 | 4 | ACTIVE_LISTS = ('german', 'french', 'italian', 'english', 'spanish') 5 | 6 | class StopWords(object): 7 | 8 | def __init__(self): 9 | 10 | self.stop_words_lists = {} 11 | self.language = None 12 | 13 | stop_dir = os.path.join(os.path.dirname(os.path.abspath(__file__)), 'stop') 14 | 15 | for root, dirs, files in os.walk(stop_dir): 16 | for file in files: 17 | if not file in ACTIVE_LISTS: 18 | continue 19 | stop_file = open(os.path.join(os.path.dirname(os.path.abspath(__file__)), 'stop/', file), 'r') 20 | self.stop_words_lists[file] = [] 21 | for stop_word in stop_file: 22 | self.stop_words_lists[file].append(stop_word.strip().lower()) 23 | stop_file.close() 24 | 25 | def load_language(self, language): 26 | self.language = language 27 | 28 | def is_stop_word(self, word): 29 | if not self.language: 30 | raise LookupError("No language loaded") 31 | return word in self.stop_words_lists[self.language] 32 | 33 | def guess(self, words): 34 | currentWinner = ACTIVE_LISTS[0]; 35 | currentMax = 0; 36 | 37 | for language, stop_word_list in self.stop_words_lists.items(): 38 | count = 0 39 | for word in words: 40 | if word in stop_word_list: 41 | count += 1 42 | 43 | if count > currentMax: 44 | currentWinner = language 45 | currentMax = count 46 | 47 | return currentWinner 48 | 49 | -------------------------------------------------------------------------------- /python/rgbd: -------------------------------------------------------------------------------- 1 | ../../vpCluster/rgbd -------------------------------------------------------------------------------- /src/cat.cpp: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2015, Julian Straub 2 | * Licensed under the MIT license. See the license file LICENSE. 3 | */ 4 | 5 | #include 6 | 7 | // --------------------------------------------------------------------------- 8 | 9 | template 10 | Cat::Cat(const Matrix& pdf, boost::mt19937 *pRndGen) 11 | : Distribution(pRndGen), K_(pdf.size()), pdf_(pdf) 12 | { 13 | updateCdf(); 14 | }; 15 | 16 | template 17 | Cat::Cat(const VectorXu& z, boost::mt19937 *pRndGen) 18 | : Distribution(pRndGen), K_(z.maxCoeff()+1) 19 | { 20 | pdf_ = counts(z,K_); 21 | pdf_ /= pdf_.sum(); 22 | 23 | updateCdf(); 24 | }; 25 | 26 | template 27 | Cat::Cat(const Cat& other) 28 | : Distribution(other.pRndGen_), K_(other.K_), pdf_(other.pdf_), 29 | cdf_(other.cdf_) 30 | {}; 31 | 32 | template 33 | Cat::~Cat() 34 | {}; 35 | 36 | template 37 | uint32_t Cat::sample() 38 | { 39 | T r=unif_(*this->pRndGen_); 40 | //cout< "< 47 | void Cat::sample(VectorXu& z) 48 | { 49 | for(uint32_t i=0; isample(); 51 | }; 52 | 53 | template 54 | void Cat::updateCdf() 55 | { 56 | cdf_.setZero(pdf_.size()+1); 57 | for (uint32_t k=0; k 62 | void Cat::print() const 63 | { 64 | cout<<"pi="<; 68 | template class Cat; 69 | -------------------------------------------------------------------------------- /src/generateSphericalData.cpp: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2015, Julian Straub 2 | * Licensed under the MIT license. See the license file LICENSE. 3 | */ 4 | 5 | #include 6 | #include 7 | #include 8 | 9 | #include 10 | 11 | #include 12 | 13 | using namespace Eigen; 14 | using std::string; 15 | 16 | namespace po = boost::program_options; 17 | 18 | int main(int argc, char** argv) 19 | { 20 | // Declare the supported options. 21 | po::options_description desc("Allowed options"); 22 | desc.add_options() 23 | ("help,h", "produce help message") 24 | ("seed", po::value(), "seed for random number generator") 25 | ("N,N", po::value(), "number of input datapoints") 26 | ("D,D", po::value(), "number of dimensions of the data") 27 | ("K,K", po::value(), "number of initial clusters ") 28 | ("nu,nu", po::value(), "nu parameter of IW from which " 29 | "sigmas are sampled") 30 | ("minAngle,a", po::value(), "min angle between means on sphere") 31 | ("delta,d", po::value(), "delta of NIW") 32 | ("output,o", po::value(), 33 | "path to output labels and data .csv file (rows: time; cols: different " 34 | "datapoints)") 35 | ; 36 | 37 | po::variables_map vm; 38 | po::store(po::parse_command_line(argc, argv, desc), vm); 39 | po::notify(vm); 40 | 41 | if (vm.count("help")) { 42 | cout << desc << "\n"; 43 | return 1; 44 | } 45 | 46 | uint64_t seed = time(0); 47 | if(vm.count("seed")) 48 | seed = static_cast(vm["seed"].as()); 49 | boost::mt19937 rndGen(seed); 50 | uint32_t K=5; 51 | if (vm.count("K")) K = vm["K"].as(); 52 | uint32_t N=100; 53 | if (vm.count("N")) N = vm["N"].as(); 54 | uint32_t D=3; 55 | if (vm.count("D")) D = vm["D"].as(); 56 | string pathOut ="./rndSphereData"; 57 | if(vm.count("output")) 58 | pathOut = vm["output"].as(); 59 | cout<<"output to "<(D)+2.; // 100 for spherical 62 | if (vm.count("nu")) nu = vm["nu"].as(); 63 | if(nu < static_cast(D)+1.+1e-8) 64 | nu = static_cast(D)+1.+1e-8; 65 | double minAngle = 6.; 66 | if (vm.count("minAngle")) minAngle = vm["minAngle"].as(); 67 | double delta = 6.; 68 | if (vm.count("delta")) delta = vm["delta"].as(); 69 | 70 | MatrixXd Delta(D-1,D-1); 71 | Delta = MatrixXd::Identity(D-1,D-1); 72 | Delta *= nu*(delta*PI/180.)*(delta*PI/180.); 73 | 74 | // double nu = D+0.1 75 | // MatrixXd Delta(D,D); 76 | // Delta.setIdentity(); 77 | // Delta *= nu * (12.*PI)/180.0; 78 | MatrixXd x(D,N); 79 | VectorXu z(N); 80 | sampleClustersOnSphere(Delta,nu,x,z,K,minAngle); 81 | for(uint32_t i=0; i 1e-2) 83 | { 84 | cout<<"@"< 2 | * Licensed under the MIT license. See the license file LICENSE. 3 | */ 4 | #include 5 | 6 | // --------------------------------------------------------------------------- 7 | 8 | template 9 | Mult::Mult(const Matrix& pdf, boost::mt19937 *pRndGen) 10 | : Distribution(pRndGen), K_(pdf.size()), pdf_(pdf) 11 | { 12 | }; 13 | 14 | template 15 | Mult::Mult(const VectorXu& z, boost::mt19937 *pRndGen) 16 | : Distribution(pRndGen), K_(z.maxCoeff()+1) 17 | { 18 | pdf_ = counts(z,K_); 19 | pdf_ /= pdf_.sum(); 20 | }; 21 | 22 | template 23 | Mult::Mult(const Mult& other) 24 | : Distribution(other.pRndGen_), K_(other.K_), pdf_(other.pdf_) 25 | {}; 26 | 27 | template 28 | Mult::~Mult() 29 | {}; 30 | 31 | template 32 | T Mult::logPdf(const Matrix& x) const 33 | { 34 | // log(Gamma(n+1)) = n! 35 | T logPdf = lgamma(x.sum()+1); 36 | for(uint32_t k=0; k 44 | uint32_t Mult::sample() 45 | { 46 | assert(false);// TODO 47 | // T r=unif_(*this->pRndGen_); 48 | //cout< "< 55 | void Mult::sample(VectorXu& z) 56 | { 57 | assert(false);// TODO 58 | for(uint32_t i=0; isample(); 60 | }; 61 | 62 | template 63 | void Mult::print() const 64 | { 65 | cout<<"pi="<; 69 | template class Mult; 70 | -------------------------------------------------------------------------------- /test/mf.cpp: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2015, Julian Straub 2 | * Licensed under the MIT license. See the license file LICENSE. 3 | */ 4 | 5 | #include 6 | #define BOOST_TEST_DYN_LINK 7 | #define BOOST_TEST_MODULE mf test 8 | #include 9 | 10 | #include 11 | #include 12 | 13 | BOOST_AUTO_TEST_CASE(mf_test) 14 | { 15 | boost::mt19937 rndGen(1); 16 | double nu = 4; 17 | MatrixXd Delta = MatrixXd::Identity(2,2); 18 | Delta *= pow(5.0*M_PI/180.,2)*nu; 19 | IW iw0(Delta,nu,&rndGen); 20 | std::vector > >thetas; 21 | for(uint32_t k=0; k<6; ++k) 22 | thetas.push_back(shared_ptr >( 23 | new IwTangent(iw0,&rndGen))); 24 | VectorXd alpha = VectorXd::Ones(6); 25 | Dir, double> dir(alpha,&rndGen); 26 | DirMM dirMM(dir,thetas); 27 | MfPrior mfPrior(dirMM,10); 28 | 29 | MatrixXd Sigma = MatrixXd::Identity(2,2); 30 | Sigma *= pow(1.0*M_PI/180.,2); 31 | uint32_t N = 100; 32 | MatrixXd x(3,N*6); 33 | MatrixXd R(3,3); 34 | double theta = 30.*M_PI/180.; 35 | R< g(R*mfPrior.M().col(k),Sigma,&rndGen); 43 | for(uint32_t i =0; i< N; ++i) 44 | x.col(i+N*k) = g.sample(); 45 | } 46 | VectorXu z = VectorXu::Zero(N*6); 47 | MF mf = mfPrior.posteriorSample(x,z,0); 48 | 49 | mf.print(); 50 | 51 | for(uint32_t i =0; i< N*6; i+=N) 52 | { 53 | cout< mf2(mf); 56 | mf2.print(); 57 | }; 58 | -------------------------------------------------------------------------------- /test/naiveBayes.cpp: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2015, Julian Straub , Randi Cabezas 2 | * Licensed under the MIT license. See the license file LICENSE. 3 | */ 4 | 5 | #include 6 | 7 | #include 8 | 9 | #include 10 | #include 11 | #include 12 | #include 13 | 14 | namespace po = boost::program_options; 15 | 16 | int main(int argc, char **argv){ 17 | 18 | 19 | // Declare the supported options. 20 | po::options_description desc("Allowed options"); 21 | desc.add_options() 22 | ("help,h", "produce help message") 23 | ("K,K", po::value(), "number of initial clusters ") 24 | ("T,T", po::value(), "iterations") 25 | ("v,v", po::value(), "verbose output") 26 | ("input,i", po::value(), 27 | "path to input dataset .csv file (rows: dimensions; cols: different " 28 | "datapoints)") 29 | ("output,o", po::value(), 30 | "path to output labels .csv file (rows: time; cols: different " 31 | "datapoints)") 32 | ; 33 | 34 | po::variables_map vm; 35 | po::store(po::parse_command_line(argc, argv, desc), vm); 36 | po::notify(vm); 37 | 38 | if (vm.count("help")) { 39 | cout << desc << "\n"; 40 | return 1; 41 | } 42 | 43 | uint K=2; 44 | uint T=100; 45 | uint N=100; 46 | uint D=2; 47 | uint M=2; 48 | uint NumObs = 1; 49 | bool verbose = false; 50 | vector Mword; 51 | if (vm.count("K")) 52 | K = vm["K"].as(); 53 | if (vm.count("T")) 54 | T = vm["T"].as(); 55 | if (vm.count("v")) 56 | verbose = vm["v"].as(); 57 | 58 | string pathIn =""; 59 | string pathOut =""; 60 | if(vm.count("input")) 61 | pathIn = vm["input"].as(); 62 | if(vm.count("output")) 63 | pathOut= vm["output"].as(); 64 | 65 | vector< Matrix > x; 66 | x.reserve(N); 67 | if (!pathIn.compare("")) 68 | { 69 | cout<<"making some data up " <>NumObs; 90 | fin>>N; 91 | fin>>M; 92 | fin>>D; 93 | 94 | MatrixXd data(D,N); 95 | VectorXu words(M); 96 | 97 | for (uint j=0; j>words(j); 99 | 100 | for (uint j=1; j<(D+1); ++j) 101 | for (uint i=0; i>data(j-1,i); 103 | 104 | uint count = 0; 105 | for (uint j=0; j niw(Delta,theta,nu,kappa,&rndGen); 123 | 124 | Dir dir(alpha,&rndGen); 125 | 126 | 127 | //cout<<"------ marginalized ---- NIW "< naive_marg(dir,niwMargBase); 129 | //naive_marg.initialize(x); 130 | //cout< >) x ); 151 | naive_samp.inferAll(T,verbose); 152 | 153 | 154 | if (pathOut.compare("")) 155 | { 156 | std::ofstream fout(pathOut.data(),std::ofstream::out); 157 | 158 | std::streambuf *coutbuf = std::cout.rdbuf(); //save old cout buffer 159 | cout.rdbuf(fout.rdbuf()); //redirect std::cout to fout1 buffer 160 | 161 | naive_samp.dump(fout,fout); 162 | 163 | std::cout.rdbuf(coutbuf); //reset to standard output again 164 | 165 | fout.close(); 166 | } 167 | 168 | tlocal.displayElapsedTimeAuto(); 169 | return(0); 170 | 171 | }; 172 | -------------------------------------------------------------------------------- /test/sampler.cpp: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2015, Julian Straub 2 | * Licensed under the MIT license. See the license file LICENSE. 3 | */ 4 | 5 | #include 6 | #define BOOST_TEST_DYN_LINK 7 | #define BOOST_TEST_MODULE sampler test 8 | #include 9 | 10 | #include 11 | #include 12 | #include 13 | 14 | using namespace Eigen; 15 | 16 | using std::cout; 17 | using std::endl; 18 | 19 | #define N 640*480 20 | #define M 10 21 | 22 | BOOST_AUTO_TEST_CASE( sampler_cpu_test) 23 | { 24 | cout<<"----------------- sampler CPU float (N="< s; 26 | //cout<=.0).all()); 33 | 34 | MatrixXf pdfs(4,3); 35 | pdfs << 0.5,0.5,0.0, 36 | 0.25,0.25,0.5, 37 | 0.33,0.33,0.34, 38 | 0.9,0.05,0.05; 39 | cout<=0).all()); 55 | 56 | cout<(z,M).transpose()< s; 63 | //cout<=.0).all()); 70 | 71 | MatrixXd pdfs(4,3); 72 | pdfs << 0.5,0.5,0.0, 73 | 0.25,0.25,0.5, 74 | 0.33,0.33,0.34, 75 | 0.9,0.05,0.05; 76 | cout<=0).all()); 86 | 87 | cout<(z,M).transpose()< s(N,M); 95 | //cout<=.0f).all()); 102 | 103 | MatrixXf pdfs(N,M); 104 | pdfs.setOnes(N,M); 105 | pdfs *= 1.0/M; 106 | 107 | //cout<=0).all()); 114 | 115 | cout<(z,M).transpose()<(z,M).transpose()< s(N,M); 131 | //cout<=.0f).all()); 138 | 139 | MatrixXd pdfs(N,M); 140 | pdfs.setOnes(N,M); 141 | pdfs *= 1.0/M; 142 | 143 | //cout<=0).all()); 150 | 151 | cout<(z,M).transpose()<(z,M).transpose()<