package sklearn

  1. Overview
  2. Docs
Legend:
Library
Module
Module type
Parameter
Class
Class type
type t

Ndarray.t represents a tensor (a multidimensional array), which can contain integers, floats and strings.

You can **build an Ndarray from an OCaml array** :

```ocaml let nda = Sklearn.Ndarray.Float.matrix | [|1;2;3|]; [|4;5;6|] | in Format.printf "%a" Ndarray.pp nda;; ```

You can also **build it from a bigarray**. This way, no data is copied, the bigarray and the Ndarray share the same memory. You may want to use the library Owl to build the bigarray (this is useful because the interface provided here is minimal).

```ocaml let module Matrix = Owl.Dense.Matrix.D in let x = Sklearn.Ndarray.of_bigarray @@ Matrix.uniform 10 3 in Format.printf "%a" Ndarray.pp x;; ```

Finally, this module provides functions for **building a Python list of Ndarrays**, which is useful for functions expecting a collection of arrays which do not have the same length (and therefore do not fit into one tensor).

```ocaml let y = Ndarray.String.vectors [|"hello"; "world"|]; [|"how"; "are"; "you"; "gentlemen"|] in Format.printf "%a" Ndarray.pp y;; ```

val show : t -> string

### show

Pretty-print an Ndarray into a string.

val pp : Format.formatter -> t -> unit

### pp

Pretty-print the Ndarray.

val to_pyobject : t -> Py.Object.t

### to_pyobject

Convert the Ndarray to a Py.Object.t.

val of_pyobject : Py.Object.t -> t

### of_pyobject

Build an Ndarray from a Py.Object.t.

val of_bigarray : ('a, 'b, 'c) Bigarray.Genarray.t -> t

### of_bigarray

Build an Ndarray from a bigarray.

val shape : t -> int array

### shape

Shape (dimensions) of an Ndarray.

module List : PyList.S with type elt := t

## module Ndarray.List

module Float : sig ... end

## module Ndarray.Float

module Int : sig ... end

## module Ndarray.Int

module String : sig ... end

## module Ndarray.String

OCaml

Innovation. Community. Security.