Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added Stratified Sampling instead of Monte Carlo Sampling #742

Open
wants to merge 43 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
43 commits
Select commit Hold shift + click to select a range
f8d7125
Initial Commit with code of Stratified Sampling Algorithm
rashidrao-pk Dec 11, 2023
ad704b5
Update README.md
rashidrao-pk Feb 8, 2024
b724ccf
Updated readme
rashidrao-pk Mar 27, 2024
fdd5c47
Updated readme
rashidrao-pk Mar 27, 2024
a75eb4f
Update README.md
rashidrao-pk Apr 1, 2024
e2062a7
Update README.md
rashidrao-pk Apr 1, 2024
0e46475
'updated_files
rashidrao-pk Oct 1, 2024
cf3a3fe
Merge branch 'master' of https://github.com/rashidrao-pk/lime_stratified
rashidrao-pk Oct 1, 2024
9aab2d0
'updated_files'
rashidrao-pk Oct 1, 2024
70a681e
'updated_files'
rashidrao-pk Oct 1, 2024
d3ccd1a
'updated_files'
rashidrao-pk Oct 1, 2024
5b0f955
'updated_files'
rashidrao-pk Oct 1, 2024
baab704
'updated'
rashidrao-pk Oct 1, 2024
6168b44
'updated_codes'
rashidrao-pk Oct 1, 2024
16cf84e
'updated_codes'
rashidrao-pk Oct 1, 2024
05ca18d
Create makefile.yml
rashidrao-pk Oct 1, 2024
43df0b8
Bump webpack-dev-server
dependabot[bot] Oct 1, 2024
57f1be2
'updated_codes'
rashidrao-pk Oct 1, 2024
e53a6b9
Merge branch 'master' of https://github.com/rashidrao-pk/lime_stratified
rashidrao-pk Oct 1, 2024
fc8eedb
Update scikit-learn requirement in the pip group across 1 directory
dependabot[bot] Oct 1, 2024
f98693d
Create python-package-conda.yml
rashidrao-pk Oct 1, 2024
f0c9762
Create codeql.yml
rashidrao-pk Oct 1, 2024
328daf2
Create greetings.yml
rashidrao-pk Oct 1, 2024
4734402
Create static.yml
rashidrao-pk Oct 1, 2024
ee466e9
'updated_codes'
rashidrao-pk Oct 1, 2024
1bf06c5
Merge branch 'master' of https://github.com/rashidrao-pk/lime_stratified
rashidrao-pk Oct 1, 2024
7444140
'updated_codes'
rashidrao-pk Oct 1, 2024
bf127ff
'updated_files'
rashidrao-pk Oct 3, 2024
cb60e80
Merge pull request #3 from rashidrao-pk/dependabot/pip/pip-bf684ffced
rashidrao-pk Oct 3, 2024
e1083c6
Merge pull request #2 from rashidrao-pk/dependabot/npm_and_yarn/lime/…
rashidrao-pk Oct 3, 2024
7f2cd94
'updated_files'
rashidrao-pk Oct 3, 2024
4918449
'updated_files'
rashidrao-pk Oct 3, 2024
65f86f8
'updated_files'
rashidrao-pk Oct 3, 2024
7defc80
'updated_files'
rashidrao-pk Oct 3, 2024
6539256
'updated_files'
rashidrao-pk Oct 3, 2024
5fab883
'updated_files'
rashidrao-pk Oct 4, 2024
8192370
'updated_files'
rashidrao-pk Oct 4, 2024
b5eadc3
Add environment.yml file
rashidrao-pk Oct 4, 2024
e6e6f5c
Add environment.yml file
rashidrao-pk Oct 4, 2024
60abaa1
Add environment.yml file
rashidrao-pk Oct 4, 2024
ee649d4
Add environment.yml file
rashidrao-pk Oct 4, 2024
4b0f98d
Add environment.yml file
rashidrao-pk Oct 4, 2024
e03f7a2
'updated_files'
rashidrao-pk Oct 7, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added .coverage
Binary file not shown.
94 changes: 94 additions & 0 deletions .github/workflows/codeql.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
# For most projects, this workflow file will not need changing; you simply need
# to commit it to your repository.
#
# You may wish to alter this file to override the set of languages analyzed,
# or to provide custom queries or build logic.
#
# ******** NOTE ********
# We have attempted to detect the languages in your repository. Please check
# the `language` matrix defined below to confirm you have the correct set of
# supported CodeQL languages.
#
name: "CodeQL Advanced"

on:
push:
branches: [ "master" ]
pull_request:
branches: [ "master" ]
schedule:
- cron: '16 19 * * 2'

jobs:
analyze:
name: Analyze (${{ matrix.language }})
# Runner size impacts CodeQL analysis time. To learn more, please see:
# - https://gh.io/recommended-hardware-resources-for-running-codeql
# - https://gh.io/supported-runners-and-hardware-resources
# - https://gh.io/using-larger-runners (GitHub.com only)
# Consider using larger runners or machines with greater resources for possible analysis time improvements.
runs-on: ${{ (matrix.language == 'swift' && 'macos-latest') || 'ubuntu-latest' }}
permissions:
# required for all workflows
security-events: write

# required to fetch internal or private CodeQL packs
packages: read

# only required for workflows in private repositories
actions: read
contents: read

strategy:
fail-fast: false
matrix:
include:
- language: javascript-typescript
build-mode: none
- language: python
build-mode: none
# CodeQL supports the following values keywords for 'language': 'c-cpp', 'csharp', 'go', 'java-kotlin', 'javascript-typescript', 'python', 'ruby', 'swift'
# Use `c-cpp` to analyze code written in C, C++ or both
# Use 'java-kotlin' to analyze code written in Java, Kotlin or both
# Use 'javascript-typescript' to analyze code written in JavaScript, TypeScript or both
# To learn more about changing the languages that are analyzed or customizing the build mode for your analysis,
# see https://docs.github.com/en/code-security/code-scanning/creating-an-advanced-setup-for-code-scanning/customizing-your-advanced-setup-for-code-scanning.
# If you are analyzing a compiled language, you can modify the 'build-mode' for that language to customize how
# your codebase is analyzed, see https://docs.github.com/en/code-security/code-scanning/creating-an-advanced-setup-for-code-scanning/codeql-code-scanning-for-compiled-languages
steps:
- name: Checkout repository
uses: actions/checkout@v4

# Initializes the CodeQL tools for scanning.
- name: Initialize CodeQL
uses: github/codeql-action/init@v3
with:
languages: ${{ matrix.language }}
build-mode: ${{ matrix.build-mode }}
# If you wish to specify custom queries, you can do so here or in a config file.
# By default, queries listed here will override any specified in a config file.
# Prefix the list here with "+" to use these queries and those in the config file.

# For more details on CodeQL's query packs, refer to: https://docs.github.com/en/code-security/code-scanning/automatically-scanning-your-code-for-vulnerabilities-and-errors/configuring-code-scanning#using-queries-in-ql-packs
# queries: security-extended,security-and-quality

# If the analyze step fails for one of the languages you are analyzing with
# "We were unable to automatically build your code", modify the matrix above
# to set the build mode to "manual" for that language. Then modify this step
# to build your code.
# ℹ️ Command-line programs to run using the OS shell.
# 📚 See https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idstepsrun
- if: matrix.build-mode == 'manual'
shell: bash
run: |
echo 'If you are using a "manual" build mode for one or more of the' \
'languages you are analyzing, replace this with the commands to build' \
'your code, for example:'
echo ' make bootstrap'
echo ' make release'
exit 1

- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v3
with:
category: "/language:${{matrix.language}}"
16 changes: 16 additions & 0 deletions .github/workflows/greetings.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
name: Greetings

on: [pull_request_target, issues]

jobs:
greeting:
runs-on: ubuntu-latest
permissions:
issues: write
pull-requests: write
steps:
- uses: actions/first-interaction@v1
with:
repo-token: ${{ secrets.GITHUB_TOKEN }}
issue-message: "Message that will be displayed on users' first issue"
pr-message: "Message that will be displayed on users' first pull request"
27 changes: 27 additions & 0 deletions .github/workflows/makefile.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
name: Makefile CI

on:
push:
branches: [ "master" ]
pull_request:
branches: [ "master" ]

jobs:
build:

runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4

- name: configure
run: ./configure

- name: Install dependencies
run: make

- name: Run check
run: make check

- name: Run distcheck
run: make distcheck
26 changes: 26 additions & 0 deletions .github/workflows/python-package-conda.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
name: Python Package Conda CI

on:
push:
branches:
- main
pull_request:
branches:
- main

jobs:
build:
runs-on: ubuntu-latest

steps:
- name: Checkout repository
uses: actions/checkout@v2

- name: Set up Miniconda
uses: conda-incubator/setup-miniconda@v2
with:
auto-update-conda: true
python-version: 3.8

- name: Install dependencies
run: conda env update --file environment.yml --name base
29 changes: 29 additions & 0 deletions .github/workflows/python-tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
name: Python Tests

on:
push:
branches: [ main ]
pull_request:
branches: [ main ]

jobs:
test:
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v2

- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: '3.8' # Change this to your desired Python version

- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install pytest pytest-cov

- name: Run tests with coverage
run: |
pytest --cov --cov-report=xml
43 changes: 43 additions & 0 deletions .github/workflows/static.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
# Simple workflow for deploying static content to GitHub Pages
name: Deploy static content to Pages

on:
# Runs on pushes targeting the default branch
push:
branches: ["master"]

# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:

# Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages
permissions:
contents: read
pages: write
id-token: write

# Allow only one concurrent deployment, skipping runs queued between the run in-progress and latest queued.
# However, do NOT cancel in-progress runs as we want to allow these production deployments to complete.
concurrency:
group: "pages"
cancel-in-progress: false

jobs:
# Single deploy job since we're just deploying
deploy:
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup Pages
uses: actions/configure-pages@v5
- name: Upload artifact
uses: actions/upload-pages-artifact@v3
with:
# Upload entire repository
path: '.'
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v4
7 changes: 4 additions & 3 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
dist: xenial
sudo: false
language: python
cache: pip
python:
- "3.6"
- "3.7"
- "3.8"
- "3.9"
# command to install dependencies
install:
- python -m pip install -U pip
- python -m pip install -e .[dev]
# command to run tests
script:
- pytest lime
- flake8 lime
- pytest lime_stratified
- flake8 lime_stratified
17 changes: 8 additions & 9 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -1,17 +1,16 @@
## Contributing
I am delighted when people want to contribute to LIME. Here are a few things to keep in mind before sending in a pull request:
I am delighted when people want to contribute to LIME_Stratified. Here are a few things to keep in mind before sending in a pull request:
* We are now using flake8 as a style guide enforcer (I plan on adding eslint for javascript soon). Make sure your code passes the default flake8 execution.
* There must be a really good reason to change the external interfaces - I want to avoid breaking previous code as much as possible.
* If you are adding a new feature, please let me know the use case and the rationale behind how you did it (unless it's obvious)

If you want to contribute but don't know where to start, take a look at the [issues page](https://github.com/marcotcr/lime/issues), or at the list below.
If you want to contribute but don't know where to start, take a look at the **[issues page](https://github.com/rashidrao-pk/lime_stratified/pulls)**, or at the list below.

# Roadmap
Here are a few high level features I want to incorporate in LIME. If you want to work incrementally in any of these, feel free to start a branch.
Here are a few high level features I want to incorporate in LIME_Stratified. If you want to work incrementally in any of these, feel free to start a branch.

1. Creating meaningful tests that we can run before merging things. Right now I run the example notebooks and the few tests we have.
2. Creating a wrapper that computes explanations for a particular dataset, and suggests instances for the user to look at (similar to what we did in [the paper](http://arxiv.org/abs/1602.04938))
3. Making LIME work with images in a reasonable time. The explanations we used in the paper took a few minutes, which is too slow.
4. Thinking through what is needed to use LIME in regression problems. An obvious problem is that features with different scales make it really hard to interpret.
5. Figuring out better alternatives to discretizing the data for tabular data. Discretizing is definitely more interpretable, but we may just want to treat features as continuous.
6. Figuring out better ways to sample around a data point for tabular data. One example is sampling columns from the training set assuming independence, or some form of conditional sampling.
1. Adding Stratification concept on other data.


## Special Thanks:
I would like to say special thanks to **`LIME`** by `Marco` for providing these files.
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,4 @@ DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
20 changes: 20 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# Minimal makefile for Sphinx documentation
#

# You can set these variables from the command line, and also
# from the environment for the first two.
SPHINXOPTS ?=
SPHINXBUILD ?= sphinx-build
SOURCEDIR = source
BUILDDIR = build

# Put it first so that "make" without argument is like "make help".
help:
@$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)

.PHONY: help Makefile

# Catch-all target: route all unknown targets to Sphinx using the new
# "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS).
%: Makefile
@$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
Loading