Function used for loading data from the seaborn splitting into x and y points
(dataset_name: str, cola_name: str, colb_name: str)
| 56 | |
| 57 | |
| 58 | def load_data(dataset_name: str, cola_name: str, colb_name: str) -> np.mat: |
| 59 | """ |
| 60 | Function used for loading data from the seaborn splitting into x and y points |
| 61 | """ |
| 62 | import seaborn as sns |
| 63 | |
| 64 | data = sns.load_dataset(dataset_name) |
| 65 | col_a = np.array(data[cola_name]) # total_bill |
| 66 | col_b = np.array(data[colb_name]) # tip |
| 67 | |
| 68 | mcol_a = np.mat(col_a) |
| 69 | mcol_b = np.mat(col_b) |
| 70 | |
| 71 | m = np.shape(mcol_b)[1] |
| 72 | one = np.ones((1, m), dtype=int) |
| 73 | |
| 74 | # horizontal stacking |
| 75 | training_data = np.hstack((one.T, mcol_a.T)) |
| 76 | |
| 77 | return training_data, mcol_b, col_a, col_b |
| 78 | |
| 79 | |
| 80 | def get_preds(training_data: np.mat, mcol_b: np.mat, tau: float) -> np.ndarray: |
no outgoing calls
no test coverage detected