我尝试在python中使用elasticsearch构建模型,但遇到此错误,我可以执行一次,但由于此错误,现在无法再次运行
import pandas as pd
df = pd.read_csv("salaries.csv")
df.head()
inputs = df.drop('salary_more_then_100k',axis='columns')
target = df['salary_more_then_100k']
from sklearn.preprocessing import LabelEncoder
le_company = LabelEncoder()
le_job = LabelEncoder()
le_degree = LabelEncoder()
inputs['company_n'] = le_company.fit_transform(inputs['company'])
inputs['job_n'] = le_job.fit_transform(inputs['job'])
inputs['degree_n'] = le_degree.fit_transform(inputs['degree'])
inputs
inputs_n = inputs.drop(['company','job','degree'],axis='columns')
inputs_n
target
from sklearn import tree
model = tree.DecisionTreeClassifier()
model.fit(inputs_n, target)
from eland.ml import MLModel
from elasticsearch import Elasticsearch
es = Elasticsearch(hosts='http://localhost:9200')
es_model = MLModel.import_model(es_client=es,
model=model,
model_id='salaries-model',
feature_names=list(df.columns),
es_if_exists='replace'
)
当我运行es_model行时,我得到这个错误-〉AttributeError:“Elasticsearch”对象没有属性“options”
我做错了什么,谁能告诉我
1条答案
按热度按时间bzzcjhmw1#
我安装了elasticsearch-dsl软件包之后就遇到了这个问题。我的Elastic软件包与elasticsearch库在比elastic_transport低得多的版本上失去了同步。升级elasticsearch库修复了我的问题。