watson_developer_cloud.natural_language_classifier_v1 module¶
IBM Watson Natural Language Classifier uses machine learning algorithms to return the top matching predefined classes for short text input. You create and train a classifier to connect predefined classes to example texts so that the service can apply those classes to new inputs.
-
class
NaturalLanguageClassifierV1
(url='https://gateway.watsonplatform.net/natural-language-classifier/api', username=None, password=None)[source]¶ Bases:
watson_developer_cloud.watson_service.WatsonService
The Natural Language Classifier V1 service.
-
default_url
= 'https://gateway.watsonplatform.net/natural-language-classifier/api'¶
-
classify
(classifier_id, text)[source]¶ Returns label information for the input.
The status must be Available before you can use the classifier to classify text. Use Get information about a classifier to retrieve the status.
Parameters: Returns: A dict containing the Classification response.
Return type:
-
create_classifier
(metadata, training_data, metadata_filename=None, training_data_filename=None)[source]¶ Create classifier.
Sends data to create and train a classifier and returns information about the new classifier.
Parameters: - metadata (file) – Metadata in JSON format. The metadata identifies the language of the data, and an optional name to identify the classifier. For details, see the [API reference](https://www.ibm.com/watson/developercloud/natural-language-classifier/api/v1/#create_classifier).
- training_data (file) – Training data in CSV format. Each text value must have at least one class. The data can include up to 15,000 records. For details, see [Using your own data](https://www.ibm.com/watson/developercloud/doc/natural-language-classifier/using-your-data.html).
- metadata_filename (str) – The filename for training_metadata.
- training_data_filename (str) – The filename for training_data.
Returns: A dict containing the Classifier response.
Return type:
-
delete_classifier
(classifier_id)[source]¶ Delete classifier.
Parameters: classifier_id (str) – Classifier ID to delete. Return type: None
-
-
class
Classification
(classifier_id=None, url=None, text=None, top_class=None, classes=None)[source]¶ Bases:
object
Response from the classifier for a phrase.
Attr str classifier_id: (optional) Unique identifier for this classifier. Attr str url: (optional) Link to the classifier. Attr str text: (optional) The submitted phrase. Attr str top_class: (optional) The class with the highest confidence. Attr list[ClassifiedClass] classes: (optional) An array of up to ten class-confidence pairs sorted in descending order of confidence.
-
class
ClassifiedClass
(confidence=None, class_name=None)[source]¶ Bases:
object
Class and confidence.
Attr float confidence: (optional) A decimal percentage that represents the confidence that Watson has in this class. Higher values represent higher confidences. Attr str class_name: (optional) Class label.
-
class
Classifier
(url, classifier_id, name=None, status=None, created=None, status_description=None, language=None)[source]¶ Bases:
object
A classifier for natural language phrases.
Attr str name: (optional) User-supplied name for the classifier. Attr str url: Link to the classifier. Attr str status: (optional) The state of the classifier. Attr str classifier_id: Unique identifier for this classifier. Attr datetime created: (optional) Date and time (UTC) the classifier was created. Attr str status_description: (optional) Additional detail about the status. Attr str language: (optional) The language used for the classifier.