Advertisement
brospresident

Untitled

Nov 17th, 2021
835
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.10 KB | None | 0 0
  1. import numpy as np
  2. import pandas as pd
  3. import matplotlib.pyplot as plt
  4. from skimage.io import imread
  5.  
  6.  
  7. #Citim baza de date pentru antrenare si testare
  8. df = pd.read_csv('eye_data_lab4.csv')
  9. df_t = pd.read_csv('eye_data_lab4_test.csv')
  10.  
  11. #pandas.DataFrame.nunique finds the unique elements(lines) of a dataset
  12. df['label'].nunique()
  13.  
  14. #Print dataframe
  15. print(df.head())
  16.  
  17. # Eliminam coloana label pentru a ramane doar cu caracterisiticile pozelor
  18. features = df.drop('label', axis=1)
  19. label = df['label']
  20.  
  21. #convertim tipul de date din panda in ndarray
  22. testFeatures = df_t.to_numpy()
  23.  
  24. #Extragem dimensiunea matricei de caracteristici
  25. n, m = features.shape
  26.  
  27. # Construiti si rezolvati problema cmmp utilizand comanda lstqr
  28. lstqr = np.linalg.lstsq(features, label, rcond=None)
  29.  
  30. i = input('Introduceti o valoare intre 0 si 3: ')
  31.  
  32. #Afisarea imaginii testate
  33. img = imread(i +'.jpg')
  34. plt.axis("off")
  35. plt.imshow(img,cmap="gray")
  36.  
  37. print(img.shape)
  38.  
  39. # Testati clasificatorul, cu alte cuvinte preziceti test_label
  40.  
  41. if test_label >= 0:
  42.     print('Ochiul este deschis')
  43. else: print('Ochiul este inchis')
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement