|
3 | 3 | (require net/url) |
4 | 4 | (require csv-reading) |
5 | 5 | (require math/array) |
| 6 | + (require math/matrix) |
6 | 7 | (require plot) |
| 8 | + |
| 9 | +; require custom functions |
7 | 10 | (require "graphs.rkt") |
8 | | -(require "data-filitering.rkt") |
| 11 | +(require "data-filtering.rkt") |
9 | 12 |
|
10 | 13 | ;; define list of iris data directly from url |
11 | 14 | (define iris-url "https://archive.ics.uci.edu/ml/machine-learning-databases/iris/iris.data") |
12 | 15 | (define iris-raw ((compose csv->list get-pure-port string->url) iris-url)) |
13 | 16 |
|
14 | | -; function to remve last element from list, needed to remove class from iris csv to form a array |
15 | | -; and to remove the last element |
16 | | -(define (remove-last lst) |
17 | | - (reverse (cdr (reverse lst)))) |
| 17 | +; converts iris csv to a list with just numbers (stored as string), drops the last cololmn in a list |
| 18 | +; of lists |
| 19 | +(define iris-raw-num-str (filter-last-csv iris-raw)) |
18 | 20 |
|
19 | | -; function that takes a list of lists, will remove the last list in the first level and final element |
20 | | -; of all other lists |
21 | | -(define (filter-last-csv lst-of-lsts) |
22 | | - (define remove-last-lst (remove-last lst-of-lsts)) |
23 | | - (map (lambda (x) (remove-last x)) remove-last-lst)) |
| 21 | +; create a mutable NxM array of the iris dataset |
| 22 | +(define iris-array (list*->array (strlst-to-numlsts iris-raw-num-str) number?)) |
24 | 23 |
|
25 | | -; converts iris csv to a list with just numbers (stored as string) |
26 | | -(define iris-raw-num-str (filter-last-csv iris-raw)) |
| 24 | +; calculate mean and standard diviation |
| 25 | +(define iris-mean 0) |
27 | 26 |
|
28 | | -; converts a list of strings to numbers recursivly |
29 | | -(define (str-to-num-lst items) |
30 | | - (if (null? items) |
31 | | - '() |
32 | | - (cons (string->number (car items)) |
33 | | - (str-to-num-lst (cdr items))))) |
| 27 | +(define iris-std 0) |
34 | 28 |
|
35 | | -; converts a list of lists of strings to numbers using a mapping of the str-to-num-lst function |
36 | | -(define (strlst-to-numlsts lst-of-str) |
37 | | - (map (lambda (x) (str-to-num-lst x)) lst-of-str)) |
| 29 | +; function that takes a NXM array and standardizes the values (z = (x - mean) / std) |
| 30 | +(define (standardize-matrix n) 0) |
| 31 | + |
| 32 | +; calculate mean vector (mean of z) |
| 33 | +(define mean-vector 0) |
| 34 | + |
| 35 | +; create N X N matrix of containing covariance of all properties |
| 36 | +(define co-variance-matrix 0) |
| 37 | + |
| 38 | +; calculate eigenvectors and eigenvalues |
| 39 | +(define eigenvalues 0) |
| 40 | +(define eigenvectors 0) |
| 41 | + |
| 42 | +; use eigenvectors with the 2 or 3 highest eigenvalues to create projection matrix |
| 43 | + |
| 44 | +; take dot product of z and projection matrix |
| 45 | + |
| 46 | +; plot with result of dot product |
38 | 47 |
|
39 | | -; finally create a mutable NxM array of the iris dataset |
40 | | -(define iris-array (list*->array (strlst-to-numlsts iris-raw-num-str) number?)) |
41 | 48 |
|
42 | 49 | ; quick test of 3d plot |
43 | 50 | ;(plot3d (points3d (array->list* iris-array)) |
|
71 | 78 | (lambda (x) |
72 | 79 | x)) |
73 | 80 |
|
74 | | - |
75 | 81 | ;;TODO |
76 | 82 | ;;Plot a 3d graph plot graph |
77 | 83 | ;;Make a linear regression |
|
86 | 92 |
|
87 | 93 |
|
88 | 94 | ;;Some test data set for ploting |
89 | | -(define Iris-virginica (filiter (remove-last iris-raw) petal-width identity "Iris-virginica")) |
90 | | -(define Iris-versicolor (filiter (remove-last iris-raw) petal-width identity "Iris-versicolor")) |
91 | | -(define Iris-setosa (filiter (remove-last iris-raw) petal-width identity "Iris-setosa")) |
92 | | - |
93 | | - |
94 | | - |
95 | | - |
96 | | - |
97 | | - |
98 | | - |
99 | | - |
100 | | - |
101 | | - |
102 | | - |
| 95 | +;(define Iris-virginica (filiter (remove-last iris-raw) petal-width identity "Iris-virginica")) |
| 96 | +;(define Iris-versicolor (filiter (remove-last iris-raw) petal-width identity "Iris-versicolor")) |
| 97 | +;(define Iris-setosa (filiter (remove-last iris-raw) petal-width identity "Iris-setosa")) |
0 commit comments