BPNN
正确率大概是三四十
import os
import time
import cv2 as cv
import numpy as np
import tensorflow as tf
from sklearn.decomposition import PCA
# ——————————————————————————————————————————————function————————————————————————————————————————————————————
def get_path(filepath):
filelist = []
filedirs = []
for root, _, files in os.walk(filepath, topdown = False):
for name in files:
filelist.append(name)
filedirs.append(os.path.join(root, name))
return filelist, filedirs
def read_file(path,filelist, filedirs, n_component = 1, Use_smote = False):
dic ={
'DCIS':0, 'IDC':0, 'Muc':0, 'ILC':0, 'MC':0,
'normal':1,
'TIL':2}
datalist = []
claslist = []
for path in filedirs:
img = cv.imread(path, 0) #单通道读入灰度图像
vec = img.flatten() / 255
name = filelist[filedirs.index(path)]
clas = name.split('_')[0] #保留_前面的字符串即:'DCIS'...
if len(vec) == 51*51:
datalist.append(vec)
claslist.append(dic[clas])
claslist = np