Python中关于SVM物种分布模型代码报错

尝试使用Python的sklearn库构建SVM物种分布模型,根据某博客文章进行操作,但遇到代码适配字典形式TXT数据集的问题。在Spyder环境中运行,代码无报错,但模型未正确输出。寻求帮助解决此问题。
摘要由CSDN通过智能技术生成

Python中关于SVM物种分布模型代码报错
最近看了这篇文章:https://blog.csdn.net/wong2016/article/details/83151122
里面用sklearn的数据集结合SVM画了物种分布图,遂想要试试看,手头有字典形式的TXT数据集,但并不是特别会写,遂参考链接文中的代码进行修改和复制(非商用)。
想发个帖子求助一下……哪位前辈给康康哪里错了……脑阔痛=。=

**from __future__ import print_function
from time import time
import numpy as np
import matplotlib.pyplot as plt
from sklearn.datasets.base import Bunch
#from sklearn.datasets import fetch_species_distributions
from sklearn.datasets.species_distributions import construct_grids
from sklearn import svm, metrics
# if basemap is available, we'll use it.
# otherwise, we'll improvise later...
try:
    from mpl_toolkits.basemap import Basemap
    basemap = True
except ImportError:
    basemap = False
print(__doc__)
def create_species_bunch(species_name, train, test, coverages, xgrid, ygrid):
    """Create a bunch with information about a particular organism
    This will use the test/train record arrays to extract the
    data specific to the given species name.
    """
    bunch = Bunch(name=' '.join(species_name.split("_")[:2]))
    species_name = species_name.encode('ascii')
    points = dict(test=test, train=train)
    for label, pts in points.items():
        # choose points associated with the desired species
        pts = pts[pts['species'] == species_name]
       
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 5
    评论
评论 5
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值