Quick reference =============== Field accessors and properties ------------------------------ Access to input field values: .. code:: lisp (field [] []) (f [] []) (fields ... ) (random-field-value ) (weighted-random-field-value ) (ensure-value ) (ensure-weighted-value ) All fields in a row: .. code:: lisp (all) (all-but ... ) (all-with-defaults ... ) (all-with-numeric-default ["mean" "median" "minimum" "maximum" ] Row properties: .. code:: lisp (row-number) ;; current row number, 0-based Field properties: .. code:: lisp (bin-center ) ;; number (bin-count ) ;; number (category-count ) ;; number (maximum ) ;; number (mean ) ;; number (median ) ;; number (minimum ) ;; number (missing? []) ;; boolean (missing-count ) ;; number (preferred? ) ;; boolean (population ) ;; integer (sum ) ;; number (sum-squares ) ;; number (variance ) ;; number (standard-deviation ) ;; number Normalization: .. code:: lisp (normalize [ ]) ;; [from to] defaults to [0, 1] (z-score ) (log-normal ) Percentiles and population: .. code:: lisp (percentile ) ;; number (population-fraction ) ;; integer (within-percentiles? ) ;; boolean (percentile-label ... ) Segments: .. code:: lisp (segment-label ... ) (segment-label ... ) Vectorize categorical and text fields: .. code:: lisp (vectorize []) Items: .. code:: lisp (contains-items? ... ) (equal-to-items? ... ) Regions: .. code:: lisp (region? ) (rename-region ) (add-region ) (add-region ) (remove-region ) (update-region ) (update-region ) ;; either a regions value or a regions field designator Clustering: .. code:: lisp (row-distance [ ]) (row-distance-squared [ ]) Strings and regular expressions ------------------------------- Conversion of any value to a string: .. code:: lisp (str ...) ;; string Substrings: .. code:: lisp (subs []) ;; string Regexps: .. code:: lisp (matches? ) ;; boolean (re-quote ) ;; regexp that matches literally (replace ) ;; string (replace-first ) ;; string Utilities: .. code:: lisp (length ) ;; integer (join ) ;; string (levenshtein ) ;; number (occurrences [ ]) ;; number (language ) ;; ["en", "es", "ca", "nl"] Hashing: .. code:: lisp (md5 ) ;; string of length 32 (sha1 ) ;; string of length 40 (sha256 ) ;; string of length 64 Math and logic -------------- Arithmetic operators: .. code:: lisp + - * / div mod Relational operators: .. code:: lisp < <= > >= = != Logical operators: .. code:: lisp and or not Mathematical functions: .. code:: lisp (zero? ) (even? ) (odd? ) (abs ) ;; Absolute value (acos ) (asin ) (atan ) (ceil ) (cos ) ;; := radians (cosh ) (exp ) ;; Exponential (floor ) (ln ) ;; Natural logarithm (log ) ;; Natural logarithm (log2 ) ;; Base-2 logarithm (log10 ) ;; Base-10 logarithm (max ... ) (min ... ) (mod ) ;; Modulus (div ) ;; Integer division (quotient) (pow ) (rand) ;; a random double in [0, 1) (rand-int ) ;; a random integer in [0, n) or (n, 0] (round ) (sin ) ;; := radians (sinh ) (sqrt ) (square ) ;; (* ) (tan ) ;; := radians (tanh ) (to-degrees ) ;; := radians (to-radians ) ;; := degrees (spherical-distance ) ;; args in (spherical-distance-deg ) ;; args in radians (linear-regression ... ) ;; slope, intercept, pearson (chi-square-p-value ) Fuzzy logic ----------- Basic t-norms .. code:: lisp (tnorm-min ) ;; Minimum t-norm. Also called the Gödel t-norm. (tnorm-product ) ;; Product t-norm. The ordinary product of real numbers. (tnorm-lukasiewicz ) ;; Łukasiewicz t-norm. (tnorm-drastic ) ;; Drastic t-norm (tnorm-nilpotent-min ) ;; Nilpotent minimum t-norm T-conorms: .. code:: lisp (tconorm-max ) ;; Maximum t-norm. Dual to the minimum t-norm, is the smallest t-conorm. (tconorm-probabilistic ) ;; Probabilistic t-norm. It's dual to the product t-norm. (tconorm-bounded ) ;; Bounded t-norm. It'ss dual to the Łukasiewicz t-norm. (tconorm-drastic ) ;; Drastic t-conorm. It's dual to the drastic t-norm. (tconorm-nilpotent-max ) ;; Nilpotent maximum t-conorm. It's dual to the nilpotent minumum. (tconorm-einstein-sum ) ;; Einstein t-conorm. It's a dual to one of the Hamacher t-norms. Parametric t-conorms: .. code:: lisp (tconorm-max ) ;; Maximum t-norm. Dual to the minimum t-norm, is the smallest t-conorm. (tconorm-probabilistic ) ;; Probabilistic t-norm. It's dual to the product t-norm. (tconorm-bounded ) ;; Bounded t-norm. It'ss dual to the Łukasiewicz t-norm. (tconorm-drastic ) ;; Drastic t-conorm. It's dual to the drastic t-norm. (tconorm-nilpotent-max ) ;; Nilpotent maximum t-conorm. It's dual to the nilpotent minumum. (tconorm-einstein-sum ) ;; Einstein t-conorm. It's a dual to one of the Hamacher t-norms. Coercions --------- .. code:: lisp (integer ) ;; integer (real ) ;; real ;; (integer true) = 1, (integer false) = 0 Dates and time -------------- Functions taking a number representing the *epoch*, i.e., the number of **milliseconds** since Jan 1st 1970. .. code:: lisp (epoch-year ) ;; number (epoch-month ) ;; number (epoch-week ) ;; number (epoch-day ) ;; number (epoch-weekday ) ;; number (epoch-hour ) ;; number (epoch-minute ) ;; number (epoch-second ) ;; number (epoch-millisecond ) ;; number (epoch-fields ) ;; list of numbers Any string can be coerced to an epoch: .. code:: lisp (epoch []) Conditionals and local variables -------------------------------- Conditionals: .. code:: lisp (if []) (cond ... ... ) For example: .. code:: lisp (cond (> (f "000001") (mean "000001")) "above average" (= (f "000001") (mean "000001")) "below average" "mediocre") Local variables: .. code:: lisp (let ) := ( ... ) := For example: .. code:: lisp (let (x (+ (window "a" -10 10)) a (/ (* x 3) 4.34) y (if (< a 10) "Good" "Bad")) (list x (str (f 10) "-" y) a y)) Lists ----- Creation and elememt access: .. code:: lisp (list ... ) ;; list of given values (cons ) ;; list (head ) ;; first element (tail ) ;; list sans first element (nth ) ;; 0-based nth element (take ) ;; take first elements (drop ) ;; drop first elements (drop ) ;; elements in range [from to) Inclusion: .. code:: lisp (in ) ;; boolean Properties of lists: .. code:: lisp (count ) ;; (count (list (f 1) (f 2))) => 2 (max ) ;; (max (list -1 2 -2 0.38)) => 2 (min ) ;; (min (list -1.3 2 1)) => -1.3 (avg ) ;; (avg (list -1 -2 1 2 0.8 -0.8)) => 0 (list-median ) ;; (list-median (list -1 -2 1 2 0.8 -0.8) => 1 (mode ) ;; (mode (list a b b c b a c c c)) => "c" List transformations: .. code:: lisp (map (list ... )) (filter (list ... )) (reverse ) (sort ) ;; sorts, in increasing order, a list of values Field lists and windows: .. code:: lisp (fields ... ) (window []) (diff-window ) ;; differences of consecutive values (cond-window ) ;; values that satisfy boolean sexp ;; sum of values (window-sum []) ;; mean of values (window-mean []) ;; mode of values (window-mode []) ;; median of values (window-median []) Accumulating values in cells ---------------------------- .. code:: lisp (cell ) (set-cell )