package sklearn

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

Module Sklearn.NdarraySource

Sourcetype 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;; ```

Sourceval show : t -> string

### show

Pretty-print an Ndarray into a string.

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

### pp

Pretty-print the Ndarray.

Sourceval to_pyobject : t -> Py.Object.t

### to_pyobject

Convert the Ndarray to a Py.Object.t.

Sourceval of_pyobject : Py.Object.t -> t

### of_pyobject

Build an Ndarray from a Py.Object.t.

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

### of_bigarray

Build an Ndarray from a bigarray.

Sourceval shape : t -> int array

### shape

Shape (dimensions) of an Ndarray.

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

## module Ndarray.List

Sourcemodule Float : sig ... end

## module Ndarray.Float

Sourcemodule Int : sig ... end

## module Ndarray.Int

Sourcemodule String : sig ... end

## module Ndarray.String