semvec/pypi-packages huggingface dataset:
ge 0.0.5
Utils for training models
License: apache-2.0

# ge
Utils for training models

To install:	```pip install ge```

## Overview
The `ge` package provides utility functions for evaluating and constructing formulas for fitted models, particularly useful in the context of machine learning and data analysis. The main functionalities include calculating normalized root mean square error (NRMSE), cross-validated root mean square error (CV RMSE), and generating a string representation of a model's formula with fitted parameters.

## Functions

### nrmse
Calculates the normalized root mean square error between predicted and actual data. This is used to measure the accuracy of a model, normalized by the range of the data.

**Usage:**
```python
from ge import nrmse
actual_data = [1, 2, 3, 4, 5]
predicted_data = [1.1, 1.9, 3.0, 3.9, 5.1]
error = nrmse(actual_data, predicted_data)
print("NRMSE:", error)
```

### cv_rmse
Calculates the cross-validated root mean square error between predicted and actual data, normalized by the mean of the actual data. This provides a scale-independent measure of prediction error, useful for comparing models across different datasets.

**Usage:**
```python
from ge import cv_rmse
actual_data = [1, 2, 3, 4, 5]
predicted_data = [1.1, 1.9, 3.0, 3.9, 5.1]
error = cv_rmse(actual_data, predicted_data)
print("CV RMSE:", error)
```

### formula_str
Generates a string representation of a fit function's formula with parameters injected. This is particularly useful for documenting and sharing the exact mathematical formula used in model fitting.

**Usage:**
```python
from ge import formula_str
from scipy.optimize import curve_fit

# Define a model function
def model_func(x, a, b):
    return a + b * x

# Example data
xdata = [0, 1, 2, 3, 4]
ydata = [0, 2, 4, 6, 8]

# Fit the model to the data
params, _ = curve_fit(model_func, xdata, ydata)

# Generate formula string
formula = formula_str(model_func, params)
print("Fitted formula:", formula)
```

## Installation
To install the `ge` package, use the following pip command:
```bash
pip install ge
```

This package is designed to be lightweight and easy to integrate into existing Python projects, particularly those involving data analysis and machine learning.
nj 0.0.5
Triangle plots
License: apache-2.0

# nj
Triangle plots

To install:	```pip install nj```

## Overview

The `nj` package provides tools for creating triangle plots, which are useful for visualizing and analyzing the distributions and correlations between multiple variables in a dataset. It includes functionality for plotting histograms, 2D histograms, and error ellipses, as well as enhancing plots with quantiles and truth values for comparative analysis.

## Main Features

- **corner**: Generates a corner plot (or a pair plot) that shows all the pairwise scatter plots of the variables on the off-diagonals, the histogram of each variable on the diagonal, and optionally overlays contours and points.
- **hist2d**: Plots a 2-dimensional histogram or density plot.
- **error_ellipse**: Plots an error ellipse based on a covariance matrix, useful for visualizing confidence intervals on scatter plots.

## Installation

To install `nj`, use pip:

```bash
pip install nj
```

## Usage Examples

### Creating a Corner Plot

To create a corner plot to visualize the distribution of and correlation between multiple variables:

```python
import numpy as np
import matplotlib.pyplot as plt
from nj import corner

# Generate some synthetic data
data = np.random.randn(1000, 3)  # 1000 samples of 3 variables

# Create a corner plot
fig = corner(data, labels=['X', 'Y', 'Z'], show_titles=True, quantiles=[0.16, 0.5, 0.84])
plt.show()
```

### Plotting a 2D Histogram

To plot a 2-dimensional histogram of two variables:

```python
import numpy as np
import matplotlib.pyplot as plt
from nj import hist2d

# Generate some synthetic data
x = np.random.randn(1000)
y = np.random.randn(1000)

# Create a 2D histogram
fig, ax = plt.subplots()
hist2d(x, y, ax=ax, plot_contours=True)
plt.show()
```

### Adding an Error Ellipse

To add an error ellipse to a scatter plot:

```python
import numpy as np
import matplotlib.pyplot as plt
from nj import error_ellipse

# Generate some synthetic data
data = np.random.multivariate_normal([0, 0], [[1, 0.5], [0.5, 1]], size=1000)
x, y = data.T

# Plot the data
fig, ax = plt.subplots()
ax.scatter(x, y, s=5)

# Calculate the covariance and plot the error ellipse
cov = np.cov(data, rowvar=False)
error_ellipse([0, 0], cov, ax=ax, edgecolor='red')
plt.show()
```

## Documentation

### Function: `corner`

Generates a comprehensive corner plot. This function is highly customizable with numerous parameters to adjust the appearance and behavior of the plot, including options for displaying quantiles, adjusting the histogram scaling, and plotting contours or data points.

### Function: `hist2d`

Creates a 2-dimensional histogram or density plot. This function allows for significant customization, including the choice of bin size, colormap, and whether to include contours or data points.

### Function: `error_ellipse`

Plots an error ellipse at a specified point given its covariance matrix. This function is useful for visualizing uncertainty in two-dimensional measurements.

## Contributing

Contributions to `nj` are welcome! Please feel free to submit pull requests or raise issues on the project's GitHub page.
nm 0.0.5
SOM utils
License: apache-2.0

# nm
SOM utils

To install:	```pip install nm```

## Overview
The `nm` package provides a Python implementation of Self-Organizing Maps (SOMs), a type of unsupervised learning neural network that is used to produce a low-dimensional (typically two-dimensional), discretized representation of the input space of the training samples. This implementation includes various functionalities such as data normalization, initialization methods, training processes, and visualization tools.

## Main Features
- **Normalization**: Support for data normalization which is crucial for effective SOM training.
- **Initialization Methods**: Includes PCA-based and random initialization to start the SOM training.
- **Training**: Supports both batch and sequential training methods.
- **Visualization**: Functions to visualize the SOM's codebooks and the mapping from data space to SOM space.
- **Projection**: Ability to project new data onto the trained SOM.
- **Clustering**: Utilize the trained SOM for clustering data.
- **Utility Functions**: Additional functions for data denormalization, finding k-nearest nodes, etc.

## Usage

### Initialization
To create a SOM instance:
```python
from nm import SOM
som = SOM(name="My_SOM", Data=my_data, mapsize=[20, 30], norm_method='var', initmethod='pca', neigh='Gaussian')
```

### Training
To train the SOM:
```python
som.train(n_job=1, shared_memory='no', verbose='on')
```

### Visualization
To visualize the trained SOM:
```python
som.view_map(what='codebook', which_dim='all', pack='Yes', text_size=10, save='No', grid='Yes', text='Yes')
```

### Project Data
To project new data onto the trained SOM and find the best matching units (BMUs):
```python
new_data_projection = som.project_data(new_data)
```

### Clustering
To perform clustering on the map nodes:
```python
cluster_labels = som.cluster(method='Kmeans', n_clusters=8)
```

### Prediction
To predict using the trained SOM:
```python
predicted_values = som.predict(X_test)
```

## Documentation
Each function in the SOM class is well documented with docstrings, providing details on the parameters, the expected inputs, and outputs. Users are encouraged to refer to these docstrings for more detailed usage instructions.

## Installation
This package can be installed using pip:
```bash
pip install nm
```

## Requirements
This package depends on several external libraries including:
- NumPy
- Matplotlib
- Scikit-learn
- Joblib
- NumExpr
- SciPy

Ensure these are installed in your Python environment to use `nm` package effectively.
kr 0.0.5
Utils to work with json
License: apache-2.0

# kr
Utils to work with json

To install:	```pip install kr```

## Overview
The `kr` package provides utility functions to handle JSON data, specifically focusing on error handling and reporting. It includes functions to convert error objects into dictionary or JSON format, optionally including traceback information to aid in debugging.

## Features
- **Error Object Serialization**: Convert exceptions and errors into a more readable and structured JSON format.
- **Traceback Inclusion**: Option to include traceback details in the serialized error output, which can be very helpful for debugging.

## Functions

### `get_dict_of_error_object(error_object, with_traceback=True)`
Converts an error object into a dictionary with keys for the error type and message. Optionally includes a traceback if `with_traceback` is set to `True`.

#### Parameters:
- **error_object**: The exception object to serialize.
- **with_traceback** (optional): Boolean flag to determine if traceback information should be included. Defaults to `True`.

#### Returns:
- A dictionary containing the error type, message, and optionally the traceback.

#### Example:
```python
try:
    1 / 0
except Exception as e:
    error_info = get_dict_of_error_object(e)
    print(error_info)
```

### `get_json_of_error_object(error_object)`
Converts an error object into a JSON string by utilizing `get_dict_of_error_object`.

#### Parameters:
- **error_object**: The exception object to serialize.

#### Returns:
- A JSON string representation of the error object.

#### Example:
```python
try:
    1 / 0
except Exception as e:
    error_json = get_json_of_error_object(e)
    print(error_json)
```

## Installation
Install the package using pip:
```bash
pip install kr
```

This package can be a useful tool in applications where error handling and reporting are crucial, especially in environments where JSON is the preferred format for data interchange.