diff --git a/docs/examples/classification.md b/docs/examples/classification.md new file mode 100644 index 0000000..994cef7 --- /dev/null +++ b/docs/examples/classification.md @@ -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)) +``` diff --git a/docs/examples/classification.rst b/docs/examples/classification.rst deleted file mode 100644 index c3a9a2a..0000000 --- a/docs/examples/classification.rst +++ /dev/null @@ -1,11 +0,0 @@ -.. _classification_example: - -Classification Example -====================== - -This example demonstrates how use Classification module from the `mambular` package. - - -.. literalinclude:: ../../examples/example_classification.py - :language: python - :linenos: \ No newline at end of file diff --git a/docs/examples/distributional.rst b/docs/examples/distributional.rst index 592b4f7..52ecf0e 100644 --- a/docs/examples/distributional.rst +++ b/docs/examples/distributional.rst @@ -1,7 +1,7 @@ .. _dist_example: -Distributional Example -====================== +Distributional +============== This example demonstrates how use Distributional from the `mambular` package. diff --git a/docs/examples/embedding.rst b/docs/examples/embedding.rst index 63c991d..c838585 100644 --- a/docs/examples/embedding.rst +++ b/docs/examples/embedding.rst @@ -1,7 +1,7 @@ .. _embedding_example: -Embedding Example -================= +Embedding +========= This example demonstrates how use Embedding from the `mambular` package. diff --git a/docs/examples/regression.rst b/docs/examples/regression.rst index 25048ac..00c671a 100644 --- a/docs/examples/regression.rst +++ b/docs/examples/regression.rst @@ -1,7 +1,7 @@ .. _regression_example: -Regression Example -================== +Regression +========== This example demonstrates how use Regression module from the `mambular` package. diff --git a/docs/index.rst b/docs/index.rst index f3b7ad1..8432b8d 100644 --- a/docs/index.rst +++ b/docs/index.rst @@ -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::