Skip to content

Set up library configuration with setup.py and minor changes to source #8

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

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
*.pyc
.project
.pydevproject
__pycache__/
__pycache__/
*.egg
*.egg-info/
build/
Empty file removed __init__.py
Empty file.
2 changes: 2 additions & 0 deletions highdimensional_boundary/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
from .decisionboundaryplot import DBPlot
__all__ = ['DBPlot',]
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
import nlopt
import random
from scipy.spatial.distance import euclidean, squareform, pdist
from utils import minimum_spanning_tree, polar_to_cartesian
from .utils import minimum_spanning_tree, polar_to_cartesian
from sklearn.model_selection import GridSearchCV
from sklearn.svm import SVC
from sklearn.metrics import accuracy_score, f1_score
Expand Down Expand Up @@ -270,6 +270,7 @@ def fit(self, X, y, training_indices=None):
print(
"Failed to find initial decision boundary. Retrying... If this keeps happening, increasing the acceptance threshold might help. Also, make sure the classifier is able to find a point with 0.5 prediction probability (usually requires an even number of estimators/neighbors/etc)."
)
self.acceptance_threshold += 0.03
return self.fit(X, y, training_indices)

# step 3. look for decision boundary points between already known db
Expand Down Expand Up @@ -376,6 +377,7 @@ def plot(
background_resolution=100,
scatter_size_scale=1.0,
legend=True,
annotate=None,
):

"""Plots the dataset and the identified decision boundary in 2D.
Expand Down Expand Up @@ -408,6 +410,8 @@ def plot(
legend : boolean, optional (default=False)
Whether to display a legend

annotate : float, optional (default=None)
If not None, it specifies the percentage of points to annotate as a float: range from 0 to 1.0
Returns
-------
plt : The matplotlib.pyplot or axis object which has been passed in, after
Expand Down Expand Up @@ -493,14 +497,10 @@ def plot(
)

# label data points with their indices
for i in range(len(self.X2d)):
plt.text(
self.X2d[i, 0] + (self.X2d_xmax - self.X2d_xmin) * 0.5e-2,
self.X2d[i, 1] + (self.X2d_ymax - self.X2d_ymin) * 0.5e-2,
str(i),
size=8,
)

if annotate:
step = int(len(self.X2d)*annotate) + 1
for i, txt in enumerate(range(self.X2d.shape[0])[:step:]):
plt.text(self.X2d[i, 0], self.X2d[i, 1], txt, fontsize='xx-small')
if legend:
plt.legend(
[
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
8 changes: 4 additions & 4 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
matplotlib==3.0.2
scipy==1.1.0
numpy==1.15.4
matplotlib
scipy
numpy
nlopt==2.6.1
scikit_learn==0.21.2
scikit_learn
19 changes: 19 additions & 0 deletions setup.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
from setuptools import setup, find_packages
from os.path import dirname, join, realpath
from textwrap import dedent

PROJECT_ROOT = dirname(realpath(__file__))
REQUIREMENTS_FILE = join(PROJECT_ROOT, "requirements.txt")

with open(REQUIREMENTS_FILE) as f:
install_reqs = f.read().splitlines()

install_reqs.append("setuptools")

setup(
name='highdimensional_boundary',
version='1.0.0',
author='Tamas Madl',
packages=find_packages(),
install_requires=install_reqs,
)