Skip to content

Data

Structs

struct StandardScaler

StandardScaler (inverse transform only).

Mean of 0 and standard deviation of 1.

This is not a full StandardScaler implementation. It is only designed to load a "fit" sklearn StandardScaler object from Python that can then be used to inverse_transform_point points from the scaled space back to the original space. The pattern of use here would be to do the data analysis and machine learning in Python using sklearn, then load only the needed data into Mojo for real-time processing.

Traits: AnyType, Copyable, ImplicitlyDestructible, Movable


StandardScaler Functions

struct StandardScaler . fn init

Initializes the StandardScaler struct. If a sklearn_path is provided, it will attempt to load a fitted sklearn StandardScaler object from Python. The StandardScaler object must have been fit in Python before saving, and should be saved from Python using joblib.dump(scaler, path).

fn init Signature

__init__(out self, sklearn_path: Optional[String] = None)

fn init Arguments

Name Type Default Description
sklearn_path Optional[String] None

fn init Returns : Self

Static Method

This is a static method.

struct StandardScaler . fn load_from_sklearn

Loads StandardScaler data from a fitted sklearn StandardScaler object saved with joblib. The StandardScaler object must have been fit in Python before saving, and should be saved from Python using joblib.dump(scaler, path).

fn load_from_sklearn Signature

load_from_sklearn(mut self, path_joblib: String)

fn load_from_sklearn Arguments

Name Type Default Description
path_joblib String Path to a joblib file containing a fitted sklearn StandardScaler object.

struct StandardScaler . fn inverse_transform_point

Inverse transform a single point from scaled space back to original space. Nothing is returned, the result is written to the output list.

fn inverse_transform_point Signature

inverse_transform_point(mut self, input: List[Float64], mut output: List[Float64])

fn inverse_transform_point Arguments

Name Type Default Description
input List[Float64] List of length d (original dimensionality) in scaled space.
output List[Float64] List of length d (original dimensionality) that will be filled with the result.

struct StandardScaler . fn transform_point

Transform a single point from original space to scaled space. Nothing is returned, the result is written to the output list.

fn transform_point Signature

transform_point(mut self, input: List[Float64], mut output: List[Float64])

fn transform_point Arguments

Name Type Default Description
input List[Float64] List of length d (original dimensionality) in original space.
output List[Float64] List of length d (original dimensionality) that will be filled with the result in scaled space.

struct PCA

Principle Component Analysis (PCA) (inverse transform only).

This is not a full PCA implementation. It is only designed to load a "fit" sklearn PCA from Python that can then be used to inverse_transform_point points from the PCA space back to the original space. The pattern of use here would be to do the data analysis and machine learning in Python using sklearn, then load only the needed data into Mojo for real-time processing.

Traits: AnyType, Copyable, ImplicitlyDestructible, Movable


PCA Functions

struct PCA . fn init

Initializes the PCA struct. If a joblib_path is provided, it will attempt to load the PCA data from a sklearn PCA object saved with joblib. The PCA object must have been fit in Python before saving, and should be saved from Python using joblib.dump(pca, path).

fn init Signature

__init__(out self, joblib_path: Optional[String] = None)

fn init Arguments

Name Type Default Description
joblib_path Optional[String] None Optional path to a joblib file containing a fitted sklearn PCA object.

fn init Returns : Self

Static Method

This is a static method.

struct PCA . fn load_from_sklearn

Loads PCA data from a sklearn PCA object saved with joblib. The PCA object must have been fit in Python before saving, and should be saved from Python using joblib.dump(pca, path).

fn load_from_sklearn Signature

load_from_sklearn(mut self, joblib_path: String)

fn load_from_sklearn Arguments

Name Type Default Description
joblib_path String Path to a joblib file containing a fitted sklearn PCA object.

struct PCA . fn transform_point

Transform a single point from original space to PCA space. Nothing is returned, the result is written to the output list.

fn transform_point Signature

transform_point(mut self, input: List[Float64], mut output: List[Float64])

fn transform_point Arguments

Name Type Default Description
input List[Float64] List of length d (original dimensionality).
output List[Float64] List of length k (number of principal components kept) that will be filled with the result.

struct PCA . fn inverse_transform_point

Inverse transform a single point from PCA space back to original space. Nothing is returned, the result is written to the output list.

fn inverse_transform_point Signature

inverse_transform_point(mut self, input: List[Float64], mut output: List[Float64])

fn inverse_transform_point Arguments

Name Type Default Description
input List[Float64] List of length k (number of principal components kept).
output List[Float64] List of length d (original dimensionality) that will be filled with the result.

Documentation generated with mojo doc from Mojo version 1.0.0b1