我正在尝试在Mathematica中运行一个简单的文本分类器实验。下面的代码显示了训练模型的设置;
B = Classify[{3 -> "The", 2 -> "Phrase", 1 -> "Best", 4 -> "Bad"}]
我已经在我手动放在一起的简单列表上对此进行了测试,并且工作正常,我要完成的下一步是在从Excel工作表导入的数据列上运行此操作。我对Mathematica并不熟悉,而且我对Python更熟悉。我遇到了麻烦,因为看起来我不能简单地调用一个列并在其上运行一个函数。我相信我的问题是,在导入时,该列存储为列表列表。如何将其转换为单个文本列表,以便我可以尝试运行上面的内容。我还将如何存储输出?我想我可以创建一个对象,但我又不熟悉这种编程风格。
我在excel下面的数据示例;字面上是单列,没有标题
The Phrase
The Answer
The Phrases
Phrase
Answer
The Answer Phrase
The Answer Phrases
The Answers Phrase
The Question
The Statement
Statement
Question
Questions
Statements
The Statements
Good
Bad
Neutral
Best
Better
The Best
The Bad
The Worst
Worst
The Offer
The Offers
Offer
导入后如下所示;
`{{{"The Phrase"}, {"The Answer"}, {"The Phrases"}, {"Phrase"},
{"Answer"}, {"The Answer Phrase"}, {"The Answer Phrases"}, {"The
Answers Phrase"}, {"The Question"}, {"The Statement"}, {"Statement"},
{"Question"}, {"Questions"}, {"Statements"}, {"The Statements"},
{"Good"}, {"Bad"}, {"Neutral"}, {"Best"}, {"Better"}, {"The Best"},
{"The Bad"}, {"The Worst"}, {"Worst"}, {"The Offer"}, {"The Offers"},
{"Offer"},....`