Skip to content

Commit

Permalink
install fix
Browse files Browse the repository at this point in the history
  • Loading branch information
Larsvanderlaan committed Jan 28, 2025
1 parent e89d1a1 commit 396a819
Show file tree
Hide file tree
Showing 33 changed files with 694 additions and 93 deletions.
Binary file modified .DS_Store
Binary file not shown.
3 changes: 3 additions & 0 deletions .ipynb_checkpoints/MANIFEST-checkpoint.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
include README.md
include LICENSE
recursive-include selfcalibratingconformal *
6 changes: 6 additions & 0 deletions .ipynb_checkpoints/Untitled-checkpoint.ipynb
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"cells": [],
"metadata": {},
"nbformat": 4,
"nbformat_minor": 5
}
4 changes: 2 additions & 2 deletions .ipynb_checkpoints/setup-checkpoint.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
from setuptools import setup, find_packages

setup(
name='SelfCalibratingConformal',
version='1.0',
name='selfcalibratingconformal',
version='1.11',
packages=find_packages(),
description='A Python implementation of Self-Calibrating Conformal Prediction',
long_description='A Python implementation of Self-Calibrating Conformal Prediction',
Expand Down
137 changes: 69 additions & 68 deletions .ipynb_checkpoints/vignette-checkpoint.ipynb

Large diffs are not rendered by default.

3 changes: 3 additions & 0 deletions MANIFEST.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
include README.md
include LICENSE
recursive-include selfcalibratingconformal *
15 changes: 12 additions & 3 deletions SelfCalibratingConformal.egg-info/PKG-INFO
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Metadata-Version: 2.1
Name: SelfCalibratingConformal
Version: 1.0
Metadata-Version: 2.2
Name: selfcalibratingconformal
Version: 1.11
Summary: A Python implementation of Self-Calibrating Conformal Prediction
Home-page: https://github.com/Larsvanderlaan/SelfCalibratingConformal
Author: Lars van der Laan
Expand All @@ -16,5 +16,14 @@ Requires-Dist: scipy
Requires-Dist: statsmodels
Requires-Dist: matplotlib
Requires-Dist: xgboost
Dynamic: author
Dynamic: author-email
Dynamic: classifier
Dynamic: description
Dynamic: description-content-type
Dynamic: home-page
Dynamic: requires-dist
Dynamic: requires-python
Dynamic: summary

A Python implementation of Self-Calibrating Conformal Prediction
33 changes: 28 additions & 5 deletions SelfCalibratingConformal.egg-info/SOURCES.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,30 @@
MANIFEST.in
README.md
setup.py
SelfCalibratingConformal.egg-info/PKG-INFO
SelfCalibratingConformal.egg-info/SOURCES.txt
SelfCalibratingConformal.egg-info/dependency_links.txt
SelfCalibratingConformal.egg-info/requires.txt
SelfCalibratingConformal.egg-info/top_level.txt
selfcalibratingconformal/.DS_Store
selfcalibratingconformal/SelfCalibratingConformalPredictor.py
selfcalibratingconformal/__init__.py
selfcalibratingconformal/calibrators.py
selfcalibratingconformal/utils.py
selfcalibratingconformal.egg-info/PKG-INFO
selfcalibratingconformal.egg-info/SOURCES.txt
selfcalibratingconformal.egg-info/dependency_links.txt
selfcalibratingconformal.egg-info/requires.txt
selfcalibratingconformal.egg-info/top_level.txt
selfcalibratingconformal/.ipynb_checkpoints/SelfCalibratingConformalPredictor-checkpoint.py
selfcalibratingconformal/.ipynb_checkpoints/__init__-checkpoint.py
selfcalibratingconformal/.ipynb_checkpoints/calibrators-checkpoint.py
selfcalibratingconformal/.ipynb_checkpoints/utils-checkpoint.py
selfcalibratingconformal/__pycache__/SelfCalibratedConformalPredictor.cpython-311.pyc
selfcalibratingconformal/__pycache__/SelfCalibratedConformalPredictor.cpython-39.pyc
selfcalibratingconformal/__pycache__/SelfCalibratingConformalPredictor.cpython-311.pyc
selfcalibratingconformal/__pycache__/SelfCalibratingConformalPredictor.cpython-312.pyc
selfcalibratingconformal/__pycache__/SelfCalibratingConformalPredictor.cpython-313.pyc
selfcalibratingconformal/__pycache__/calibrators.cpython-311.pyc
selfcalibratingconformal/__pycache__/calibrators.cpython-312.pyc
selfcalibratingconformal/__pycache__/calibrators.cpython-313.pyc
selfcalibratingconformal/__pycache__/calibrators.cpython-39.pyc
selfcalibratingconformal/__pycache__/utils.cpython-311.pyc
selfcalibratingconformal/__pycache__/utils.cpython-312.pyc
selfcalibratingconformal/__pycache__/utils.cpython-313.pyc
selfcalibratingconformal/__pycache__/utils.cpython-39.pyc
2 changes: 1 addition & 1 deletion SelfCalibratingConformal.egg-info/top_level.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@

selfcalibratingconformal
Binary file modified SelfCalibratingConformal/.DS_Store
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
from statsmodels.nonparametric.kernel_regression import KernelReg
import matplotlib.pyplot as plt
# Package imports
from SelfCalibratingConformal.calibrators import *
from SelfCalibratingConformal.utils import *
from selfcalibratingconformal.calibrators import *
from selfcalibratingconformal.utils import *

class SelfCalibratingConformalPredictor:
def __init__(self, predictor: callable, calibrator = calibrator_isotonic,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
from .SelfCalibratingConformalPredictor import *
from .calibrators import *
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import numpy as np
import xgboost as xgb
from SelfCalibratingConformal.utils import *
from selfcalibratingconformal.utils import *


def calibrator_isotonic(f: np.ndarray, y: np.ndarray, max_depth=20, min_child_weight=20):
Expand Down
61 changes: 61 additions & 0 deletions SelfCalibratingConformal/.ipynb_checkpoints/utils-checkpoint.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
import numpy as np
import pandas as pd

def make_grid(values, num_bin, values_to_add=None, binning_method="quantile"):
"""
Generates a grid of values used for binning continuous data. This grid can be created using either
quantile-based binning or fixed-width binning.
Args:
values (array-like): The data values from which the grid is to be created.
num_bin (int): The number of bins to use for the grid.
values_to_add (list, optional): Additional specific values to include in the grid.
binning_method (str, optional): Method of binning ('quantile' or 'fixed'). Defaults to 'quantile'.
Returns:
list: A list of grid values that mark the boundaries of bins.
Note:
- 'quantile' binning divides the data into bins such that each bin has approximately the same number of values.
- 'fixed' binning divides the range of data into equally spaced segments based on the minimum and maximum values.
"""
unique_values = list(set(values))
unique_values.sort()
if len(unique_values) <= num_bin:
return unique_values

if binning_method == "quantile":
qs = np.linspace(0, 1, num=num_bin + 1)
grid_values = set(np.quantile(values, qs, method='inverted_cdf'))
if values_to_add is not None:
grid_values = grid_values.union(set(values_to_add))
grid_values = list(grid_values)
grid_values.sort()
elif binning_method == "fixed":
grid_values = np.linspace(min(values), max(values), num=num_bin + 1)
return grid_values

def match_grid_value(values, grid, return_index=False, all_inside=False):
"""
Maps values to the nearest grid points or their indices. This function is useful for discretizing continuous values
or for aligning values with predefined bins.
Args:
values (array-like): Values to be matched to the grid.
grid (list): A grid of values, such as those generated by `make_grid`.
return_index (bool, optional): If True, returns the indices in the grid for each value instead of the grid values. Defaults to False.
all_inside (bool, optional): If True, adjusts the indices to ensure all values are within the grid limits. Defaults to False.
Returns:
list: Depending on `return_index`, either a list of grid values matching each input value or a list of indices indicating the position in the grid.
"""
bin_index = np.searchsorted(grid, values, side='right')
if all_inside:
bin_index[bin_index == len(grid)] = len(grid) - 1
bin_index = [i if i == 0 else i-1 for i in bin_index]

if not return_index:
values_discrete = [grid[i] for i in bin_index]
return values_discrete
else:
return bin_index
4 changes: 2 additions & 2 deletions SelfCalibratingConformal/SelfCalibratingConformalPredictor.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
from statsmodels.nonparametric.kernel_regression import KernelReg
import matplotlib.pyplot as plt
# Package imports
from SelfCalibratingConformal.calibrators import *
from SelfCalibratingConformal.utils import *
from selfcalibratingconformal.calibrators import *
from selfcalibratingconformal.utils import *

class SelfCalibratingConformalPredictor:
def __init__(self, predictor: callable, calibrator = calibrator_isotonic,
Expand Down
2 changes: 2 additions & 0 deletions SelfCalibratingConformal/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
from .SelfCalibratingConformalPredictor import *
from .calibrators import *
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
2 changes: 0 additions & 2 deletions SelfCalibratingConformal/_init__.py

This file was deleted.

2 changes: 1 addition & 1 deletion SelfCalibratingConformal/calibrators.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import numpy as np
import xgboost as xgb
from SelfCalibratingConformal.utils import *
from selfcalibratingconformal.utils import *


def calibrator_isotonic(f: np.ndarray, y: np.ndarray, max_depth=20, min_child_weight=20):
Expand Down
Loading

0 comments on commit 396a819

Please sign in to comment.