你好,
我在訓練一個邏輯回歸文本的幫助下一個tf-idf vectorizer。
這樣做是與MLflow sklearn磚。
模型本身是磚訓練成功,可以完成預測在磚上的jupyter筆記本平台。Beplay体育安卓版本
MLflow代碼創建模型:
與mlflow.start_run (run_name = logistic_regression)運行:text_transformer = TfidfVectorizer (stop_words =(英語的),ngram_range =(1、2),小寫= True, max_features = 150000) lr = LogisticRegression (C = 5 e1,解算器= lbfgs, multi_class =多項式,random_state = 17日n_jobs = 4) text_transformer.fit (train_val['文本'])mlflow.sklearn。log_model (text_transformer tfidf-model) X_train_text = text_transformer.transform (train_val['文本'])X_test_text = text_transformer.transform(測試['文本'])skf = StratifiedKFold (n_splits = 5,洗牌= True, random_state = 17) cv_results = cross_val_score (lr、X_train_text train_val['標簽'],簡曆= skf,得分= f1_micro) mlflow。log_param (“F1_score cv_results.mean ()) lr。適合(X_train_text train_val['標簽'])mlflow.sklearn。log_model (lr、“lr-model”)
在模型選項卡中它隻是可能的服務邏輯回歸,沒有問題。
然而,對於服務tfidf vectorizer出現以下問題:
回溯(最近調用最後):文件“<字符串>”,1號線,在<模塊> KeyError:“python_function”
檢查下兩個模型實驗中,值得注意的是,tfidf vectorizer不包含關鍵的屬性“python_function”。
邏輯回歸:
artifact_path: lr-model databricks_runtime: 10.4.x-scala2.12口味:python_function: env: conda。yaml loader_module: mlflow。sklearn model_path:模型。pkl python_version: 3.8.10 sklearn:代碼:零pickled_model:模型。pkl serialization_format: cloudpickle sklearn_version: 0.24.1 mlflow_version: 1.28.0 model_uuid:一些run_id:一些utc_time_created:“一些日期”
tfidf:
artifact_path: tfidf-model databricks_runtime: 10.4.x-scala2.12口味:sklearn:代碼:零pickled_model:模型。pkl serialization_format: cloudpickle sklearn_version: 0.24.1 mlflow_version: 1.28.0 model_uuid:一些run_id:一些utc_time_created:“一些日期”
問題:
提前謝謝你的幫助,
最好的,
matebreeze