Notes
Notes - notes.io |
kanal_sayisi = 3 # 1: Grayscale, 3: RGB
etiket_sayisi = 2 # sınıf sayısı
test_verisi_orani = 0.3 # %20 test
resimler_klasoru = '/content/drive/MyDrive/ms/dinamik_son'
veriseti_klasoru = '/content/drive/MyDrive/ms_data_son'
def resmi_al(resimler_klasoru):
resim = imread(resimler_klasoru, flatten= True if kanal_sayisi == 1 else False)
resim = imresize(resim, (resim_boyutu, resim_boyutu, kanal_sayisi))
return resim
etiketler = listdir(resimler_klasoru)
X, Y = [], []
for i, etiket in enumerate(etiketler):
etiket_klasoru = resimler_klasoru+'/'+etiket
for resim_adi in listdir(etiket_klasoru):
resim = resmi_al(etiket_klasoru+'/'+resim_adi)
X.append(resim)
Y.append(i)
X=np.array(X)
Y=np.array(Y)
X = np.where(X>254,0,X)
import numpy as np
import matplotlib.pyplot as plt
if not os.path.exists(veriseti_klasoru+'/'):
os.makedirs(veriseti_klasoru+'/')
from keras.applications import *
from keras.models import Model
model_vgg16 = VGG16(weights='imagenet', include_top=True, input_shape=(224,224,3))
model_vgg16 = Model(inputs=model_vgg16.inputs, outputs=model_vgg16.layers[-3].output)
for layer in model_vgg16.layers:
layer.trainable = False
#print('Layer ' + layer.name + ' frozen.')
model_vgg16.summary()
import pandas as pd
data_vgg16 = pd.DataFrame(columns=["x","target"])
size, a,b,c = X.shape
for i in range(size):
data_vgg16.loc[i]=[model_vgg16.predict(X[i].reshape(1,224,224,3)),int(Y[i])]
#print(x1[i])
data_vgg16.head()
#data_vgg16.tail()
X_train, X_test, y_train, y_test = train_test_split(np.array(data_vgg16.x.tolist()).reshape(X.shape[0],4096), Y, test_size = 0.15,random_state=23)
print(y_test.shape[0])
y_test.sum()
from sklearn.svm import SVC
svclassifier = SVC(kernel = "linear")
svclassifier.fit(X_train, y_train)
y_pred = svclassifier.predict(X_test)
from sklearn.metrics import classification_report, confusion_matrix
print(confusion_matrix(y_test,y_pred))
print(classification_report(y_test,y_pred))
import seaborn as sns
sns.heatmap(confusion_matrix(y_test,y_pred), annot=True)
sns.heatmap(confusion_matrix(y_test,y_pred)/np.sum(confusion_matrix(y_test,y_pred)), annot=True,
fmt='.2%', cmap='Blues')
fig=plt.figure(figsize=(10,8))
columns = 6
rows = 3
for i in range(1, columns*rows +1):
img = X[i*8]
ax=fig.add_subplot(rows, columns, i)
label = ""
if i*11>100:
label="Sağlıklı"
else:
label="MS Hastası"
ax.title.set_text(label)
plt.imshow(img)
plt.savefig("deneme.png")
plt.show()
![]() |
Notes is a web-based application for online taking notes. You can take your notes and share with others people. If you like taking long notes, notes.io is designed for you. To date, over 8,000,000,000+ notes created and continuing...
With notes.io;
- * You can take a note from anywhere and any device with internet connection.
- * You can share the notes in social platforms (YouTube, Facebook, Twitter, instagram etc.).
- * You can quickly share your contents without website, blog and e-mail.
- * You don't need to create any Account to share a note. As you wish you can use quick, easy and best shortened notes with sms, websites, e-mail, or messaging services (WhatsApp, iMessage, Telegram, Signal).
- * Notes.io has fabulous infrastructure design for a short link and allows you to share the note as an easy and understandable link.
Fast: Notes.io is built for speed and performance. You can take a notes quickly and browse your archive.
Easy: Notes.io doesn’t require installation. Just write and share note!
Short: Notes.io’s url just 8 character. You’ll get shorten link of your note when you want to share. (Ex: notes.io/q )
Free: Notes.io works for 14 years and has been free since the day it was started.
You immediately create your first note and start sharing with the ones you wish. If you want to contact us, you can use the following communication channels;
Email: [email protected]
Twitter: http://twitter.com/notesio
Instagram: http://instagram.com/notes.io
Facebook: http://facebook.com/notesio
Regards;
Notes.io Team
