(CategoricalData[] catInfo, int dim, DataWriter.DataSetType type, OutputStream out)
| 371 | return new DataWriter(out, catInfo, dim, type) |
| 372 | { |
| 373 | @Override |
| 374 | protected void writeHeader(CategoricalData[] catInfo, int dim, DataWriter.DataSetType type, OutputStream out) throws IOException |
| 375 | { |
| 376 | DataOutputStream data_out = new DataOutputStream(out); |
| 377 | |
| 378 | data_out.write(JSATData.MAGIC_NUMBER); |
| 379 | |
| 380 | int numNumeric = dim; |
| 381 | int numCat = catInfo.length; |
| 382 | |
| 383 | DatasetTypeMarker marker = DatasetTypeMarker.STANDARD; |
| 384 | if(type == type.REGRESSION) |
| 385 | { |
| 386 | numNumeric++; |
| 387 | marker = DatasetTypeMarker.REGRESSION; |
| 388 | } |
| 389 | if(type == type.CLASSIFICATION) |
| 390 | { |
| 391 | numCat++; |
| 392 | marker = DatasetTypeMarker.CLASSIFICATION; |
| 393 | } |
| 394 | |
| 395 | data_out.writeByte(marker.ordinal()); |
| 396 | data_out.writeByte(fpStore.ordinal()); |
| 397 | data_out.writeInt(numNumeric); |
| 398 | data_out.writeInt(numCat); |
| 399 | data_out.writeInt(-1);//-1 used to indicate a potentially variable number of files |
| 400 | |
| 401 | for(CategoricalData category : catInfo) |
| 402 | { |
| 403 | //first, whats the name of the i'th category |
| 404 | writeString(category.getCategoryName(), data_out); |
| 405 | |
| 406 | data_out.writeInt(category.getNumOfCategories());//output the number of categories |
| 407 | for(int i = 0; i < category.getNumOfCategories(); i++)//the option names |
| 408 | writeString(category.getOptionName(i), data_out); |
| 409 | } |
| 410 | //extra for classification dataset |
| 411 | if(type == DataWriter.DataSetType.CLASSIFICATION) |
| 412 | { |
| 413 | CategoricalData category = predicting; |
| 414 | //first, whats the name of the i'th category |
| 415 | writeString(category.getCategoryName(), data_out); |
| 416 | |
| 417 | data_out.writeInt(category.getNumOfCategories());//output the number of categories |
| 418 | for(int i = 0; i < category.getNumOfCategories(); i++)//the option names |
| 419 | writeString(category.getOptionName(i), data_out); |
| 420 | } |
| 421 | data_out.flush(); |
| 422 | } |
| 423 | |
| 424 | @Override |
| 425 | protected void pointToBytes(DataPoint dp, double label, ByteArrayOutputStream byteOut) |
nothing calls this directly
no test coverage detected