ftcc 1.0.0
See the version list below for details.
dotnet add package ftcc --version 1.0.0
NuGet\Install-Package ftcc -Version 1.0.0
<PackageReference Include="ftcc" Version="1.0.0" />
paket add ftcc --version 1.0.0
#r "nuget: ftcc, 1.0.0"
// Install ftcc as a Cake Addin #addin nuget:?package=ftcc&version=1.0.0 // Install ftcc as a Cake Tool #tool nuget:?package=ftcc&version=1.0.0
FTCC C#
FTCC: Fast Text Classification with Compressors dictionary.
This project is a C# implementation of the FTCC project for text classification.
The main advantage of this type of classification is that it uses ZSTD compression, which allows for compression using dictionaries that have been generated beforehand, thereby achieving significant speed improvements when classifying a text.
Performance
All tests have been done at a compression level of 3, which is the default compression level.
Compressors per class represents the number of compressors used in each class, or in other words, the number of dictionaries for each class.
Compressors per class | AGNews | DBpedia | YahooAnswers | R8 | R52 | Ohsumed | Kinnews |
---|---|---|---|---|---|---|---|
CPC 1 | 0.837 | 0.892 | 0.417 | 0.908 | 0.818 | 0.426 | 0.754 |
CPC 3 | 0.876 | 0.918 | 0.517 | 0.912 | 0.803 | 0.374 | 0.766 |
CPC 5 | 0.881 | 0.925 | 0.551 | 0.896 | 0.776 | 0.370 | 0.756 |
Usage
Predict csv test file:
string trainFile = @"C:\Users\Chus\Downloads\ag_news_train.csv";
string testFile = @"C:\Users\Chus\Downloads\ag_news_test.csv";
FTCCOptions fTCCOptions = new()
{
DictionariesPath = dictionariesPath, // File path for preloaded dictionaries (ignores training file). Default: null;
TrainFile = trainFile, // File path for csv train file
ParallelismToInitialize = false, // Use paralelism to initialize dictionaries. Default: false (if true, diccionaries will be a bit different for each execution)
ParallelismOnTestFile = true, // Use paralelism for each test. Default: false
CompressionLevel = 3, // Compression level for dictionaries. Default: 3
CompressorsPerClass = 3, // Number of compressors per class. Default: 3
TextColumn = 0, // Text column number in csv file. Default: 0
LabelColumn = 1, // Label column number in csv file. Default: 1
HasHeaderRecord = true, // Csv has header record. Deault: true
ConsoleOutput = true, // Output console during file prediction. Default: true
};
FTCC fTCC = new(fTCCOptions);
double result = fTCC.PredictFile(testFile);
Console.WriteLine(result);
Single text prediction:
string text = "Socialites unite dolphin groups Dolphin groups, or \"pods\", rely on socialites to keep them from collapsing, scientists claim.";
var prediction = fTCC.Predict(text);
Console.WriteLine(prediction);
Dictionary serialisation:
Serializing the dictionaries allows for preloading the FTCC objects later on, so that it doesn't need to create the dictionaries, but instead reads them from file. This way, it allows for immediate text classification.
string dictionariesPath = @"C:\Users\Chus\Downloads\dictionaries.ftcc";
fTCC.SerializeDiccionaries(dictionariesPath);
To create the FTCC object with the serialized dictionaries:
FTCCOptions fTCCOptions = new()
{
DictionariesPath = dictionariesPath
};
FTCC fTCC = new(fTCCOptions);
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net6.0 is compatible. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 was computed. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. |
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.