程序问答   发布时间:2022-06-02  发布网站:大佬教程  code.js-code.com
大佬教程收集整理的这篇文章主要介绍了尝试使用纯 Python 获得 k-Medoids 聚类,基于其距离矩阵仅使用来自 python 的本机库大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。

如何解决尝试使用纯 Python 获得 k-Medoids 聚类,基于其距离矩阵仅使用来自 python 的本机库?

开发过程中遇到尝试使用纯 Python 获得 k-Medoids 聚类,基于其距离矩阵仅使用来自 python 的本机库的问题如何解决?下面主要结合日常开发的经验,给出你关于尝试使用纯 Python 获得 k-Medoids 聚类,基于其距离矩阵仅使用来自 python 的本机库的解决方法建议,希望对你解决尝试使用纯 Python 获得 k-Medoids 聚类,基于其距离矩阵仅使用来自 python 的本机库有所启发或帮助;

我在这里挣扎了很长时间试图完成这件事......我想要做的是用纯 Python 实现 k-MedoID PAM 算法......我的意思是没有其他库而不是原生库蟒蛇...

我有下表和距离矩阵... 那边有人可以帮我解决这个问题吗?也许你们中的一些人可以帮助我只是试图了解我如何完成这项工作...... 我编写了以下代码,但无法正常工作

def buildKMedoIDs(distances,matrixfiles):
  def tryclusters(distances,Lista):
    print(distances)
        conjuntoDiferencas = distances.copy()
        newEnsemble = []
        for n in distances:
          for m in distances:
            for i,j in zip(n[1],m[1]):
              if i < j:
                newElement = conjuntoDiferencas.pop(conjuntoDiferencas.index(n))
                newEnsemble.append(newElement)
              print(newSet)

我有一些示例数据,用于 K = 2 对于此示例数据,2 个集群是 highway_bost174,ibis_142

尝试使用纯 Python 获得 k-Medoids 聚类,基于其距离矩阵仅使用来自 python 的本机库

@H_262_27@ @H_74_28@mountain_030 @H_262_27@ @H_262_27@ @H_262_27@ @H_262_27@ @H_262_27@ @H_262_27@ @H_262_27@ @H_824_55@mountain_030 @H_262_27@ @H_262_27@ @H_262_27@
highway_bost174 ibis_142 street_par88 opencountry_241 waterfall23 fIEld26 horse_081 bison_052 ibis_040 总距离
highway_bost174 0 8.708170812 4.088197921 11.366319880 12.63876329 11.07823394 10.02510284 8.415467337 8.194840093 13.45505618 87.9701522869999
ibis_142 8.708170812 0 10.518235207 7.668395996 10.5223999 7.302185059 6.417022705 6.146172005 10.44835499 5.149291993 72.8802286650000
street_par88 4.088197921 10.51823521 0. 11.135904053 11.47283127 10.69156812 9.663827636 10.65966088 9.392413014 12.5860189 90.2086570010000
opencountry_241 11.36631988 7.668395996 11.135904053 0. 13.31494141 2.754882813 3.998626709 9.028326501 12.14570309 8.675354003 80.0884544509999
waterfall23 12.63876329 10.5223999 11.472831274 13.314941407 0 12.66552734 11.40634155 12.6048929 11.43774673 8.79888916 104.8623335570000
fIEld26 11.07823394 7.302185059 10.691568116 2.754882813 12.66552734 0 3.349212646 8.966176812 11.82766924 8.203674316 76.8391302850000
10.02510284 6.417022705 9.663827636 3.998626709 11.40634155 3.349212646 0 8.78585096 11.99428394 7.732574462 73.3728434489999
马_081 8.415467337 6.146172005 10.65966088 9.028326501 12.6048929 8.966176812 8.78585096 0 8.054160894 11.09364108 83.75434938
bison_052 8.194840093 10.44835499 9.392413014 12.145703089 11.43774673 11.82766924 11.99428394 8.054160894 0 12.86955948 96.3647314629999
ibis_040 13.45505618 5.149291993 12.586018896 8.675354003 8.79888916 8.203674316 7.732574462 11.09364108 12.86955948 0 88.5640595690000
  distances=  [('highway_bost174',[0.0,8.708170812,4.088197921,11.366319879999999,12.638763287,11.078233943,10.025102839,8.415467337,8.194840093,13.455056175000001]),('ibis_142',[8.708170812,0.0,10.518235207,7.668395996,10.522399903,7.302185059,6.417022705,6.146172005,10.448354985,5.149291993]),('street_par88',[4.088197921,11.135904053,11.472831274,10.691568116,9.663827636,10.659660884000001,9.392413013999999,12.586018896]),('opencountry_241',[11.366319879999999,13.314941407,2.754882813,3.998626709,9.028326501,12.145703089000001,8.675354002999999]),('waterfall23',[12.638763287,12.665527344000001,11.406341552,12.6048929,11.43774673,8.79888916]),('fIEld26',[11.078233943,3.349212646,8.966176812,11.827669236000002,8.203674316]),('mountain_030',[10.025102839,8.78585096,11.994283939999999,7.7325744620000005]),('horse_081',[8.415467337,8.054160893999999,11.093641082000001]),('bison_052',[8.194840093,12.869559482]),('ibis_040',[13.455056175000001,5.149291993,12.586018896,8.675354002999999,8.79888916,8.203674316,7.7325744620000005,11.093641082000001,12.869559482,0.0])]

  matrixfiles = [('highway_bost174',0.0])]

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)

大佬总结

以上是大佬教程为你收集整理的尝试使用纯 Python 获得 k-Medoids 聚类,基于其距离矩阵仅使用来自 python 的本机库全部内容,希望文章能够帮你解决尝试使用纯 Python 获得 k-Medoids 聚类,基于其距离矩阵仅使用来自 python 的本机库所遇到的程序开发问题。

如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。

本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。