我在尝试使用joblib取消对象时遇到属性错误。我应该单独挑选我的课程然后拆开它们吗?
Class MainWindow
Private Sub Button1_Click(sender As System.Object, e As System.Windows.RoutedEventArgs) Handles Button1.Click
For Each window As Window In Application.Current.Windows
window.Background = New SolidColorBrush(Colors.Yellow)
Next
End Sub
Private Sub Button2_Click(sender As System.Object, e As System.Windows.RoutedEventArgs) Handles Button2.Click
Dim myWindow As New Window1()
myWindow.Owner = Application.Current.MainWindow
myWindow.ShowDialog()
End Sub
End Class
在此处加载腌制文件
class LengthTransformer(TransformerMixin):
def transform(self, X, **transform_params):
length = pd.DataFrame(X.apply(lambda x: len(x)))
return length
def fit(self, X, y=None, **fit_params):
return self
pipeline = Pipeline([('features', FeatureUnion([
('ngram_tf_idf', Pipeline([
('vect', CountVectorizer()),
('tfidf', TfidfTransformer())
])),
('length',LengthTransformer())
])),
('clf', clf),])
vectorizer_name = 'fpath'+name
joblib.dump(pipeline.steps[0][1],vectorizer_name+'_vect_'+str(int(accuracy*100)) +'.pkl')
我收到以下错误。我相信这是因为它没有腌制我的课程。我读过pickle可以用来序列化类,但我使用joblib来获得更好的性能。
vect_file = "MultinomialNB_vect_80.pkl"
vect = joblib.load(vect_file)
答案 0 :(得分:0)
在一个单独的模块中定义您的类,并将该模块导入正在执行pickle转储的程序和执行pickle加载的程序。