# Extract the features for a given application
features = extract_features(file_path)
# Form the feature vector
feature_vector = create_vector_single(features)
# Load the pre configured feature model from a pickle file
model = pickle.load(open("feature_model.p", "rb"))
# Reduce the feature vector into size 12
feature_vector_new = model.transform(feature_vector)
# Load the pre-trained model from a pickle file
clf = pickle.load( open( "kfold_train_data.p", "rb" ) )
# Perform prediction using the model
result = clf.predict(feature_vector_new)
feature_vector_new = model.transform(feature_vector)
上发生错误
Reshape your data either using array.reshape(-1, 1) if your data has a single feature or array.reshape(1, -1) if it contains a single sample.
然后我用:
解决# Reduce the feature vector into size 12
vec = [feature_vector]
vec = np.array(vec).reshape(1, -1)
feature_vector_new = model.transform(vec)
它会生成另一个错误:
AttributeError: 'SelectFromModel' object has no attribute 'norm_order'
答案 0 :(得分:0)
当我跟踪类似的代码时,我发现生成的模型对象中的参数DELETE
FROM tblParts
WHERE NOT EXISTS
(
SELECT '1'
FROM tblOrders
WHERE tblOrders.PartID = tblParts.ID
);
少了一个norm_order
。
答案:重新生成一个模型,然后这个问题就解决了!
```
feature_model.p
```