-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
e89d1a1
commit 396a819
Showing
33 changed files
with
694 additions
and
93 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
include README.md | ||
include LICENSE | ||
recursive-include selfcalibratingconformal * |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
{ | ||
"cells": [], | ||
"metadata": {}, | ||
"nbformat": 4, | ||
"nbformat_minor": 5 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
include README.md | ||
include LICENSE | ||
recursive-include selfcalibratingconformal * |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
|
||
selfcalibratingconformal |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 2 additions & 0 deletions
2
SelfCalibratingConformal/.ipynb_checkpoints/__init__-checkpoint.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
from .SelfCalibratingConformalPredictor import * | ||
from .calibrators import * |
2 changes: 1 addition & 1 deletion
2
SelfCalibratingConformal/.ipynb_checkpoints/calibrators-checkpoint.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
61 changes: 61 additions & 0 deletions
61
SelfCalibratingConformal/.ipynb_checkpoints/utils-checkpoint.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
from .SelfCalibratingConformalPredictor import * | ||
from .calibrators import * |
Binary file modified
BIN
+54 Bytes
(100%)
SelfCalibratingConformal/__pycache__/SelfCalibratingConformalPredictor.cpython-312.pyc
Binary file not shown.
Binary file added
BIN
+20.4 KB
SelfCalibratingConformal/__pycache__/SelfCalibratingConformalPredictor.cpython-313.pyc
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.