本文整理匯總了Python中FileManager.FileManager.csvToArray方法的典型用法代碼示例。如果您正苦於以下問題:Python FileManager.csvToArray方法的具體用法?Python FileManager.csvToArray怎麽用?Python FileManager.csvToArray使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類FileManager.FileManager
的用法示例。
在下文中一共展示了FileManager.csvToArray方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: creaFileFeatures
# 需要導入模塊: from FileManager import FileManager [as 別名]
# 或者: from FileManager.FileManager import csvToArray [as 別名]
def creaFileFeatures(self,key=None):
if key == None:
## PREPROCESSING PERCORSI IMMAGINI
fm = FileManager()
file_positive = self.root+self.keywords+"/"+self.keywords+"_" + self.detector + "_" + self.extractor + ".csv"
# Creo una lista contenente tutte le immagini (jpg) positive (Filtro estension)
listArrayPositive = fm.listNoHiddenFiles(self.root+self.keywords,self.estension)
## SAVE FEATURES IN FILES
# Controllo se e' gia' presente, altrimenti leggo il file e restituisco array
if not os.path.isfile(file_positive):
print "Nuovo File Features Positive " + self.detector + " + " + self.extractor + " creato."
X_positive = []
for k in range(0,len(listArrayPositive)): # Da eliminare file csv ed altri
base_name = self.root+self.keywords+"/"+self.keywords+fm.correggi(k)+ self.estension
print "Immagini " + str(k) + " -> " + base_name
ret = (self.obj.elabora(base_name)) #[0:cut_features]
X_positive.append(ret)
fm.arrayToCsv(X_positive,file_positive)
else:
print "File Features Positive " + self.detector + " + " + self.extractor + " esiste gia."
X_positive = fm.csvToArray(file_positive)
else:
## PREPROCESSING PERCORSI IMMAGINI
fm = FileManager()
file_positive = self.root+key+"/"+key+"_" + self.detector + "_" + self.extractor + ".csv"
# Creo una lista contenente tutte le immagini (jpg) positive (Filtro estension)
listArrayPositive = fm.listNoHiddenFiles(self.root+key,self.estension)
## SAVE FEATURES IN FILES
# Controllo se e' gia' presente, altrimenti leggo il file e restituisco array
if not os.path.isfile(file_positive):
print "Nuovo File Features Positive " + self.detector + " + " + self.extractor + " creato."
X_positive = []
for k in range(0,len(listArrayPositive)): # Da eliminare file csv ed altri
base_name = self.root+key+"/"+key+fm.correggi(k)+ self.estension
print "Immagini " + str(k) + " -> " + base_name
ret = (self.obj.elabora(base_name)) #[0:cut_features]
X_positive.append(ret)
fm.arrayToCsv(X_positive,file_positive)
else:
print "File Features Positive " + self.detector + " + " + self.extractor + " esiste gia."
X_positive = fm.csvToArray(file_positive)
return X_positive
示例2: negativeFeaturesSingleCat
# 需要導入模塊: from FileManager import FileManager [as 別名]
# 或者: from FileManager.FileManager import csvToArray [as 別名]
def negativeFeaturesSingleCat(self,category):
## PREPROCESSING PERCORSI IMMAGINI
fm = FileManager()
X_negative = []
#for i in range(0,len(listDir)):
file_negative = self.root+category+"/"+category+"_" + self.detector + "_" + self.extractor + ".csv"
if not os.path.isfile(file_negative):
self.creaFileFeatures(category)
else:
X = fm.csvToArray(file_negative)
X_negative = X_negative + X
return X_negative
示例3: featuresCategories
# 需要導入模塊: from FileManager import FileManager [as 別名]
# 或者: from FileManager.FileManager import csvToArray [as 別名]
def featuresCategories(self):
#recupera tutte le categorie, senza distinzione fra positive e negative
#usando un numero incrementale per l'assegnazione delle categorie
fm = FileManager()
X_train = []
y_train = []
assoc = dict()
listCategories = fm.listNoHiddenDir(self.root)
index = 1
for cat in listCategories:
file_positive = self.root+cat+"/"+cat+"_" + self.detector + "_" + self.extractor + ".csv"
X_cat = fm.csvToArray(file_positive)
X_train = X_train + X_cat
y_train = y_train + [index]*len(X_cat)
assoc[cat] = index
index = index + 1
return X_train,y_train,assoc
示例4: negativeFeatures
# 需要導入模塊: from FileManager import FileManager [as 別名]
# 或者: from FileManager.FileManager import csvToArray [as 別名]
def negativeFeatures(self):
## PREPROCESSING PERCORSI IMMAGINI
fm = FileManager()
#file_negative = self.root+self.keywords+"/"+self.keywords+"_" + self.detector + "_" + self.extractor + "_negative.csv"
# List dir contiene tutte le cartelle della root img
listDir = fm.listNoHiddenDir(self.root)
# Cerco l'indice della cartella della Keywords
indexKeywords = listDir.index(self.keywords)
# Vado ad eliminare nella lista cartelle quella della keywords
listDir.pop(indexKeywords)
X_negative = []
for i in range(0,len(listDir)):
file_negative = self.root+listDir[i]+"/"+listDir[i]+"_" + self.detector + "_" + self.extractor + ".csv"
if not os.path.isfile(file_negative):
self.creaFileFeatures(listDir[i])
else:
X = fm.csvToArray(file_negative)
X_negative = X_negative + X
return X_negative
示例5: str
# 需要導入模塊: from FileManager import FileManager [as 別名]
# 或者: from FileManager.FileManager import csvToArray [as 別名]
print "Immagini " + str(k) + " -> " + base_name
ret = (obj.elabora(base_name)) #[0:cut_features]
X_negative.append(ret)
fm.arrayToCsv(X_negative,file_negative)
else:
print "File Features Negative " + detector + " + " + extractor + " esiste gia."
#raw_input()
## FEATURES ML FROM FILES
# Array dai file csv
print "Caricamento file csv into array"
X_positive_from_csv = fm.csvToArray(file_positive)
X_negative_from_csv = fm.csvToArray(file_negative)
X_total = X_positive_from_csv + X_negative_from_csv
y_total = [0]*len(X_positive_from_csv)+[1]*len(X_negative_from_csv)
#print y_total
# Preparing cross_validation
#X_train, X_test, y_train, y_test = cross_validation.train_test_split(X_total, y_total, test_size=0.3, random_state=1)
X_train = X_total
y_train = y_total
X_test = [obj.elabora("./gatto.jpg")]
y_test = [1]
# ML