Skip to content

Commit 5055464

Browse files
author
prithagupta
committed
Added first commit to generate documents
1 parent ba0a1f4 commit 5055464

17 files changed

+872
-635
lines changed

.github/workflows/docs.yml

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
name: docs
2+
3+
# on:
4+
# # Trigger manually
5+
# workflow_dispatch:
6+
#
7+
# # Trigger on any push to the main
8+
# push:
9+
# branches:
10+
# - main
11+
# - development
12+
#
13+
# # Trigger on any push to a PR that targets main
14+
# pull_request:
15+
# branches:
16+
# - main
17+
# - development
18+
19+
permissions:
20+
contents: write
21+
22+
env:
23+
name: AutoMLQuantILDetect
24+
25+
jobs:
26+
build-and-deploy:
27+
runs-on: ubuntu-latest
28+
steps:
29+
- name: Checkout
30+
uses: actions/checkout@v3
31+
32+
- name: Setup Python
33+
uses: actions/setup-python@v4
34+
with:
35+
python-version: "3.10"
36+
37+
- name: Install dependencies
38+
run: |
39+
pip install ".[dev]"
40+
41+
- name: Make docs
42+
run: |
43+
make clean
44+
make docs
45+
46+
- name: Pull latest gh-pages
47+
if: (contains(github.ref, 'development') || contains(github.ref, 'main'))
48+
run: |
49+
cd ..
50+
git clone https://github.com/${{ github.repository }}.git --branch gh-pages --single-branch gh-pages
51+
52+
- name: Copy new docs into gh-pages
53+
if: (contains(github.ref, 'development') || contains(github.ref, 'main'))
54+
run: |
55+
branch_name=${GITHUB_REF##*/}
56+
cd ../gh-pages
57+
rm -rf $branch_name
58+
cp -r ../${{ env.name }}/docs/build/html $branch_name
59+
60+
- name: Push to gh-pages
61+
if: (contains(github.ref, 'development') || contains(github.ref, 'main'))
62+
run: |
63+
last_commit=$(git log --pretty=format:"%an: %s")
64+
cd ../gh-pages
65+
branch_name=${GITHUB_REF##*/}
66+
git add $branch_name/
67+
git config --global user.name 'Github Actions'
68+
git config --global user.email 'not@mail.com'
69+
git remote set-url origin https://x-access-token:${{ secrets.GITHUB_TOKEN }}@github.com/${{ github.repository }}
70+
git commit -am "$last_commit"
71+
git push

.readthedocs.yaml

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
# .readthedocs.yaml
2+
# Read the Docs configuration file
3+
# See https://docs.readthedocs.io/en/stable/config-file/v2.html for details
4+
5+
# Required
6+
version: 2
7+
8+
# Set the version of Python and other tools you might need
9+
build:
10+
os: ubuntu-22.04
11+
tools:
12+
python: "3.10"
13+
apt_packages:
14+
- pandoc
15+
16+
# Build documentation in the docs/ directory with Sphinx
17+
sphinx:
18+
configuration: docs/source/conf.py
19+
20+
# If using Sphinx, optionally build your docs in additional formats such as PDF
21+
# formats:
22+
# - pdf
23+
24+
# Optionally declare the Python requirements required to build your docs
25+
python:
26+
install:
27+
- requirements: docs/requirements.txt

autoqild/classifiers/layers.py

Lines changed: 45 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,67 @@
11
from keras.layers import Layer, Dense, Activation, BatchNormalization
22

33
class NormalizedDense(Layer):
4-
"""Stop training when a monitored quantity has stopped improving.
5-
# Arguments
6-
units: Positive integer, dimensionality of the output space.
7-
activation: Activation function to use
8-
(see [activations](../activations.md)).
9-
If you don't specify anything, no activation is applied
10-
(ie. "relu:).
11-
normalize_before_activation: True if normalize the inputs before applying the activation.
12-
False if activation is applied before Bach Normalization
13-
"""
144

155
def __init__(self, units, activation="relu", **kwd):
6+
"""
7+
A custom dense layer with batch normalization and optional pre-activation normalization.
8+
9+
Parameters
10+
----------
11+
units : int
12+
Positive integer, dimensionality of the output space.
13+
activation : str, optional
14+
Activation function to use (default is 'relu').
15+
If not specified, no activation is applied (i.e., "linear").
16+
normalize_before_activation : bool, optional
17+
If True, normalizes the inputs before applying the activation function.
18+
If False, applies activation before batch normalization.
19+
**kwd : dict
20+
Additional keyword arguments to pass to the `Dense` layer.
21+
"""
1622
self.dense = Dense(units, activation="linear", **kwd)
1723
self.activation = Activation(activation=activation)
1824
self.batchnorm = BatchNormalization()
1925
self.norm_layer = None
2026

2127
def __call__(self, x):
28+
"""
29+
Applies the layer to the input tensor `x`.
30+
31+
Parameters
32+
----------
33+
x : tensor
34+
Input tensor to the layer.
35+
36+
Returns
37+
-------
38+
tensor
39+
Output tensor after applying dense, activation, and batch normalization.
40+
"""
2241
return self.batchnorm(self.activation(self.dense(x)))
2342

2443
def get_weights(self):
44+
"""
45+
Returns the weights of the batch normalization and dense layers.
46+
47+
Returns
48+
-------
49+
tuple
50+
A tuple containing the weights of the batch normalization and dense layers.
51+
"""
2552
w_b = self.batchnorm.get_weights()
2653
w_d = self.dense.get_weights()
2754
return w_b, w_d
2855

2956
def set_weights(self, weights):
57+
"""
58+
Sets the weights of the batch normalization and dense layers.
59+
60+
Parameters
61+
----------
62+
weights : tuple
63+
A tuple containing the weights for the batch normalization and dense layers.
64+
"""
3065
w_b, w_d = weights
3166
self.batchnorm.set_weights(w_b)
3267
self.dense.set_weights(w_d)

autoqild/classifiers/multi_layer_perceptron.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -184,8 +184,7 @@ def fit(self, X, y, epochs=50, batch_size=32, callbacks=None, validation_split=0
184184
epochs : int, optional, default=50
185185
Number of training epochs.
186186
187-
batch_size : int, optional, default=32
188-
Number of samples per gradient update.
187+
batch_size :
189188
190189
callbacks : list of keras.callbacks.Callback, optional
191190
List of callback instances to apply during training.

autoqild/detectors/ild_base_class.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
class InformationLeakageDetector(metaclass=ABCMeta):
2525
def __init__(self, padding_name, learner_params, fit_params, hash_value, cv_iterations, n_hypothesis,
2626
base_directory, detection_method, random_state, **kwargs):
27+
2728
self.logger = logging.getLogger(InformationLeakageDetector.__name__)
2829
self.padding_name, self.padding_code = self.format_name(padding_name)
2930
self.fit_params = fit_params

autoqild/utilities/dimensionality_reduction_techniques.py

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,34 @@
77

88
# Create a dictionary to store the techniques and their options
99
def create_dimensionality_reduction_model(reduction_technique, n_reduced=20):
10+
"""
11+
Creates a dimensionality reduction model based on the specified technique.
12+
13+
Parameters
14+
----------
15+
reduction_technique : str
16+
The technique to use for dimensionality reduction. Options include:
17+
- 'recursive_feature_elimination_et': Recursive Feature Elimination with ExtraTreesClassifier.
18+
- 'recursive_feature_elimination_rf': Recursive Feature Elimination with RandomForestClassifier.
19+
- 'select_from_model_et': SelectFromModel with ExtraTreesClassifier.
20+
- 'select_from_model_rf': SelectFromModel with RandomForestClassifier.
21+
- 'pca': Principal Component Analysis.
22+
- 'lda': Linear Discriminant Analysis.
23+
- 'tsne': t-Distributed Stochastic Neighbor Embedding.
24+
- 'nmf': Non-negative Matrix Factorization.
25+
n_reduced : int, optional
26+
The number of components or features to reduce to (default is 20).
27+
28+
Returns
29+
-------
30+
object
31+
A dimensionality reduction model corresponding to the specified technique.
32+
33+
Raises
34+
------
35+
ValueError
36+
If the specified reduction technique is not defined.
37+
"""
1038
reduction_techniques = {
1139
'recursive_feature_elimination_et': RFE(ExtraTreesClassifier(), n_features_to_select=n_reduced),
1240
'recursive_feature_elimination_rf': RFE(RandomForestClassifier(), n_features_to_select=n_reduced),

0 commit comments

Comments
 (0)