public void writeModel(String filename) {
    if (trained == false || model == null || featureConfig == null) {
      System.err.println("train or load trained model first.");
      System.exit(0);
    }
    try {
      FileOutputStream fos = new FileOutputStream(new File(filename
          + ".gz"));
      GZIPOutputStream gout = new GZIPOutputStream(fos);
      ObjectOutputStream oos = new ObjectOutputStream(gout);
      oos.writeObject(new FeatureSubsetModel(model, featureConfig));
      oos.close();
    } catch (Exception e) {
      e.printStackTrace();
      System.exit(0);
    }
  }