1234567891011121314151617181920212223242526272829303132333435 |
- ;; ======================
- ;; DATA POINT ABSTRACTION
- ;; ======================
- ;; These procedures serve as an abstraction layer over the underlying data
- ;; structures used to represent data points. Make sure to only ever use these
- ;; procedures, when dealing with data points.
- (define-module (data-point))
- (use-modules
- (utils vector))
- (define-public make-data-point
- (lambda (. elems)
- (list->vector elems)))
- (define-public data-point-length vector-length)
- (define-public data-point-get-col vector-ref)
- (define-public data-point-set-col! vector-set!)
- (define-public data-point-take
- (lambda (from-data-point num)
- "Get the first n feature values of the data point."
- (let ([to-new-vec (make-vector num)])
- (vector-move-left! from-data-point 0 num to-new-vec 0)
- to-new-vec)))
- (define-public data-point-take-features
- (lambda (data-point label-column-index)
- "Take all columns of a data point except for the label column."
- (vector-take-except-ref data-point label-column-index)))
|