mirror of
https://github.com/Doctorado-ML/FImdlp.git
synced 2025-08-17 16:35:52 +00:00
Create package
This commit is contained in:
1
MANIFEST.in
Normal file
1
MANIFEST.in
Normal file
@@ -0,0 +1 @@
|
||||
include fimdlp/FImdlp.h
|
40
Makefile
Normal file
40
Makefile
Normal file
@@ -0,0 +1,40 @@
|
||||
SHELL := /bin/bash
|
||||
.DEFAULT_GOAL := help
|
||||
.PHONY: coverage deps help lint push test doc build
|
||||
|
||||
clean: ## Clean up
|
||||
rm -rf build dist *.egg-info
|
||||
for name in fimdlp/cfimdlp.cpp fimdlp/fimdlp.cpython-310-darwin.so;do if [ -f $name ]; then rm $name; fi; done
|
||||
|
||||
lint: ## Lint and static-check
|
||||
black fimdlp
|
||||
flake8 fimdlp
|
||||
|
||||
push: ## Push code with tags
|
||||
git push && git push --tags
|
||||
|
||||
build: ## Build package
|
||||
rm -fr dist/*
|
||||
rm -fr build/*
|
||||
#python setup.py build_ext
|
||||
python -m build
|
||||
|
||||
audit: ## Audit pip
|
||||
pip-audit
|
||||
|
||||
help: ## Show help message
|
||||
@IFS=$$'\n' ; \
|
||||
help_lines=(`fgrep -h "##" $(MAKEFILE_LIST) | fgrep -v fgrep | sed -e 's/\\$$//' | sed -e 's/##/:/'`); \
|
||||
printf "%s\n\n" "Usage: make [task]"; \
|
||||
printf "%-20s %s\n" "task" "help" ; \
|
||||
printf "%-20s %s\n" "------" "----" ; \
|
||||
for help_line in $${help_lines[@]}; do \
|
||||
IFS=$$':' ; \
|
||||
help_split=($$help_line) ; \
|
||||
help_command=`echo $${help_split[0]} | sed -e 's/^ *//' -e 's/ *$$//'` ; \
|
||||
help_info=`echo $${help_split[2]} | sed -e 's/^ *//' -e 's/ *$$//'` ; \
|
||||
printf '\033[36m'; \
|
||||
printf "%-20s %s" $$help_command ; \
|
||||
printf '\033[0m'; \
|
||||
printf "%s\n" $$help_info; \
|
||||
done
|
1
fimdlp/__init__.py
Normal file
1
fimdlp/__init__.py
Normal file
@@ -0,0 +1 @@
|
||||
from ._version import __version__
|
1
fimdlp/_version.py
Normal file
1
fimdlp/_version.py
Normal file
@@ -0,0 +1 @@
|
||||
__version__ = '0.1.1'
|
@@ -1,6 +1,7 @@
|
||||
# distutils: language = c++
|
||||
# cython: language_level = 3
|
||||
from libcpp.vector cimport vector
|
||||
|
||||
cdef extern from "FImdlp.h" namespace "FImdlp":
|
||||
cdef cppclass FImdlp:
|
||||
FImdlp() except +
|
25
prueba/FImdlp.cpp
Normal file
25
prueba/FImdlp.cpp
Normal file
@@ -0,0 +1,25 @@
|
||||
#include "FImdlp.h"
|
||||
namespace FImdlp
|
||||
{
|
||||
FImdlp::FImdlp()
|
||||
{
|
||||
}
|
||||
FImdlp::~FImdlp()
|
||||
{
|
||||
}
|
||||
std::vector<float> FImdlp::cutPoints(std::vector<int> &X, std::vector<int> &y)
|
||||
{
|
||||
std::vector<float> cutPts;
|
||||
int i, ant = X.at(0);
|
||||
int n = X.size();
|
||||
for (i = 1; i < n; i++)
|
||||
{
|
||||
if (X.at(i) != ant)
|
||||
{
|
||||
cutPts.push_back(float(X.at(i) + ant) / 2);
|
||||
ant = X.at(i);
|
||||
}
|
||||
}
|
||||
return cutPts;
|
||||
}
|
||||
}
|
15
prueba/FImdlp.h
Normal file
15
prueba/FImdlp.h
Normal file
@@ -0,0 +1,15 @@
|
||||
#ifndef FIMDLP_H
|
||||
#define FIMDLP_H
|
||||
#include <vector>
|
||||
#include <Python.h>
|
||||
namespace FImdlp
|
||||
{
|
||||
class FImdlp
|
||||
{
|
||||
public:
|
||||
FImdlp();
|
||||
~FImdlp();
|
||||
std::vector<float> cutPoints(std::vector<int> &, std::vector<int> &);
|
||||
};
|
||||
}
|
||||
#endif
|
21
prueba/LICENSE
Normal file
21
prueba/LICENSE
Normal file
@@ -0,0 +1,21 @@
|
||||
MIT License
|
||||
|
||||
Copyright (c) 2022 Doctorado-ML
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
42
prueba/Makefile
Normal file
42
prueba/Makefile
Normal file
@@ -0,0 +1,42 @@
|
||||
SHELL := /bin/bash
|
||||
.DEFAULT_GOAL := help
|
||||
.PHONY: coverage deps help lint push test doc build
|
||||
|
||||
clean: ## Clean up
|
||||
rm -rf build dist *.egg-info
|
||||
for name in fimdlp/cfimdlp.cpp fimdlp/fimdlp.cpython-310-darwin.so
|
||||
do
|
||||
if [ -f $name ]; then rm $name; fi
|
||||
done
|
||||
|
||||
lint: ## Lint and static-check
|
||||
black fimdlp
|
||||
flake8 fimdlp
|
||||
|
||||
push: ## Push code with tags
|
||||
git push && git push --tags
|
||||
|
||||
build: ## Build package
|
||||
rm -fr dist/*
|
||||
rm -fr build/*
|
||||
python setup.py build_ext
|
||||
|
||||
audit: ## Audit pip
|
||||
pip-audit
|
||||
|
||||
help: ## Show help message
|
||||
@IFS=$$'\n' ; \
|
||||
help_lines=(`fgrep -h "##" $(MAKEFILE_LIST) | fgrep -v fgrep | sed -e 's/\\$$//' | sed -e 's/##/:/'`); \
|
||||
printf "%s\n\n" "Usage: make [task]"; \
|
||||
printf "%-20s %s\n" "task" "help" ; \
|
||||
printf "%-20s %s\n" "------" "----" ; \
|
||||
for help_line in $${help_lines[@]}; do \
|
||||
IFS=$$':' ; \
|
||||
help_split=($$help_line) ; \
|
||||
help_command=`echo $${help_split[0]} | sed -e 's/^ *//' -e 's/ *$$//'` ; \
|
||||
help_info=`echo $${help_split[2]} | sed -e 's/^ *//' -e 's/ *$$//'` ; \
|
||||
printf '\033[36m'; \
|
||||
printf "%-20s %s" $$help_command ; \
|
||||
printf '\033[0m'; \
|
||||
printf "%s\n" $$help_info; \
|
||||
done
|
10
prueba/README.md
Normal file
10
prueba/README.md
Normal file
@@ -0,0 +1,10 @@
|
||||
# FImdlp
|
||||
|
||||
Fayyad - Irani MDLP discretization algorithm
|
||||
|
||||
## Build and usage sample
|
||||
|
||||
```bash
|
||||
python setup.py build_ext --inplace
|
||||
python sample.py
|
||||
```
|
1
prueba/__init__.py
Normal file
1
prueba/__init__.py
Normal file
@@ -0,0 +1 @@
|
||||
from ._version import __version__
|
1
prueba/_version.py
Normal file
1
prueba/_version.py
Normal file
@@ -0,0 +1 @@
|
||||
__version__ = '0.1.1'
|
17
prueba/cfimdlp.pyx
Normal file
17
prueba/cfimdlp.pyx
Normal file
@@ -0,0 +1,17 @@
|
||||
# distutils: language = c++
|
||||
# cython: language_level = 3
|
||||
from libcpp.vector cimport vector
|
||||
|
||||
cdef extern from "FImdlp.h" namespace "FImdlp":
|
||||
cdef cppclass FImdlp:
|
||||
FImdlp() except +
|
||||
vector[float] cutPoints(vector[int]&, vector[int]&)
|
||||
|
||||
cdef class CFImdlp:
|
||||
cdef FImdlp *thisptr
|
||||
def __cinit__(self):
|
||||
self.thisptr = new FImdlp()
|
||||
def __dealloc__(self):
|
||||
del self.thisptr
|
||||
def cut_points(self, X, y):
|
||||
return self.thisptr.cutPoints(X, y)
|
38
prueba/pyproject.toml
Normal file
38
prueba/pyproject.toml
Normal file
@@ -0,0 +1,38 @@
|
||||
# pyproject.toml
|
||||
[build-system]
|
||||
requires = ["setuptools", "cython", "wheel"]
|
||||
build-backend = "setuptools.build_meta"
|
||||
|
||||
[tool.setuptools]
|
||||
license-files = ["LICENSE"]
|
||||
|
||||
[tool.setuptools.dynamic]
|
||||
version = { attr = "fimdlp.__version__" }
|
||||
|
||||
[project]
|
||||
name = "FImdlp"
|
||||
readme = "README.md"
|
||||
authors = [
|
||||
{ name = "Ricardo Montañana", email = "ricardo.montanana@alu.uclm.es" },
|
||||
]
|
||||
dynamic = ['version']
|
||||
dependencies = ["numpy"]
|
||||
requires-python = ">=3.8"
|
||||
classifiers = [
|
||||
"Development Status :: 3 - Alpha",
|
||||
"Intended Audience :: Science/Research",
|
||||
"Intended Audience :: Developers",
|
||||
"Topic :: Software Development",
|
||||
"Topic :: Scientific/Engineering",
|
||||
"License :: OSI Approved :: MIT License",
|
||||
"Natural Language :: English",
|
||||
"Operating System :: OS Independent",
|
||||
"Programming Language :: Python",
|
||||
"Programming Language :: Python",
|
||||
"Programming Language :: Python :: 3.8",
|
||||
"Programming Language :: Python :: 3.9",
|
||||
"Programming Language :: Python :: 3.10",
|
||||
]
|
||||
|
||||
[project.urls]
|
||||
Home = "https://github.com/doctorado-ml/FImdlp"
|
14
prueba/sample.py
Normal file
14
prueba/sample.py
Normal file
@@ -0,0 +1,14 @@
|
||||
import numpy as np
|
||||
from sklearn.datasets import load_iris
|
||||
from fimdlp import CFImdlp
|
||||
|
||||
data = load_iris()
|
||||
X = data.data
|
||||
y = data.target
|
||||
features = data.feature_names
|
||||
test = CFImdlp()
|
||||
print("Cut points for each feature in Iris dataset:")
|
||||
for i in range(0, X.shape[1]):
|
||||
data = np.sort(X[:, i])
|
||||
Xcutpoints = test.cut_points(data, y)
|
||||
print(f"{features[i]:20s}: {Xcutpoints}")
|
32
prueba/setup.py
Normal file
32
prueba/setup.py
Normal file
@@ -0,0 +1,32 @@
|
||||
"""
|
||||
Calling
|
||||
$python setup.py build_ext --inplace
|
||||
will build the extension library in the current file.
|
||||
"""
|
||||
|
||||
from setuptools import Extension, setup
|
||||
|
||||
setup(
|
||||
ext_modules=[
|
||||
Extension(
|
||||
name="fimdlp",
|
||||
sources=["cfimdlp.pyx", "FImdlp.cpp"],
|
||||
language="c++",
|
||||
include_dirs=["fimdlp"],
|
||||
),
|
||||
]
|
||||
)
|
||||
|
||||
# from Cython.Build import cythonize
|
||||
# setup(
|
||||
# ext_modules=cythonize(
|
||||
# Extension(
|
||||
# "fimdlp",
|
||||
# sources=["fimdlp/cfimdlp.pyx", "fimdlp/FImdlp.cpp"],
|
||||
# language="c++",
|
||||
# include_dirs=["fimdlp"],
|
||||
# ),
|
||||
# include_path=["./fimdlp"],
|
||||
# )
|
||||
# )
|
||||
|
@@ -1,8 +1,39 @@
|
||||
# pyproject.toml
|
||||
[build-system]
|
||||
requires = ["setuptools", "cython"]
|
||||
requires = ["setuptools", "cython", "wheel"]
|
||||
build-backend = "setuptools.build_meta"
|
||||
|
||||
[tool.setuptools]
|
||||
packages = ["fimdlp"]
|
||||
license-files = ["LICENSE"]
|
||||
|
||||
[tool.setuptools.dynamic]
|
||||
version = { attr = "fimdlp.__version__" }
|
||||
|
||||
[project]
|
||||
name = "FImdlp"
|
||||
version = "0.1.0"
|
||||
readme = "README.md"
|
||||
authors = [
|
||||
{ name = "Ricardo Montañana", email = "ricardo.montanana@alu.uclm.es" },
|
||||
]
|
||||
dynamic = ['version']
|
||||
dependencies = ["numpy"]
|
||||
requires-python = ">=3.8"
|
||||
classifiers = [
|
||||
"Development Status :: 3 - Alpha",
|
||||
"Intended Audience :: Science/Research",
|
||||
"Intended Audience :: Developers",
|
||||
"Topic :: Software Development",
|
||||
"Topic :: Scientific/Engineering",
|
||||
"License :: OSI Approved :: MIT License",
|
||||
"Natural Language :: English",
|
||||
"Operating System :: OS Independent",
|
||||
"Programming Language :: Python",
|
||||
"Programming Language :: Python",
|
||||
"Programming Language :: Python :: 3.8",
|
||||
"Programming Language :: Python :: 3.9",
|
||||
"Programming Language :: Python :: 3.10",
|
||||
]
|
||||
|
||||
[project.urls]
|
||||
Home = "https://github.com/doctorado-ml/FImdlp"
|
||||
|
17
setup.py
17
setup.py
@@ -10,8 +10,23 @@ setup(
|
||||
ext_modules=[
|
||||
Extension(
|
||||
name="fimdlp",
|
||||
sources=["cfimdlp.pyx", "FImdlp.cpp"],
|
||||
sources=["fimdlp/cfimdlp.pyx", "fimdlp/FImdlp.cpp"],
|
||||
language="c++",
|
||||
include_dirs=["fimdlp"],
|
||||
),
|
||||
]
|
||||
)
|
||||
|
||||
# from Cython.Build import cythonize
|
||||
# setup(
|
||||
# ext_modules=cythonize(
|
||||
# Extension(
|
||||
# "fimdlp",
|
||||
# sources=["fimdlp/cfimdlp.pyx", "fimdlp/FImdlp.cpp"],
|
||||
# language="c++",
|
||||
# include_dirs=["fimdlp"],
|
||||
# ),
|
||||
# include_path=["./fimdlp"],
|
||||
# )
|
||||
# )
|
||||
|
||||
|
Reference in New Issue
Block a user