我正在使用管道构建NLP模型,并且像这样定义了pipe.transform(x_train),
('array to be sorted is: ', [7, 5, 4, 6, 1, 15, 12])
('Pivot is: ', 7)
('array after partitioning step is: ', [1, 5, 4, 6, 7, 15, 12])
('Pivot Index in the array is:', 4)
('array to be sorted is: ', [1, 5, 4, 6])
('Pivot is: ', 1)
('array after partitioning step is: ', [1, 5, 4, 6])
('Pivot Index in the array is:', 0)
('array to be sorted is: ', [5, 4, 6])
('Pivot is: ', 5)
--->('array after partitioning step is: ', [4, 5, 6])
--->('Pivot Index in the array is:', 1)
--->('Sorting is done! Final array is:', [4, 5, 6])
--->('Sorting is done! Final array is:', [1, 5, 4, 6])
('array to be sorted is: ', [15, 12])
('Pivot is: ', 15)
('array after partitioning step is: ', [12, 15])
('Pivot Index in the array is:', 1)
--->('Sorting is done! Final array is:', [12, 15])
--->('Sorting is done! Final array is:', [1, 5, 4, 6, 7, 15, 12])
('Total number of comparisons', 6)
[1, 5, 4, 6, 7, 15, 12]
那没问题,但是当我在两个单元格之后呼叫%%time
train_vec = pipeline.transform(x_train)
test_vec = pipeline.transform(x_test)
print("Checking that the number of features in train and test correspond: %s - %s" % (train_vec.shape, test_vec.shape))
时,我收到了NameError。
train_vec
然后我在这里称呼它
clf_sv = LinearSVC(C=1, class_weight='balanced', multi_class='ovr', random_state=40, max_iter=10000)#Support Vector Machines
clf_sgd = SGDClassifier(max_iter=200) #Stochastic Gradient Classifier
在这一点上,我只是通过直接调用pipeline.transform(x_train)解决了这个问题,但它仍然令人发疯。感谢您的帮助。