from scipy.io import loadmat

def load_clean_data():
    data = loadmat('data/cleandata_students.mat')
    return data['x'], data['y']

def load_noisy_data():
    data = loadmat('data/noisydata_students.mat')
    return data['x'], data['y']

if __name__ == '__main__':
    print('Clean Data:')
    x, y = load_clean_data()
    print('x:', x)
    print('y:', y)

    print()

    print('Noisy Data:')
    x, y = load_noisy_data()
    print('x:', x)
    print('y:', y)

from scipy.io import loadmat

def load_data(data_file):
    data = loadmat(data_file)
    return data['x'], data['y']

if __name__ == '__main__':
    print('Clean Data:')
    x, y = load_data('data/cleandata_students.mat')
    print('x:', x)
    print('y:', y)

    print()

    print('Noisy Data:')
    x, y = load_data('data/noisydata_students.mat')
    print('x:', x)
    print('y:', y)

Remove hard-coded data file path
Remove hard-coded data file path
  from scipy.io import loadmat
  
+ def load_data(data_file):
+     data = loadmat(data_file)
- def load_clean_data():
-     data = loadmat('data/cleandata_students.mat')
-     return data['x'], data['y']
- 
- def load_noisy_data():
-     data = loadmat('data/noisydata_students.mat')
      return data['x'], data['y']
  
  if __name__ == '__main__':
      print('Clean Data:')
-     x, y = load_clean_data()
+     x, y = load_data('data/cleandata_students.mat')
      print('x:', x)
      print('y:', y)
  
      print()
  
      print('Noisy Data:')
-     x, y = load_noisy_data()
+     x, y = load_data('data/noisydata_students.mat')
      print('x:', x)
      print('y:', y)
  
Remove hard-coded data file path
## Code Before:
from scipy.io import loadmat

def load_clean_data():
    data = loadmat('data/cleandata_students.mat')
    return data['x'], data['y']

def load_noisy_data():
    data = loadmat('data/noisydata_students.mat')
    return data['x'], data['y']

if __name__ == '__main__':
    print('Clean Data:')
    x, y = load_clean_data()
    print('x:', x)
    print('y:', y)

    print()

    print('Noisy Data:')
    x, y = load_noisy_data()
    print('x:', x)
    print('y:', y)

## Instruction:
Remove hard-coded data file path
## Code After:
from scipy.io import loadmat

def load_data(data_file):
    data = loadmat(data_file)
    return data['x'], data['y']

if __name__ == '__main__':
    print('Clean Data:')
    x, y = load_data('data/cleandata_students.mat')
    print('x:', x)
    print('y:', y)

    print()

    print('Noisy Data:')
    x, y = load_data('data/noisydata_students.mat')
    print('x:', x)
    print('y:', y)
