Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import numpy as np
- import pandas as pd
- import matplotlib.pyplot as plt
- from skimage.io import imread
- #Citim baza de date pentru antrenare si testare
- df = pd.read_csv('eye_data_lab4.csv')
- df_t = pd.read_csv('eye_data_lab4_test.csv')
- #pandas.DataFrame.nunique finds the unique elements(lines) of a dataset
- df['label'].nunique()
- #Print dataframe
- print(df.head())
- # Eliminam coloana label pentru a ramane doar cu caracterisiticile pozelor
- features = df.drop('label', axis=1)
- label = df['label']
- #convertim tipul de date din panda in ndarray
- testFeatures = df_t.to_numpy()
- #Extragem dimensiunea matricei de caracteristici
- n, m = features.shape
- # Construiti si rezolvati problema cmmp utilizand comanda lstqr
- lstqr = np.linalg.lstsq(features, label, rcond=None)
- i = input('Introduceti o valoare intre 0 si 3: ')
- #Afisarea imaginii testate
- img = imread(i +'.jpg')
- plt.axis("off")
- plt.imshow(img,cmap="gray")
- print(img.shape)
- # Testati clasificatorul, cu alte cuvinte preziceti test_label
- if test_label >= 0:
- print('Ochiul este deschis')
- else: print('Ochiul este inchis')
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement