我试图从Java中的多维数组获取arrf扩展输出文件.我导入了weka库,但是我收到了错误;The type FastVector<E> is deprecated.
我可以使用什么代替FastVector以及如何重写下面的代码?
import weka.core.FastVector; //Error: The type FastVector<E> is deprecated.
int [][] myArray = new int[45194][12541];
for (int i = 0; i < myArray.length; i++) {
for (int j = 0; j < myArray[0].length; j++) {
System.out.print(myArray[i][j]+" ");
}
System.out.println("");
}
int numAtts = myArray[0].length;
FastVector atts = new FastVector(numAtts);
for (int att = 0; att < numAtts; att++) {
atts.addElement(new Attribute("Attribute" + att, att));
}
int numInstances = myArray.length;
Instances dataset = new Instances("Dataset", …Run Code Online (Sandbox Code Playgroud) 我有一些代码,它给出了一个单词列表,其中包含它们在文本中出现的频率,我希望这样做,以便代码将前10个单词自动转换为ARFF
@RELATION wordfrequencies
@ATTRIBUTE字符串@ATTRIBUTE频率数字
和前10名作为数据及其频率.
我正在努力解决如何使用我当前的代码执行此操作
import re
import nltk
# Quran subset
filename = 'subsetQuran.txt'
# create list of lower case words
word_list = re.split('\s+', file(filename).read().lower())
print 'Words in text:', len(word_list)
word_list2 = [w.strip() for w in word_list if w.strip() not in nltk.corpus.stopwords.words('english')]
# create dictionary of word:frequency pairs
freq_dic = {}
# punctuation and numbers to be removed
punctuation = re.compile(r'[-.?!,":;()|0-9]')
for word in word_list2:
# remove punctuation marks
word = punctuation.sub("", word)
# form dictionary
try:
freq_dic[word] …Run Code Online (Sandbox Code Playgroud) 这是我在这个论坛上的第一个问题.... 我正在使用 WEKA API 在 java 中制作一个数据挖掘应用程序。我首先进行预处理阶段,当我保存 ARFF 文件时,我想添加几行(作为注释),指定我对文件所做的预处理任务......问题是我没有知道如何从 Java WEKA API 向 ARFF 文件添加注释。为了保存文件,我像这样使用 ArffSaver 类......
try {
ArffSaver saver = new ArffSaver();
saver.setInstances(dataPost);
saver.setFile(arffFile);
saver.writeBatch();
return true;
} catch (IOException ex) {
Logger.getLogger(Preprocesamiento.class.getName()).log(Level.SEVERE, null, ex);
return false;
}
Run Code Online (Sandbox Code Playgroud)
如果有人可以提供一些想法,我会非常高兴......谢谢!
如何将一列添加到 Rdata.frame作为新的第一列,以便所有其他列移动一列?
喜欢:
a|b|c --> new|a|b|c
Run Code Online (Sandbox Code Playgroud)
我需要这样做,因为我希望它row.names成为一个离散的列。这是必需的,因为该write.arff函数将 adata.frame作为输入,但在写入文件时不保留名称。
我需要在不使用任何外部库的情况下解析如下的arff文件。我不确定如何将属性与数值关联起来。就像我怎么说每一行的第一个数字是年龄,而第二行的是性别?您还可以将我链接到一些用于解析类似情况的python代码吗?
@relation cleveland-14-heart-disease
@attribute 'age' real
@attribute 'sex' { female, male}
@attribute 'cp' { typ_angina, asympt, non_anginal, atyp_angina}
@attribute 'trestbps' real
@attribute 'chol' real
@attribute 'fbs' { t, f}
@attribute 'restecg' { left_vent_hyper, normal, st_t_wave_abnormality}
@attribute 'thalach' real
@attribute 'exang' { no, yes}
@attribute 'oldpeak' real
@attribute 'slope' { up, flat, down}
@attribute 'ca' real
@attribute 'thal' { fixed_defect, normal, reversable_defect}
@attribute 'class' { negative, positive}
@data
63,male,typ_angina,145,233,t,left_vent_hyper,150,no,2.3,down,0,fixed_defect,negative
37,male,non_anginal,130,250,f,normal,187,no,3.5,down,0,normal,negative
41,female,atyp_angina,130,204,f,left_vent_hyper,172,no,1.4,up,0,normal,negative
56,male,atyp_angina,120,236,f,normal,178,no,0.8,up,0,normal,negative
57,female,asympt,120,354,f,normal,163,yes,0.6,up,0,normal,negative
57,male,asympt,140,192,f,normal,148,no,0.4,flat,0,fixed_defect,negative
56,female,atyp_angina,140,294,f,left_vent_hyper,153,no,1.3,flat,0,normal,negative
44,male,atyp_angina,120,263,f,normal,173,no,0,up,0,reversable_defect,negative
52,male,non_anginal,172,199,t,normal,162,no,0.5,up,0,reversable_defect,negative
Run Code Online (Sandbox Code Playgroud)
这是我编写的示例代码:
arr=[]
arff_file = …Run Code Online (Sandbox Code Playgroud) 假设我有以下带有两个属性的示例ARFF文件:
(1)情绪:正面[1]或负面[-1]
(2)推文:文字
@relation sentiment_analysis
@attribute sentiment {1, -1}
@attribute tweet string
@data
-1,'is upset that he can\'t update his Facebook by texting it... and might cry as a result School today also. Blah!'
-1,'@Kenichan I dived many times for the ball. Managed to save 50\% The rest go out of bounds'
-1,'my whole body feels itchy and like its on fire '
-1,'@nationwideclass no, it\'s not behaving at all. i\'m mad. why am i here? because I can\'t see …Run Code Online (Sandbox Code Playgroud) machine-learning weka arff sentiment-analysis text-classification
我是 Weka GUI 的新手,我想将不同字段的相关性列表输出到 .txt 文件。我的 arff 文件是正确的。任何人都可以帮忙吗?
我已经使用带有 api 的艺术作家对其进行了管理,但我似乎无法找到使用该人的地方。
我能够使用以下命令加载 .arff 文件。但是我无法从对象中提取数据并将对象转换为数据帧格式。我需要这个来在这个数据帧上应用机器学习算法。
命令:-
import arff
dataset = pd.DataFrame(arff.load(open('Training Dataset.arff')))
print(dataset)
Run Code Online (Sandbox Code Playgroud)
请帮我将这里的数据转换为数据框。
我已经使用以下代码将 arff 文件加载到 python 中:
import pandas as pd, scipy as sp
from scipy.io import arff
datos,meta = arff.loadarff(open('selectividad.arff', 'r'))
d = pd.DataFrame(datos)
Run Code Online (Sandbox Code Playgroud)
但是,这些“b”不存在于 arff 文件中,如下所示: https: //gyazo.com/3123aa4c7007cb4d6f99241b1fc41bcb 这里有什么问题?非常感谢