com.datumbox.framework.applications.nlp
Class TextClassifier
- java.lang.Object
-
- com.datumbox.framework.core.machinelearning.common.abstracts.AbstractTrainer<MP,TP>
-
- com.datumbox.framework.core.machinelearning.common.abstracts.modelers.AbstractModeler<Modeler.ModelParameters,Modeler.TrainingParameters>
-
- com.datumbox.framework.applications.datamodeling.Modeler
-
- com.datumbox.framework.applications.nlp.TextClassifier
-
- All Implemented Interfaces:
- Savable, Parallelizable, Trainable<Modeler.ModelParameters,Modeler.TrainingParameters>, java.lang.AutoCloseable
public class TextClassifier extends Modeler
TextClassifier is a convenience class which can be used to train Text ClassificationMetrics models. It is a wrapper class which automatically takes care of the text parsing, tokenization, feature selection and modeler training processes. It takes as input either a Dataframe object or multiple text files (one for each category) with one observation per row.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class and Description static classTextClassifier.ModelParametersIt contains all the Model AbstractParameters which are learned during the training.static classTextClassifier.TrainingParametersIt contains the Training AbstractParameters of the Text Classifier.-
Nested classes/interfaces inherited from class com.datumbox.framework.core.machinelearning.common.abstracts.AbstractTrainer
AbstractTrainer.AbstractModelParameters, AbstractTrainer.AbstractTrainingParameters
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method and Description voidfit(java.util.Map<java.lang.Object,java.net.URI> datasets)Trains a Machine Learning modeler using the provided dataset files.Recordpredict(java.lang.String text)It generates a prediction for a particular string.Dataframepredict(java.net.URI datasetURI)Generates a Dataframe with the predictions for the provided data file.ClassificationMetricsvalidate(Dataframe testDataset)It validates the modeler using the provided dataset and it returns the ClassificationMetrics.ClassificationMetricsvalidate(java.util.Map<java.lang.Object,java.net.URI> datasets)It validates the modeler using the provided dataset files.-
Methods inherited from class com.datumbox.framework.applications.datamodeling.Modeler
_predict, close, delete, isParallelized, save, setParallelized
-
Methods inherited from class com.datumbox.framework.core.machinelearning.common.abstracts.modelers.AbstractModeler
predict
-
Methods inherited from class com.datumbox.framework.core.machinelearning.common.abstracts.AbstractTrainer
fit, getModelParameters, getTrainingParameters
-
-
-
-
Method Detail
-
fit
public void fit(java.util.Map<java.lang.Object,java.net.URI> datasets)
Trains a Machine Learning modeler using the provided dataset files. The data map should have as index the names of each class and as values the URIs of the training files. The training files should contain one training example per row.- Parameters:
datasets-
-
predict
public Dataframe predict(java.net.URI datasetURI)
Generates a Dataframe with the predictions for the provided data file. The data file should contain the text of one observation per row.- Parameters:
datasetURI-- Returns:
-
predict
public Record predict(java.lang.String text)
It generates a prediction for a particular string. It returns a Record object which contains the observation data, the predicted class and probabilities.- Parameters:
text-- Returns:
-
validate
public ClassificationMetrics validate(Dataframe testDataset)
It validates the modeler using the provided dataset and it returns the ClassificationMetrics. The testDataset should contain the real target variables.- Parameters:
testDataset-- Returns:
-
validate
public ClassificationMetrics validate(java.util.Map<java.lang.Object,java.net.URI> datasets)
It validates the modeler using the provided dataset files. The data map should have as index the names of each class and as values the URIs of the training files. The data files should contain one example per row.- Parameters:
datasets-- Returns:
-
-
DataMelt 3.0 © DataMelt by jWork.ORG