Skip to content

Commit

Permalink
docs update
Browse files Browse the repository at this point in the history
  • Loading branch information
mkumar73 committed May 27, 2024
1 parent 8b3be33 commit 4c424fb
Show file tree
Hide file tree
Showing 6 changed files with 73 additions and 21 deletions.
62 changes: 62 additions & 0 deletions docs/examples/classification.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
# Classification

This example demonstrates how use Classification module from the `mambular` package.

```python
import numpy as np
import pandas as pd
from sklearn.model_selection import train_test_split
from mambular.models import MambularClassifier
# Set random seed for reproducibility
np.random.seed(0)
```

Let's generate some random data to use for classification.

```python
# Number of samples
n_samples = 1000
n_features = 5
```

Generate random features

```python
X = np.random.randn(n_samples, n_features)
coefficients = np.random.randn(n_features)
```

Generate target variable

```python
y = np.dot(X, coefficients) + np.random.randn(n_samples)
## Convert y to multiclass by categorizing into quartiles
y = pd.qcut(y, 4, labels=False)
```

Create a DataFrame to store the data

```python
data = pd.DataFrame(X, columns=[f"feature_{i}" for i in range(n_features)])
data["target"] = y
```

Split data into features and target variable
```python
X = data.drop(columns=["target"])
y = data["target"].values

X_train, X_test, y_train, y_test = train_test_split(
X, y, test_size=0.2, random_state=42
)
```

Instantiate the classifier and fit the model on training data
```python
classifier = MambularClassifier()

# Fit the model on training data
classifier.fit(X_train, y_train, max_epochs=10)

print(classifier.evaluate(X_test, y_test))
```
11 changes: 0 additions & 11 deletions docs/examples/classification.rst

This file was deleted.

4 changes: 2 additions & 2 deletions docs/examples/distributional.rst
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
.. _dist_example:

Distributional Example
======================
Distributional
==============

This example demonstrates how use Distributional from the `mambular` package.

Expand Down
4 changes: 2 additions & 2 deletions docs/examples/embedding.rst
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
.. _embedding_example:

Embedding Example
=================
Embedding
=========

This example demonstrates how use Embedding from the `mambular` package.

Expand Down
4 changes: 2 additions & 2 deletions docs/examples/regression.rst
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
.. _regression_example:

Regression Example
==================
Regression
==========

This example demonstrates how use Regression module from the `mambular` package.

Expand Down
9 changes: 5 additions & 4 deletions docs/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,12 @@
.. toctree::
:name: API Reference
:caption: API Reference
:maxdepth: 1
:maxdepth: 2
:hidden:

api/models/index
api/base_models/index
api/utils/index
api/models/Models
api/base_models/BaseModels
api/utils/Preprocessor


.. toctree::
Expand Down

0 comments on commit 4c424fb

Please sign in to comment.