### Configure Mojmelo Setup Task in Pixi Source: https://yetalit.github.io/Mojmelo/docs/Mojmelo/index Defines a 'setup' task in 'pixi.toml' to install Mojmelo from source. This involves navigating to the Mojmelo directory and running the 'setup.mojo' script with various arguments. ```toml [tasks] setup = """ cd && mojo ./setup.mojo && mojo ./setup.mojo 1 && mojo ./setup.mojo 2 && mojo ./setup.mojo 3 && mojo ./setup.mojo 4 && mojo ./setup.mojo 5 && mojo ./setup.mojo 6 && mojo ./setup.mojo 7 && mojo ./setup.mojo 8 && mojo ./setup.mojo 9""" ``` -------------------------------- ### Run Mojmelo Setup from Source using Pixi Source: https://yetalit.github.io/Mojmelo/docs/Mojmelo/index Executes the custom 'setup' task defined in 'pixi.toml' to install Mojmelo from its source code. This command triggers the execution of the 'setup.mojo' script. ```bash pixi run setup ``` -------------------------------- ### Run Mojmelo Setup Script Source: https://yetalit.github.io/Mojmelo/docs/Mojmelo/index Executes the setup script for Mojmelo, which may include benchmarking and configuration steps. This script is typically found within the Pixi environment's conda test files. ```bash bash ./.pixi/envs/default/etc/conda/test-files/mojmelo/0/tests/setup.sh ``` -------------------------------- ### Install Mojmelo using Pixi CLI Source: https://yetalit.github.io/Mojmelo/docs/Mojmelo/index This command adds the 'mojmelo' package to your project's dependencies using the Pixi CLI. Ensure the Modular community channel is configured in your 'pixi.toml'. ```bash pixi add mojmelo ``` -------------------------------- ### Create Linspace Matrix Source: https://yetalit.github.io/Mojmelo/docs/utils/Matrix/Matrix Creates a matrix with values evenly spaced between a start and stop point. This static method requires the start, stop, number of points, and optionally an order parameter. ```Rust @staticmethod fn linspace(start: Float32, stop: Float32, num: Int, order: String = "c") -> Self ``` -------------------------------- ### Matrix Shape and Stride (`shape`, `stride`) Source: https://yetalit.github.io/Mojmelo/docs/utils/mojmelo_matmul/matmul/Matrix Methods to get the shape and stride information of the matrix. ```APIDOC ### `shape` Returns the size of the matrix along a specified dimension. ```mojo fn shape[dim: Int](self) -> Int ``` **Parameters:** - **dim** (`Int`) - The dimension (0 for rows, 1 for columns) for which to get the size. **Args:** - **self** (`Self`) - The Matrix instance. **Returns:** - `Int` - The size of the matrix along the specified dimension. ### `stride` Returns the stride of the matrix along a specified dimension. ```mojo fn stride[dim: Int](self) -> Int ``` **Parameters:** - **dim** (`Int`) - The dimension (0 for rows, 1 for columns) for which to get the stride. **Args:** - **self** (`Self`) - The Matrix instance. **Returns:** - `Int` - The stride of the matrix along the specified dimension. ``` -------------------------------- ### Get Data (`get_data`) Source: https://yetalit.github.io/Mojmelo/docs/utils/libsvm/svm/Cache Retrieves data from the cache at a specific index. ```APIDOC ## GET /cache/get_data ### Description Retrieves data from the cache at a specified index. This operation may modify the cache's LRU status. ### Method GET ### Endpoint /cache/get_data ### Parameters #### Query Parameters - **index** (`Int`) - Required - The index of the data to retrieve. - **data** (`UnsafePointer[UnsafePointer[Float32, MutExternalOrigin], MutAnyOrigin]`) - Required - A pointer to where the retrieved data should be stored. - **_len** (`Int`) - Required - The length of the data buffer to be filled. ### Request Example ```json { "index": 5, "data": "", "_len": 100 } ``` ### Response #### Success Response (200) - **Int** - The number of bytes successfully read. #### Response Example ```json { "bytes_read": 50 } ``` ``` -------------------------------- ### HDBSCAN Initialization Source: https://yetalit.github.io/Mojmelo/docs/HDBSCAN/HDBSCAN Initializes the HDBSCAN struct with various parameters to control the clustering process. Default values are provided for most parameters, allowing for quick setup or fine-grained control over the clustering behavior. ```mojo fn __init__(out self, min_samples: Int = 5, min_cluster_size: Int = 5, cluster_selection_method: String = "eom", alpha: Float32 = 1, cluster_selection_epsilon: Float32 = 0, cluster_selection_epsilon_max: Float32 = inf[DType.float32](), cluster_selection_persistence: Float32 = 0, max_cluster_size: Int = 0, allow_single_cluster: Bool = False, match_reference_implementation: Bool = False, search_deepness_coef: Int = 1) __ ``` -------------------------------- ### KDTreeBoruvka Node Building Source: https://yetalit.github.io/Mojmelo/docs/utils/hdbscan/KDTreeBoruvka/KDTreeBoruvka The `build_node` method recursively builds a node in the KDTreeBoruvka, processing data within the specified range (`start` to `end`) for the given node index. ```mojo fn build_node(mut self, node: Int, start: Int, end: Int) __ **Args:** * **self** (`Self`) * **node** (`Int`) * **start** (`Int`) * **end** (`Int`) ``` -------------------------------- ### KDTreeBoruvka Split Dimension Choice Source: https://yetalit.github.io/Mojmelo/docs/utils/hdbscan/KDTreeBoruvka/KDTreeBoruvka The `choose_split_dim` method determines the optimal dimension to split the data within a given range (`start` to `end`) using the provided index list. ```mojo fn choose_split_dim(self, start: Int, end: Int, idx: List[Scalar[DType.index]]) -> Int __ **Args:** * **self** (`Self`) * **start** (`Int`) * **end** (`Int`) * **idx** (`List`) **Returns:** `Int` ``` -------------------------------- ### Import Utility Modules in Mojo Source: https://yetalit.github.io/Mojmelo/docs/Mojmelo/index Shows how to import utility classes and functions from the 'mojmelo.utils' package. This includes the 'Matrix' class and other functions imported with a wildcard. ```mojo from mojmelo.utils.Matrix import Matrix from mojmelo.utils.utils import * ``` -------------------------------- ### Matrix Initialization (`__init__`) Source: https://yetalit.github.io/Mojmelo/docs/utils/mojmelo_matmul/matmul/Matrix Details the different ways to initialize a Matrix object. ```APIDOC ## Methods: Matrix ### `__init__` Initializes a new Matrix object. #### Overload 1 ```mojo fn __init__(out self, shape: Tuple[Int, Int]) ``` **Args:** - **shape** (`Tuple`) - A tuple representing the desired shape (rows, columns) of the matrix. - **self** (`Self`) - The instance of the Matrix to initialize. **Returns:** - `Self` - The initialized Matrix object. #### Overload 2 ```mojo fn __init__(out self, data: UnsafePointer[Scalar[Type], MutAnyOrigin], var layout: Layout) ``` **Args:** - **data** (`UnsafePointer`) - A pointer to the existing data for the matrix. - **layout** (`Layout`) - The memory layout to be used for the matrix. - **self** (`Self`) - The instance of the Matrix to initialize. **Returns:** - `Self` - The initialized Matrix object. #### Overload 3 ```mojo fn __init__(out self, data: UnsafePointer[Scalar[Type], MutAnyOrigin], shape: Tuple[Int, Int]) ``` **Args:** - **data** (`UnsafePointer`) - A pointer to the existing data for the matrix. - **shape** (`Tuple`) - A tuple representing the shape (rows, columns) of the matrix. - **self** (`Self`) - The instance of the Matrix to initialize. **Returns:** - `Self` - The initialized Matrix object. ``` -------------------------------- ### KDTreeBoruvka Initialization Source: https://yetalit.github.io/Mojmelo/docs/utils/hdbscan/KDTreeBoruvka/KDTreeBoruvka The `__init__` method for KDTreeBoruvka. It initializes the k-d tree with provided data, minimum samples, leaf size, and search depth coefficient. ```mojo fn __init__(out self, data: Matrix, min_samples: Int, leaf_size: Int, search_deepness_coef: Int) __ **Args:** * **data** (`Matrix`) * **min_samples** (`Int`) * **leaf_size** (`Int`) * **search_deepness_coef** (`Int`) * **self** (`Self`) **Returns:** `Self` **Raises:** ``` -------------------------------- ### Get Cluster Tree Leaves Source: https://yetalit.github.io/Mojmelo/docs/utils/hdbscan/hdbscan_tree/get_cluster_tree_leaves Retrieves the leaf nodes from a given cluster tree structure. ```APIDOC ## get_cluster_tree_leaves ### Description Retrieves the leaf nodes from a given cluster tree structure. ### Method POST ### Endpoint /websites/yetalit_github_io_mojmelo/get_cluster_tree_leaves ### Parameters #### Request Body - **cluster_tree** (Dict) - Required - A dictionary representing the cluster tree. Keys are strings, and values are lists of scalar indices. ### Request Example ```json { "cluster_tree": { "cluster1": [1, 2, 3], "cluster2": [4, 5] } } ``` ### Response #### Success Response (200) - **leaves** (List) - A list of scalar indices representing the leaves of the cluster tree. #### Response Example ```json { "leaves": [1, 2, 3, 4, 5] } ``` ``` -------------------------------- ### Mojo Solver Initialization and Status Checks Source: https://yetalit.github.io/Mojmelo/docs/utils/libsvm/svm/Solver Provides methods for initializing the 'Solver' struct and checking the status of elements (lower bound, upper bound, free). These are fundamental operations for managing the state of the optimization problem. ```mojo fn __init__(out self) -> Self __ fn get_C(self, i: Int) -> Float64 __ fn update_alpha_status(self, i: Int) __ fn is_upper_bound(self, i: Int) -> Bool __ fn is_lower_bound(self, i: Int) -> Bool __ fn is_free(self, i: Int) -> Bool __ ``` -------------------------------- ### Get Coefficient C in Mojo Source: https://yetalit.github.io/Mojmelo/docs/utils/libsvm/svm/Solver_NU The get_C method retrieves the coefficient C for a given index i from the Solver_NU struct. ```mojo fn get_C(self, i: Int) -> Float64: # Implementation details for getting C pass ``` -------------------------------- ### SearchRecord Initialization Source: https://yetalit.github.io/Mojmelo/docs/utils/KDTree/SearchRecord Documentation for the `__init__` method of the SearchRecord struct, detailing its parameters and return type. ```APIDOC ## Method: SearchRecord.__init__ ### Description Initializes a new `SearchRecord` instance. ### Method `__init__` ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body * **qv_in** (`Span`) - Input span for the query vector. * **tree_in** (`KDTree`) - The KD-tree to search within. * **result_in** (`KDTreeResultVector`) - The vector to store search results. * **self** (`Self`) - The instance of `SearchRecord` being initialized. ### Request Example ```python # Example usage (conceptual, actual types may vary) # search_record = SearchRecord(qv_in=span_data, tree_in=kd_tree, result_in=result_vector) ``` ### Response #### Success Response (200) * **Self** (`Self`) - The newly initialized `SearchRecord` instance. ``` -------------------------------- ### Get QD Vector in Mojo Source: https://yetalit.github.io/Mojmelo/docs/utils/libsvm/svm/SVC_Q Retrieves the QD vector from the SVC_Q struct. This method does not require mutable access. ```mojo fn get_QD(self) -> UnsafePointer[Float64, MutExternalOrigin]: # Implementation details for getting QD vector pass ``` -------------------------------- ### Get Mojo Matrix Stride Source: https://yetalit.github.io/Mojmelo/docs/utils/mojmelo_matmul/matmul/Matrix Implements the `stride` method for the `Matrix` struct, returning the stride for a specified dimension index. ```mojo fn stride[dim: Int](self) -> Int __ **Parameters:** * **dim** (`Int`) **Args:** * **self** (`Self`) **Returns:** `Int` ``` -------------------------------- ### Mojo KNN Constructor (__init__) Source: https://yetalit.github.io/Mojmelo/docs/KNN/KNN Initializes the KNN classifier. It can be initialized with default values for k and metric, or by providing a dictionary of parameters. ```mojo fn __init__(out self, k: Int = 3, metric: String = "euc") __ **Args:** * **k** (`Int`) * **metric** (`String`) * **self** (`Self`) **Returns:** `Self` **Raises:** ``` fn __init__(out self, params: Dict[String, String]) __ **Args:** * **params** (`Dict`) * **self** (`Self`) **Returns:** `Self` **Raises:** ``` -------------------------------- ### Get QD Data in SVR_Q Struct in Mojo Source: https://yetalit.github.io/Mojmelo/docs/utils/libsvm/svm/SVR_Q The `get_QD` method retrieves a pointer to the QD data from the SVR_Q struct. ```mojo fn get_QD(self) -> UnsafePointer[Float64, MutExternalOrigin] __ # Args: # self (Self) # Returns: # UnsafePointer __ ``` -------------------------------- ### PCA Initialization and Fields Source: https://yetalit.github.io/Mojmelo/docs/PCA/PCA Details on how to initialize the PCA struct and a description of its available fields. ```APIDOC ## PCA Struct ### Description Principal component analysis (PCA). Linear dimensionality reduction using Singular Value Decomposition of the data to project it to a lower dimensional space. ### Fields - **n_components** (`Int`): Number of components to keep. - **components** (`Matrix`) - **components_T** (`Matrix`) - **explained_variance** (`Matrix`): The amount of variance explained by each of the selected components. - **explained_variance_ratio** (`Matrix`): Percentage of variance explained by each of the selected components. - **mean** (`Matrix`) - **whiten** (`Bool`): To transform data to have zero mean, unit variance, and no correlation between features. - **whiten_** (`Matrix`) - **lapack** (`Bool`): Use LAPACK to calculate svd. ``` -------------------------------- ### Get Mojo Matrix Shape Source: https://yetalit.github.io/Mojmelo/docs/utils/mojmelo_matmul/matmul/Matrix Implements the `shape` method for the `Matrix` struct, which returns the dimension size for a specified dimension index. ```mojo fn shape[dim: Int](self) -> Int __ **Parameters:** * **dim** (`Int`) **Args:** * **self** (`Self`) **Returns:** `Int` ``` -------------------------------- ### GBDT Initialization in Mojo Source: https://yetalit.github.io/Mojmelo/docs/GBDT/GBDT Provides two methods for initializing the GBDT model. The first allows direct parameter setting, while the second accepts parameters as a dictionary of strings. Both methods return the initialized GBDT instance. ```mojo fn __init__(out self, criterion: String = "log", n_trees: Int = 10, min_samples_split: Int = 10, max_depth: Int = 3, learning_rate: Float32 = 0.10000000000000001, reg_lambda: Float32 = 1, reg_alpha: Float32 = 0, gamma: Float32 = 0, n_bins: Int = 0) __ ``` ```mojo fn __init__(out self, params: Dict[String, String]) __ ``` -------------------------------- ### SIMD Load and Store (`load`, `store`) Source: https://yetalit.github.io/Mojmelo/docs/utils/mojmelo_matmul/matmul/Matrix Methods for loading and storing data using SIMD (Single Instruction, Multiple Data) operations. ```APIDOC ### `load` Loads a SIMD vector of data from the matrix at the specified indices. ```mojo fn load[width: Int, *, dim: Int](self, i: Int, j: Int) -> SIMD[Type, width] ``` **Parameters:** - **width** (`Int`) - The width of the SIMD vector to load. - **dim** (`Int`) - The dimension along which to load the SIMD vector. **Args:** - **self** (`Self`) - The Matrix instance. - **i** (`Int`) - The row index. - **j** (`Int`) - The column index. **Returns:** - `SIMD[Type, width]` - A SIMD vector containing the loaded data. ### `store` Stores a SIMD vector of data into the matrix at the specified indices. ```mojo fn store[width: Int, *, dim: Int](self, value: SIMD[Type, width], i: Int, j: Int) ``` **Parameters:** - **width** (`Int`) - The width of the SIMD vector to store. - **dim** (`Int`) - The dimension along which to store the SIMD vector. **Args:** - **self** (`Self`) - The mutable Matrix instance. - **value** (`SIMD[Type, width]`) - The SIMD vector to store. - **i** (`Int`) - The row index. - **j** (`Int`) - The column index. ``` -------------------------------- ### delTree Function Source: https://yetalit.github.io/Mojmelo/docs/DecisionTree/delTree The delTree function recursively deletes a tree structure starting from the provided node. It takes an unsafe pointer to a Node as input. ```APIDOC ## delTree Function ### Description Recursively deletes a tree structure starting from the provided node. It takes an unsafe pointer to a Node as input. ### Method N/A (This is a function definition, not an HTTP endpoint) ### Endpoint N/A ### Parameters #### Path Parameters N/A #### Query Parameters N/A #### Request Body N/A ### Request Example N/A ### Response #### Success Response (N/A) N/A #### Response Example N/A ``` -------------------------------- ### PolyRegression Initialization Source: https://yetalit.github.io/Mojmelo/docs/PolynomialRegression/PolyRegression Provides two methods for initializing the PolyRegression model. The first allows direct setting of parameters like degree, learning rate, and regularization. The second accepts parameters as a dictionary of strings. ```mojo fn __init__(out self, degree: Int = 2, learning_rate: Float32 = 0.01, n_iters: Int = 1000, reg_alpha: Float32 = 0, l1_ratio: Float32 = 0, tol: Float32 = 0, batch_size: Int = 0, random_state: Int = -1) ``` ```mojo fn __init__(out self, params: Dict[String, String]) ``` -------------------------------- ### Get Data from Cache Source: https://yetalit.github.io/Mojmelo/docs/utils/libsvm/svm/Cache Retrieves data from the 'Cache' at a specified 'index'. It populates the provided 'data' pointer and returns the length of the retrieved data. ```mojo fn get_data(mut self, index: Int, data: UnsafePointer[UnsafePointer[Float32, MutExternalOrigin], MutAnyOrigin], var _len: Int) -> Int __ ``` -------------------------------- ### Get QD Vector in Mojo Source: https://yetalit.github.io/Mojmelo/docs/utils/libsvm/svm/ONE_CLASS_Q The 'get_QD' method for the 'ONE_CLASS_Q' struct in Mojo. It returns a pointer to a Float64 array representing the QD vector. ```mojo fn get_QD(self) -> UnsafePointer[Float64, MutExternalOrigin] __ **Args:** * **self** (`Self`) **Returns:** `UnsafePointer` ``` -------------------------------- ### Mojo CV __init__ Method Source: https://yetalit.github.io/Mojmelo/docs/utils/utils/CV Initializes the CV object with provided parameters. It takes a dictionary of string key-value pairs and returns the initialized object. ```mojo fn __init__(out self: _Self, params: Dict[String, String]) __ ``` -------------------------------- ### Get Max Value from KDTreeResultVector (Mojo) Source: https://yetalit.github.io/Mojmelo/docs/utils/KDTree/KDTreeResultVector The max_value method returns the maximum value currently stored in the KDTreeResultVector. It takes 'self' and returns a Float32. ```mojo fn max_value(self) -> Float32 ``` -------------------------------- ### KDTree Methods Source: https://yetalit.github.io/Mojmelo/docs/utils/KDTree/KDTree This section details the methods available for the KDTree struct, including initialization, tree building, and various nearest neighbor search operations. ```APIDOC ## KDTree Methods ### `__init__` #### Description Initializes a new KDTree. #### Method `__init__` #### Parameters - **X** (`Matrix`) - The input data matrix. - **metric** (`String`) - The distance metric to use (e.g., "euc"). Defaults to "euc". - **build** (`Bool`) - Whether to build the tree upon initialization. Defaults to `True`. - **self** (`Self`) - The KDTree instance. #### Returns `Self` - The initialized KDTree instance. ### `__moveinit__` #### Description Move-initializes a KDTree from an existing one. #### Method `__moveinit__` #### Parameters - **existing** (`Self`) - The KDTree instance to move from. - **self** (`Self`) - The KDTree instance to move to. #### Returns `Self` - The move-initialized KDTree instance. ### `__del__` #### Description Destroys the KDTree instance. #### Method `__del__` #### Parameters - **self** (`Self`) - The KDTree instance to destroy. ### `build_tree` #### Description Builds the KDTree from the existing data. #### Method `build_tree` #### Parameters - **self** (`Self`) - The KDTree instance. ### `build_tree_for_range` #### Description Builds a portion of the KDTree for a specified range. #### Method `build_tree_for_range` #### Parameters - **self** (`Self`) - The KDTree instance. - **l** (`Int`) - The lower bound of the range. - **u** (`Int`) - The upper bound of the range. - **parent** (`UnsafePointer`) - The parent node. #### Returns `UnsafePointer` - A pointer to the newly created node. ### `spread_in_coordinate` #### Description Calculates the spread of points in a specific coordinate within a given range. #### Method `spread_in_coordinate` #### Parameters - **self** (`Self`) - The KDTree instance. - **c** (`Int`) - The coordinate index. - **l** (`Int`) - The lower bound of the range. - **u** (`Int`) - The upper bound of the range. - **interv** (`interval`) - The interval to update. ### `select_on_coordinate` #### Description Selects a pivot element on a specific coordinate within a given range. #### Method `select_on_coordinate` #### Parameters - **self** (`Self`) - The KDTree instance. - **c** (`Int`) - The coordinate index. - **k** (`Int`) - The desired rank. - **l** (`Int`) - The lower bound of the range. - **u** (`Int`) - The upper bound of the range. ### `select_on_coordinate_value` #### Description Selects elements based on a value threshold on a specific coordinate. #### Method `select_on_coordinate_value` #### Parameters - **self** (`Self`) - The KDTree instance. - **c** (`Int`) - The coordinate index. - **alpha** (`Float32`) - The threshold value. - **l** (`Int`) - The lower bound of the range. - **u** (`Int`) - The upper bound of the range. #### Returns `Int` - The number of elements selected. ### `n_nearest` #### Description Finds the N nearest neighbors to a query point. #### Method `n_nearest` #### Parameters - **self** (`Self`) - The KDTree instance. - **qv** (`Span`) - The query point. - **nn** (`Int`) - The number of nearest neighbors to find. - **result** (`KDTreeResultVector`) - The vector to store the results. ### `n_nearest_around_point` #### Description Finds the N nearest neighbors around a specific point in the dataset. #### Method `n_nearest_around_point` #### Parameters - **self** (`Self`) - The KDTree instance. - **idxin** (`Int`) - The index of the reference point. - **correltime** (`Int`) - A time correlation parameter. - **nn** (`Int`) - The number of nearest neighbors to find. - **result** (`KDTreeResultVector`) - The vector to store the results. ### `r_nearest` #### Description Finds all neighbors within a given radius `r2` of a query point. #### Method `r_nearest` #### Parameters - **self** (`Self`) - The KDTree instance. - **qv** (`Span`) - The query point. - **r2** (`Float32`) - The squared radius. - **result** (`KDTreeResultVector`) - The vector to store the results. ### `r_count` #### Description Counts the number of neighbors within a given radius `r2` of a query point. #### Method `r_count` #### Parameters - **self** (`Self`) - The KDTree instance. - **qv** (`Span`) - The query point. - **r2** (`Float32`) - The squared radius. #### Returns `Int` - The count of neighbors within the radius. ### `r_nearest_around_point` #### Description Finds all neighbors within a given radius `r2` around a specific point in the dataset. #### Method `r_nearest_around_point` #### Parameters - **self** (`Self`) - The KDTree instance. - **idxin** (`Int`) - The index of the reference point. - **correltime** (`Int`) - A time correlation parameter. - **r2** (`Float32`) - The squared radius. - **result** (`KDTreeResultVector`) - The vector to store the results. ### `r_count_around_point` #### Description Counts the number of neighbors within a given radius `r2` around a specific point in the dataset. #### Method `r_count_around_point` #### Parameters - **self** (`Self`) - The KDTree instance. - **idxin** (`Int`) - The index of the reference point. - **correltime** (`Int`) - A time correlation parameter. - **r2** (`Float32`) - The squared radius. #### Returns `Int` - The count of neighbors within the radius. ``` -------------------------------- ### KDTreeBoruvka Initialization Source: https://yetalit.github.io/Mojmelo/docs/utils/hdbscan/KDTreeBoruvka/KDTreeBoruvka Initializes a KDTreeBoruvka instance with the provided data and configuration parameters. ```APIDOC ## KDTreeBoruvka `__init__` ### Description Initializes a KDTreeBoruvka instance. ### Method `__init__` ### Endpoint N/A (Constructor) ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body * **self** (`Self`) - The instance to initialize. * **data** (`Matrix`) - The input data matrix. * **min_samples** (`Int`) - The minimum number of samples required for a node. * **leaf_size** (`Int`) - The maximum number of samples in a leaf node. * **search_deepness_coef** (`Int`) - Coefficient for search deepness. ### Request Example ```python # Example usage (conceptual) # kd_tree = KDTreeBoruvka(data=my_matrix, min_samples=10, leaf_size=5, search_deepness_coef=3) ``` ### Response #### Success Response (200) * **Self** (`Self`) - The initialized KDTreeBoruvka instance. #### Response Example ```json { "instance": "KDTreeBoruvka object" } ``` ``` -------------------------------- ### Access Column Slice with Offset in Mojo Matrix Source: https://yetalit.github.io/Mojmelo/docs/utils/Matrix/Matrix Retrieves a column slice with an offset, allowing access to sub-sections of a column based on starting index. ```mojo fn __getitem__(self, offset: Bool, start_i: Int, column: Int) -> Self __ ``` -------------------------------- ### Cache Initialization (`__init__`) Source: https://yetalit.github.io/Mojmelo/docs/utils/libsvm/svm/Cache Initializes a new Cache instance with specified length and size. ```APIDOC ## POST /cache/__init__ ### Description Initializes a new Cache instance with the specified length and size. ### Method POST ### Endpoint /cache/__init__ ### Parameters #### Query Parameters - **l_** (`Int`) - Required - The initial length of the cache. - **size_** (`Scalar[DType.uindex]`) - Required - The size of the cache. ### Request Example ```json { "l_": 100, "size_": 1024 } ``` ### Response #### Success Response (200) - **Self** (`Self`) - The newly created Cache instance. #### Response Example ```json { "__class__": "Cache", "l": 100, "size": 1024, "head": "", "lru_head": "" } ``` ``` -------------------------------- ### Access Row Slice with Offset in Mojo Matrix Source: https://yetalit.github.io/Mojmelo/docs/utils/Matrix/Matrix Retrieves a row slice with an offset, allowing access to sub-sections of a row based on starting index. ```mojo fn __getitem__(self, row: Int, offset: Bool, start_i: Int) -> Self __ ``` -------------------------------- ### Initialize KMeans in Mojo Source: https://yetalit.github.io/Mojmelo/docs/KMeans/KMeans Initializes the KMeans struct with specified parameters. Allows configuration of the number of clusters (K), initialization method (init), maximum iterations (max_iters), convergence criteria (converge), tolerance (tol), and random state for reproducibility. ```mojo fn __init__(out self, K: Int = 5, init: String = "kmeans++", max_iters: Int = 100, converge: String = "centroid", tol: Float32 = 1.0E-4, random_state: Int = 42): self.K = K self.init = init self.max_iters = max_iters self.converge = converge self.tol = tol # Initialize other fields as needed, e.g., self.labels = [] # Note: random_state is often used internally for initialization and not stored directly as a field in this example. __ ``` -------------------------------- ### Get Q Matrix Row in Mojo Source: https://yetalit.github.io/Mojmelo/docs/utils/libsvm/svm/SVC_Q Retrieves a specific row of the Q matrix from the SVC_Q struct. This method requires mutable access to the struct. ```mojo fn get_Q(mut self, i: Int, _len: Int) -> UnsafePointer[Float32, MutExternalOrigin]: # Implementation details for getting Q matrix row pass ``` -------------------------------- ### Initialize RandomForest with Parameters in Mojo Source: https://yetalit.github.io/Mojmelo/docs/RandomForest/RandomForest Provides two methods for initializing a RandomForest object. The first allows initialization with explicit parameters like n_trees, min_samples_split, max_depth, n_feats, criterion, and random_state. The second method initializes using a dictionary of string parameters. ```mojo fn __init__(out self, n_trees: Int = 10, min_samples_split: Int = 2, max_depth: Int = 100, n_feats: Int = -1, criterion: String = "gini", random_state: Int = 42) ``` ```mojo fn __init__(out self, params: Dict[String, String]) ``` -------------------------------- ### Get Length of KDTreeResultVector (Mojo) Source: https://yetalit.github.io/Mojmelo/docs/utils/KDTree/KDTreeResultVector The __len__ method returns the number of elements currently stored in the KDTreeResultVector. It takes 'self' and returns an Int representing the length. ```mojo fn __len__(self) -> Int ``` -------------------------------- ### Mojo SVC Initialization Source: https://yetalit.github.io/Mojmelo/docs/SVM/SVC Provides two methods for initializing the SVC model. The first allows direct parameter setting, while the second accepts parameters as a dictionary of strings for flexible configuration. ```mojo fn __init__(out self, C: Float64 = 0, nu: Float64 = 0, kernel: String = "rbf", degree: Int = 2, gamma: Float64 = -1, coef0: Float64 = 0, cache_size: Float64 = 200, tol: Float64 = 0.001, shrinking: Bool = True, probability: Bool = False, random_state: Int = -1) __ ``` ```mojo fn __init__(out self, params: Dict[String, String]) __ ``` -------------------------------- ### PCA Methods Source: https://yetalit.github.io/Mojmelo/docs/PCA/PCA Documentation for the methods available in the PCA struct, including `__init__`, `fit`, `transform`, and `inverse_transform`. ```APIDOC ## PCA Methods ### `__init__` #### Description Initializes the PCA struct. #### Method `__init__` #### Parameters ##### Path Parameters None ##### Query Parameters None ##### Request Body - **n_components** (`Int`) - Required - Number of components to keep. - **whiten** (`Bool`) - Optional - Whether to whiten the data (default: False). - **lapack** (`Bool`) - Optional - Whether to use LAPACK for SVD (default: False). ### `fit` #### Description Fit the PCA model to the data. #### Method `fit` #### Parameters ##### Path Parameters None ##### Query Parameters None ##### Request Body - **X** (`Matrix`) - Required - The input data matrix. ### `transform` #### Description Apply dimensionality reduction to the input data. #### Method `transform` #### Parameters ##### Path Parameters None ##### Query Parameters None ##### Request Body - **X** (`Matrix`) - Required - The input data matrix to transform. #### Response ##### Success Response (200) - **Matrix** - The transformed data matrix. ### `inverse_transform` #### Description Transform the data back to its original space. #### Method `inverse_transform` #### Parameters ##### Path Parameters None ##### Query Parameters None ##### Request Body - **X_transformed** (`Matrix`) - Required - The transformed data matrix. #### Response ##### Success Response (200) - **Matrix** - The original data matrix. ``` -------------------------------- ### Get Length of SIMD Type (__len__) Source: https://yetalit.github.io/Mojmelo/docs/utils/Matrix/Matrix Returns the length (number of elements) of a SIMD type as an integer. This is a common method for determining the size of SIMD vectors. ```Rust fn __len__(self) -> Int __ ``` -------------------------------- ### Initialize Mojo Matrix Struct Source: https://yetalit.github.io/Mojmelo/docs/utils/mojmelo_matmul/matmul/Matrix Provides multiple signatures for initializing the `Matrix` struct. These include initialization with shape, with data pointer and layout, and with data pointer and shape. ```mojo fn __init__(out self, shape: Tuple[Int, Int]) __ **Args:** * **shape** (`Tuple`) * **self** (`Self`) **Returns:** `Self` ``` ```mojo fn __init__(out self, data: UnsafePointer[Scalar[Type], MutAnyOrigin], var layout: Layout) __ **Args:** * **data** (`UnsafePointer`) * **layout** (`Layout`) * **self** (`Self`) **Returns:** `Self` ``` ```mojo fn __init__(out self, data: UnsafePointer[Scalar[Type], MutAnyOrigin], shape: Tuple[Int, Int]) __ **Args:** * **data** (`UnsafePointer`) * **shape** (`Tuple`) * **self** (`Self`) **Returns:** `Self` ``` -------------------------------- ### KMeans Initialization Source: https://yetalit.github.io/Mojmelo/docs/KMeans/KMeans Initializes the KMeans model with specified parameters for clustering. ```APIDOC ## POST /kmeans ### Description Initializes the KMeans model with specified parameters for clustering. ### Method POST ### Endpoint /kmeans ### Parameters #### Query Parameters - **K** (Int) - Optional - The number of clusters to form as well as the number of centroids to generate. Defaults to 5. - **init** (String) - Optional - Method for initialization -> 'kmeans++', 'random'. Defaults to 'kmeans++'. - **max_iters** (Int) - Optional - Maximum number of iterations of the k-means algorithm for a single run. Defaults to 100. - **converge** (String) - Optional - The converge method: Change in centroids <= tol -> 'centroid'; Change in inertia <= tol -> 'inertia'; Exact change in labels -> 'label'. Defaults to 'centroid'. - **tol** (Float32) - Optional - Relative tolerance value. Defaults to 1.0E-4. - **random_state** (Int) - Optional - Random seed for reproducibility. Defaults to 42. ### Request Body This endpoint does not require a request body for initialization. ### Response #### Success Response (200) - **message** (String) - Confirmation message indicating successful initialization. #### Response Example ```json { "message": "KMeans model initialized successfully." } ``` ``` -------------------------------- ### Get Q Matrix Data in SVR_Q Struct in Mojo Source: https://yetalit.github.io/Mojmelo/docs/utils/libsvm/svm/SVR_Q The `get_Q` method retrieves a pointer to the Q matrix data for a given index `i` and length `_len`. ```mojo fn get_Q(mut self, i: Int, _len: Int) -> UnsafePointer[Float32, MutExternalOrigin] __ # Args: # self (Self) # i (Int) # _len (Int) # Returns: # UnsafePointer __ ``` -------------------------------- ### Get Q Matrix Element in Mojo Source: https://yetalit.github.io/Mojmelo/docs/utils/libsvm/svm/ONE_CLASS_Q The 'get_Q' method for the 'ONE_CLASS_Q' struct in Mojo. It retrieves a pointer to a Float32 array representing a part of the Q matrix. ```mojo fn get_Q(mut self, i: Int, _len: Int) -> UnsafePointer[Float32, MutExternalOrigin] __ **Args:** * **self** (`Self`) * **i** (`Int`) * **_len** (`Int`) **Returns:** `UnsafePointer` ``` -------------------------------- ### Mojo Solver Methods for Working Set and Gradient Operations Source: https://yetalit.github.io/Mojmelo/docs/utils/libsvm/svm/Solver Includes methods for swapping indices within the solver's state, reconstructing gradients, and selecting elements for the working set. These are crucial for iterative optimization algorithms. ```mojo fn swap_index[QM: QMatrix](self, mut Q: QM, i: Int, j: Int) __ fn reconstruct_gradient[QM: QMatrix](self, mut Q: QM) __ fn select_working_set[QM: QMatrix](self, mut Q: QM, mut out_i: Int, mut out_j: Int) -> Int __ ``` -------------------------------- ### Mojo arange Function for Scalar Index Lists Source: https://yetalit.github.io/Mojmelo/docs/utils/hdbscan/hdbscan_tree/arange Generates a list of scalar indices. It accepts integer start and stop values and returns a List of Scalar[DType.index]. ```mojo fn arange(start: Int, stop: Int) -> List[Scalar[DType.index]] __ ``` -------------------------------- ### Mojo LinearRegression Initialization Source: https://yetalit.github.io/Mojmelo/docs/LinearRegression/LinearRegression Provides two constructors for the `LinearRegression` struct. The first allows direct initialization of parameters, while the second accepts parameters as a dictionary of strings. ```mojo fn __init__(out self, learning_rate: Float32 = 0.001, n_iters: Int = 1000, reg_alpha: Float32 = 0, l1_ratio: Float32 = -1, tol: Float32 = 0, batch_size: Int = 0, random_state: Int = -1) __ ``` ```mojo fn __init__(out self, params: Dict[String, String]) __ ``` -------------------------------- ### Import Linear Regression Model in Mojo Source: https://yetalit.github.io/Mojmelo/docs/Mojmelo/index Demonstrates how to import the LinearRegression class from the 'mojmelo.LinearRegression' module in a Mojo project. ```mojo from mojmelo.LinearRegression import LinearRegression ``` -------------------------------- ### Get Components from TreeUnionFind in Mojo Source: https://yetalit.github.io/Mojmelo/docs/utils/hdbscan/hdbscan_tree/TreeUnionFind The `components` method returns a list of integers representing the disjoint components within the `TreeUnionFind` structure. It provides a snapshot of the current set partitioning. ```mojo fn components(self) -> List[Int] ``` -------------------------------- ### KDTree Tree Building Methods in Mojo Source: https://yetalit.github.io/Mojmelo/docs/utils/KDTree/KDTree Provides methods for building and managing the KDTree. `build_tree` constructs the entire tree, while `build_tree_for_range` constructs a portion of the tree within a specified range, returning a pointer to the root of the constructed subtree. ```mojo fn build_tree(mut self) __ fn build_tree_for_range(mut self, l: Int, u: Int, parent: UnsafePointer[KDTreeNode, MutAnyOrigin]) -> UnsafePointer[KDTreeNode, MutAnyOrigin] __ ``` -------------------------------- ### Get Element by Index in KDTreeResultVector (Mojo) Source: https://yetalit.github.io/Mojmelo/docs/utils/KDTree/KDTreeResultVector The __getitem__ method allows accessing an element at a specific index within the KDTreeResultVector. It takes 'self' and an 'index' (Int) and returns a KDTreeResult. ```mojo fn __getitem__(self, index: Int) -> KDTreeResult ``` -------------------------------- ### KDTreeNode Methods Source: https://yetalit.github.io/Mojmelo/docs/utils/KDTree/KDTreeNode Provides documentation for the methods available on the KDTreeNode struct, including initialization, searching, and node processing. ```APIDOC ## Methods for KDTreeNode ### `__init__` #### Description Initializes a new KDTreeNode. #### Method `fn __init__(out self, dim: Int, metric: fn(Float32) -> Float32)` #### Parameters - **dim** (Int) - The dimension to use for splitting. - **metric** (fn(Float32) -> Float32) - The metric function to be used. - **self** (Self) - The instance of the KDTreeNode being initialized. #### Returns `Self` - The initialized KDTreeNode instance. ### `search` #### Description Performs a search operation within the KD-tree starting from this node. #### Method `fn search(self, mut sr: SearchRecord)` #### Parameters - **self** (Self) - The KDTreeNode instance. - **sr** (SearchRecord) - The search record containing search criteria and results. ### `box_in_search_range` #### Description Checks if the bounding box of this node is within the current search range. #### Method `fn box_in_search_range(self, sr: SearchRecord) -> Bool` #### Parameters - **self** (Self) - The KDTreeNode instance. - **sr** (SearchRecord) - The search record. #### Returns `Bool` - True if the bounding box is within the search range, False otherwise. ### `process_terminal_node` #### Description Processes a terminal node during a search operation. #### Method `fn process_terminal_node(self, mut sr: SearchRecord)` #### Parameters - **self** (Self) - The KDTreeNode instance. - **sr** (SearchRecord) - The search record. ### `process_terminal_node_fixedball` #### Description Processes a terminal node specifically for a fixed-ball search. #### Method `fn process_terminal_node_fixedball(self, sr: SearchRecord)` #### Parameters - **self** (Self) - The KDTreeNode instance. - **sr** (SearchRecord) - The search record. ``` -------------------------------- ### Mojo arange Function for Integer Lists Source: https://yetalit.github.io/Mojmelo/docs/utils/hdbscan/hdbscan_tree/arange Generates a list of integers within a specified range. It takes a start and stop scalar value as input and returns a List of Int. ```mojo fn arange(start: Scalar[DType.index], stop: Scalar[DType.index]) -> List[Int] __ ``` -------------------------------- ### LU Decomposition and Solving Linear Systems (Rust) Source: https://yetalit.github.io/Mojmelo/docs/utils/Matrix/Matrix Provides functions for LU decomposition, solving linear systems using LU factorization, and matrix inversion. These are static methods that operate on matrices and associated data. ```Rust @staticmethod fn lu_factor(mut A, piv: UnsafePointer[Int, MutAnyOrigin], N: Int) __ ``` ```Rust @staticmethod fn lu_solve(A, piv: UnsafePointer[Int, MutAnyOrigin], b: Self, mut x: Self, N: Int, Mi: Int) __ ``` ```Rust @staticmethod fn solve(var A, b: Self) -> Self __ ``` ```Rust fn inv(self) -> Self __ ``` -------------------------------- ### Mojo PCA Initialization Source: https://yetalit.github.io/Mojmelo/docs/PCA/PCA Constructor for the PCA struct. Initializes PCA with a specified number of components and optional parameters for whitening and LAPACK usage. ```mojo fn __init__(out self, n_components: Int, whiten: Bool = False, lapack: Bool = False) ``` -------------------------------- ### Get Per Row for SIMD Types (get_per_row) Source: https://yetalit.github.io/Mojmelo/docs/utils/Matrix/Matrix Retrieves per-row data from a SIMD type, using another SIMD type as input for columns. It returns the SIMD type itself. ```Rust fn get_per_row(self, columns: Self) -> Self __ ``` -------------------------------- ### bfs_from_cluster_tree Function Source: https://yetalit.github.io/Mojmelo/docs/utils/hdbscan/hdbscan_tree/bfs_from_cluster_tree This function implements a Breadth-First Search (BFS) algorithm on a given cluster tree structure. It starts the traversal from a specified root node and returns the order of visited nodes. ```APIDOC ## bfs_from_cluster_tree ### Description Performs a Breadth-First Search (BFS) on a cluster tree starting from a given root node. ### Method N/A (This is a function definition, not an HTTP endpoint) ### Endpoint N/A ### Parameters #### Path Parameters N/A #### Query Parameters N/A #### Request Body N/A ### Request Example N/A ### Response #### Success Response (N/A) - **List** (List[Scalar[DType.index]]) - The list of visited nodes in BFS order. #### Response Example N/A ### Args: * **tree** (`Dict[String, List[Scalar[DType.index]]]`): The cluster tree represented as a dictionary where keys are node identifiers and values are lists of their neighbors. * **bfs_root** (`Scalar[DType.index]`): The starting node for the BFS traversal. ### Returns: `List[Scalar[DType.index]]`: A list containing the nodes visited during the BFS, in the order they were visited. ### Raises: (Documentation for raised exceptions is not provided in the source text.) ``` -------------------------------- ### Mojo Layout Struct Initialization Source: https://yetalit.github.io/Mojmelo/docs/utils/mojmelo_matmul/matmul/Layout Provides two constructors for the 'Layout' struct: one taking both shape and strides, and another taking only shape. Both return an instance of 'Self'. ```mojo fn __init__(shape: Tuple[Int, Int], strides: Tuple[Int, Int]) -> Self ``` ```mojo fn __init__(shape: Tuple[Int, Int]) -> Self ``` -------------------------------- ### Get SVM Type using Mojo Source: https://yetalit.github.io/Mojmelo/docs/utils/libsvm/svm/svm_get_svm_type The `svm_get_svm_type` function in Mojo takes an `svm_model` as input and returns an integer representing the SVM type. This function is useful for inspecting the properties of a trained SVM model. ```mojo fn svm_get_svm_type(model: svm_model) -> Int __ ```