我下面的代码给出了以下错误"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) 我想知道我的句子中某个单词的具体程度。因此,为了做到这一点,我所采取的假设是单词在 wordnet 的上位词层次结构中越低,它就越具体。但我无法编写一个代码来给出名词词与其根上位词“entity.n.01”之间的节点数,我正在尝试使用 nltk 的 wordnet 来做到这一点。请在这方面帮助我。
任何帮助,将不胜感激。
我想绘制一个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) 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代码有任何错误.任何帮助和建议将受到高度赞赏
python ×3
arrays ×1
css ×1
data-science ×1
html ×1
indices ×1
javascript ×1
matplotlib ×1
meteor ×1
nltk ×1
numpy ×1
plot ×1
seaborn ×1
wordnet ×1