小编Suj*_* De的帖子

如何解决"IndexError:数组索引太多"

我下面的代码给出了以下错误"IndexError:数组索引太多".我对机器学习很新,所以我对如何解决这个问题一无所知.任何形式的帮助将不胜感激.

train = pandas.read_csv("D:/...input/train.csv")


xTrain = train.iloc[:,0:54]
yTrain = train.iloc[:,54:]


from sklearn.cross_validation import cross_val_score
clf = LogisticRegression(multi_class='multinomial')
scores = cross_val_score(clf, xTrain, yTrain, cv=10, scoring='accuracy')
print('****Results****')
print(scores.mean())
Run Code Online (Sandbox Code Playgroud)

python arrays machine-learning indices data-science

6
推荐指数
2
解决办法
2万
查看次数

如何找到词网中名词到其根节点的距离?

我想知道我的句子中某个单词的具体程度。因此,为了做到这一点,我所采取的假设是单词在 wordnet 的上位词层次结构中越低,它就越具体。但我无法编写一个代码来给出名词词与其根上位词“entity.n.01”之间的节点数,我正在尝试使用 nltk 的 wordnet 来做到这一点。请在这方面帮助我。

任何帮助,将不胜感激。

python nltk wordnet

2
推荐指数
1
解决办法
1282
查看次数

'numpy.ndarray'对象没有属性'barh'是什么意思以及如何纠正它?

我想绘制一个5 x 4的图.相同的代码如下

fig, axis = plt.subplots(5, 4,figsize=[25,10])
i = 0
for channel in np.unique(data_recent['channel_id']):
    for year in np.unique(data_recent['year']):
        filter_data = data_recent.loc[(data_recent['channel_id']==str(channel)) & (data_recent['year']==year)]
        topics_count = []
        for topic in list(sumbags.keys()):
            topics_count.append([topic, filter_data[str(topic)].sum()])
        topics_group = pd.DataFrame(topics_count, columns = ['topics','count'])
        topics_group = topics_group.sort_values(by='count', ascending=False)[:5]
        print (channel, year)
        print (topics_group)

        sns.barplot(x = 'count', y = 'topics', data = topics_group, ax = axis[i])
        axis[i].set_title("Top 5 topics for " + str(channel) + " " + str(year))
        axis[i].set_ylabel("Topics")
        axis[i].set_xlabel("Count")
        fig.subplots_adjust(hspace=0.4)    
        fig.subplots_adjust(wspace=0.4)
        i += 1

print …
Run Code Online (Sandbox Code Playgroud)

python plot numpy matplotlib seaborn

1
推荐指数
1
解决办法
6657
查看次数

我无法在课程之间切换

HTML代码

<template name="pI">
  <p class="bucket">
    <li class= "contentMain">{{{content}}}</li>
    <li><a href="#" class= "expandOrCollapse">(...)</a></li>
  </p>
</template>
Run Code Online (Sandbox Code Playgroud)

JS代码

    Template.pI.events({
      'click .expandOrCollapse':function(event){
       event.preventDefault();
       $(event.target).closest().toggleClass("contentMain Big");
      }
  });
Run Code Online (Sandbox Code Playgroud)

CSS代码

.contentMain{
    position: relative;
    overflow: hidden;
    height: 60px;
    top: -15px;
    font-family: Palatino Linotype, Georgia, Verdana, sans-serif;
}

.Big{
    position: relative;
    height: auto;
    top: -15px;
    font-family: Palatino Linotype, Georgia, Verdana, sans-serif;
}
Run Code Online (Sandbox Code Playgroud)

当我在当前类是"contentMain"时单击"expandOrCollapse"并且当我在当前单击"expandOrCollapse"时将类"Big"切换为"contentMain"时,我希望类"contentMain"切换为"Big"阶级是"大".我不认为我对JS代码有任何错误.任何帮助和建议将受到高度赞赏

html javascript css meteor

0
推荐指数
1
解决办法
57
查看次数