code: @Override
      protected void _fit(Dataframe trainingData) {
          AbstractModelParameters modelParameters = knowledgeBase.getModelParameters();
  
          modelParameters.setD(trainingData.xColumnSize());
          Set<Object> goldStandardClasses = modelParameters.getGoldStandardClasses();
          Map<Object, Integer> featureIds = modelParameters.getFeatureIds();
          
          //check if there are any gold standard classes and buld the featureIds maps
          int previousFeatureId = 0;
          for(Record r : trainingData) { 
              Object theClass=r.getY();
              if(theClass!=null) {
                  goldStandardClasses.add(theClass); 
              }
              
              for(Map.Entry<Object, Object> entry : r.getX().entrySet()) {
                  Object feature = entry.getKey();
                  if(featureIds.putIfAbsent(feature, previousFeatureId) == null) {
                      previousFeatureId++;
                  }
              }
          }
          
          //perform Gibbs Sampling and calculate the clusters
          int totalIterations = collapsedGibbsSampling(trainingData);
          
          //set the actual iterations performed
          modelParameters.setTotalIterations(totalIterations);
          
          clearClusters();
      }
docs: {@inheritDoc}