Created
July 18, 2020 16:43
-
-
Save saimadhu-polamuri/fb850e5a4d900523417d04e4ede5a07f to your computer and use it in GitHub Desktop.
Create space textcategorizer model
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
######## Main method ######## | |
def main(): | |
# Load dataset | |
data = pd.read_csv(data_path) | |
observations = len(data.index) | |
print("Dataset Size: {}".format(observations)) | |
# Create an empty spacy model | |
nlp = spacy.blank("en") | |
# Create the TextCategorizer with exclusive classes and "bow" architecture | |
text_cat = nlp.create_pipe( | |
"textcat", | |
config={ | |
"exclusive_classes": True, | |
"architecture": "bow"}) | |
# Adding the TextCategorizer to the created empty model | |
nlp.add_pipe(text_cat) | |
# Add labels to text classifier | |
text_cat.add_label("ham") | |
text_cat.add_label("spam") | |
if __name__ == "__main__": | |
main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment