从模糊名称匹配与机器学习 python 代码中获取错误

发布于 2025-01-09 13:29:40 字数 4710 浏览 0 评论 0原文

我看到了这个博客(https://towardsdatascience.com/fuzzy-name -matching-with-machine-learning-f09895dce7b4)及其 Github 页面 (https://github.com/Christopher-Thornton/hmni),我按照安装设置进行操作并得到我的 pycharm 控制台中出现以下错误。错误屏幕截图随本文一起附上。请帮助我,因为我正在尝试学习 python

这是我的 Pycharm IDE 代码,看起来像

import hmni
matcher = hmni.Matcher(model='latin')

matcher.similarity('Alan', 'Al')
# 0.6838303319889133
matcher.similarity('Alan', 'Al', prob=False)
# 1
matcher.similarity('Alan Turing', 'Al Turing', surname_first=False)
# 0.68383033198891

package, Error

Full Error list



/Users/user/folder/venv/bin/python /Users/user/folder/main.py
/Users/user/folder/venv/lib/python3.8/site-packages/sklearn/base.py:329: UserWarning: Trying to unpickle estimator MaxAbsScaler from version 0.23.1 when using version 1.0.2. This might lead to breaking code or invalid results. Use at your own risk. For more info please refer to:
https://scikit-learn.org/stable/modules/model_persistence.html#security-maintainability-limitations
  warnings.warn(
/Users/user/folder/venv/lib/python3.8/site-packages/sklearn/base.py:329: UserWarning: Trying to unpickle estimator MinMaxScaler from version 0.23.1 when using version 1.0.2. This might lead to breaking code or invalid results. Use at your own risk. For more info please refer to:
https://scikit-learn.org/stable/modules/model_persistence.html#security-maintainability-limitations
  warnings.warn(
/Users/user/folder/venv/lib/python3.8/site-packages/sklearn/base.py:329: UserWarning: Trying to unpickle estimator DecisionTreeClassifier from version 0.23.1 when using version 1.0.2. This might lead to breaking code or invalid results. Use at your own risk. For more info please refer to:
https://scikit-learn.org/stable/modules/model_persistence.html#security-maintainability-limitations
  warnings.warn(
/Users/user/folder/venv/lib/python3.8/site-packages/sklearn/base.py:329: UserWarning: Trying to unpickle estimator RandomForestClassifier from version 0.23.1 when using version 1.0.2. This might lead to breaking code or invalid results. Use at your own risk. For more info please refer to:
https://scikit-learn.org/stable/modules/model_persistence.html#security-maintainability-limitations
  warnings.warn(
/Users/user/folder/venv/lib/python3.8/site-packages/sklearn/base.py:329: UserWarning: Trying to unpickle estimator Pipeline from version 0.23.1 when using version 1.0.2. This might lead to breaking code or invalid results. Use at your own risk. For more info please refer to:
https://scikit-learn.org/stable/modules/model_persistence.html#security-maintainability-limitations
  warnings.warn(
/Users/user/folder/venv/lib/python3.8/site-packages/sklearn/base.py:329: UserWarning: Trying to unpickle estimator LogisticRegression from version 0.23.1 when using version 1.0.2. This might lead to breaking code or invalid results. Use at your own risk. For more info please refer to:
https://scikit-learn.org/stable/modules/model_persistence.html#security-maintainability-limitations
  warnings.warn(
Traceback (most recent call last):
  File "/Users/user/folder/main.py", line 8, in <module>
    matcher.similarity('Alan', 'Al')
  File "/Users/user/folder/venv/lib/python3.8/site-packages/hmni/matcher.py", line 266, in similarity
    sim = self.meta_inf(pair, features)
  File "/Users/user/folder/venv/lib/python3.8/site-packages/hmni/matcher.py", line 418, in meta_inf
    meta_features[0] = self.base_model_inf(base_features)
  File "/Users/user/folder/venv/lib/python3.8/site-packages/hmni/matcher.py", line 413, in base_model_inf
    y_pred = self.baseModel.predict_proba(x.reshape(1, -1))[0, 1]
  File "/Users/user/folder/venv/lib/python3.8/site-packages/sklearn/utils/metaestimators.py", line 113, in <lambda>
    out = lambda *args, **kwargs: self.fn(obj, *args, **kwargs)  # noqa
  File "/Users/user/folder/venv/lib/python3.8/site-packages/sklearn/pipeline.py", line 535, in predict_proba
    Xt = transform.transform(Xt)
  File "/Users/user/folder/venv/lib/python3.8/site-packages/sklearn/preprocessing/_data.py", line 506, in transform
    if self.clip:
AttributeError: 'MinMaxScaler' object has no attribute 'clip'

屏幕截图附在此处。请帮助我,我的预期结果是打印相似度分数,如 GitHub 页面所示

I saw this blog (https://towardsdatascience.com/fuzzy-name-matching-with-machine-learning-f09895dce7b4) and their Github page (https://github.com/Christopher-Thornton/hmni), I followed the installation setup and got the below error in my pycharm console. Error screenshots are attached along with this post. Please help me , as am trying to learn python

This is my Pycharm IDE code look likes

import hmni
matcher = hmni.Matcher(model='latin')

matcher.similarity('Alan', 'Al')
# 0.6838303319889133
matcher.similarity('Alan', 'Al', prob=False)
# 1
matcher.similarity('Alan Turing', 'Al Turing', surname_first=False)
# 0.68383033198891

and package, Error

Full Error list



/Users/user/folder/venv/bin/python /Users/user/folder/main.py
/Users/user/folder/venv/lib/python3.8/site-packages/sklearn/base.py:329: UserWarning: Trying to unpickle estimator MaxAbsScaler from version 0.23.1 when using version 1.0.2. This might lead to breaking code or invalid results. Use at your own risk. For more info please refer to:
https://scikit-learn.org/stable/modules/model_persistence.html#security-maintainability-limitations
  warnings.warn(
/Users/user/folder/venv/lib/python3.8/site-packages/sklearn/base.py:329: UserWarning: Trying to unpickle estimator MinMaxScaler from version 0.23.1 when using version 1.0.2. This might lead to breaking code or invalid results. Use at your own risk. For more info please refer to:
https://scikit-learn.org/stable/modules/model_persistence.html#security-maintainability-limitations
  warnings.warn(
/Users/user/folder/venv/lib/python3.8/site-packages/sklearn/base.py:329: UserWarning: Trying to unpickle estimator DecisionTreeClassifier from version 0.23.1 when using version 1.0.2. This might lead to breaking code or invalid results. Use at your own risk. For more info please refer to:
https://scikit-learn.org/stable/modules/model_persistence.html#security-maintainability-limitations
  warnings.warn(
/Users/user/folder/venv/lib/python3.8/site-packages/sklearn/base.py:329: UserWarning: Trying to unpickle estimator RandomForestClassifier from version 0.23.1 when using version 1.0.2. This might lead to breaking code or invalid results. Use at your own risk. For more info please refer to:
https://scikit-learn.org/stable/modules/model_persistence.html#security-maintainability-limitations
  warnings.warn(
/Users/user/folder/venv/lib/python3.8/site-packages/sklearn/base.py:329: UserWarning: Trying to unpickle estimator Pipeline from version 0.23.1 when using version 1.0.2. This might lead to breaking code or invalid results. Use at your own risk. For more info please refer to:
https://scikit-learn.org/stable/modules/model_persistence.html#security-maintainability-limitations
  warnings.warn(
/Users/user/folder/venv/lib/python3.8/site-packages/sklearn/base.py:329: UserWarning: Trying to unpickle estimator LogisticRegression from version 0.23.1 when using version 1.0.2. This might lead to breaking code or invalid results. Use at your own risk. For more info please refer to:
https://scikit-learn.org/stable/modules/model_persistence.html#security-maintainability-limitations
  warnings.warn(
Traceback (most recent call last):
  File "/Users/user/folder/main.py", line 8, in <module>
    matcher.similarity('Alan', 'Al')
  File "/Users/user/folder/venv/lib/python3.8/site-packages/hmni/matcher.py", line 266, in similarity
    sim = self.meta_inf(pair, features)
  File "/Users/user/folder/venv/lib/python3.8/site-packages/hmni/matcher.py", line 418, in meta_inf
    meta_features[0] = self.base_model_inf(base_features)
  File "/Users/user/folder/venv/lib/python3.8/site-packages/hmni/matcher.py", line 413, in base_model_inf
    y_pred = self.baseModel.predict_proba(x.reshape(1, -1))[0, 1]
  File "/Users/user/folder/venv/lib/python3.8/site-packages/sklearn/utils/metaestimators.py", line 113, in <lambda>
    out = lambda *args, **kwargs: self.fn(obj, *args, **kwargs)  # noqa
  File "/Users/user/folder/venv/lib/python3.8/site-packages/sklearn/pipeline.py", line 535, in predict_proba
    Xt = transform.transform(Xt)
  File "/Users/user/folder/venv/lib/python3.8/site-packages/sklearn/preprocessing/_data.py", line 506, in transform
    if self.clip:
AttributeError: 'MinMaxScaler' object has no attribute 'clip'

screenshots are attached here. Pls help me, my expected result was printing similarity score like the GitHub page shows

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文