ibrahimpy 0.1.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- ibrahimpy-0.1.0/MANIFEST.in +7 -0
- ibrahimpy-0.1.0/PKG-INFO +71 -0
- ibrahimpy-0.1.0/README.md +26 -0
- ibrahimpy-0.1.0/ibrahim/__init__.py +17 -0
- ibrahimpy-0.1.0/ibrahim/model.py +116 -0
- ibrahimpy-0.1.0/ibrahim/utils.py +49 -0
- ibrahimpy-0.1.0/ibrahim/visualization.py +31 -0
- ibrahimpy-0.1.0/ibrahimpy.egg-info/PKG-INFO +71 -0
- ibrahimpy-0.1.0/ibrahimpy.egg-info/SOURCES.txt +15 -0
- ibrahimpy-0.1.0/ibrahimpy.egg-info/dependency_links.txt +1 -0
- ibrahimpy-0.1.0/ibrahimpy.egg-info/requires.txt +14 -0
- ibrahimpy-0.1.0/ibrahimpy.egg-info/top_level.txt +1 -0
- ibrahimpy-0.1.0/pyproject.toml +65 -0
- ibrahimpy-0.1.0/requirements.txt +6 -0
- ibrahimpy-0.1.0/setup.cfg +4 -0
- ibrahimpy-0.1.0/setup.py +40 -0
- ibrahimpy-0.1.0/tests/test_model.py +98 -0
ibrahimpy-0.1.0/PKG-INFO
ADDED
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: ibrahimpy
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Intelligent Benchmark Relational Analysis for Heuristic Index Modeling
|
|
5
|
+
Home-page: https://github.com/AkmdAshraf/IBRAHIM
|
|
6
|
+
Author: AkmdAshraf
|
|
7
|
+
Author-email: AkmdAshraf <your-email@example.com>
|
|
8
|
+
Maintainer-email: AkmdAshraf <your-email@example.com>
|
|
9
|
+
License: MIT
|
|
10
|
+
Project-URL: Homepage, https://github.com/AkmdAshraf/IBRAHIM
|
|
11
|
+
Project-URL: Repository, https://github.com/AkmdAshraf/IBRAHIM
|
|
12
|
+
Project-URL: Documentation, https://github.com/AkmdAshraf/IBRAHIM#readme
|
|
13
|
+
Project-URL: Issues, https://github.com/AkmdAshraf/IBRAHIM/issues
|
|
14
|
+
Keywords: benchmark,ranking,multi-criteria,decision-analysis,mcdm
|
|
15
|
+
Classifier: Development Status :: 3 - Alpha
|
|
16
|
+
Classifier: Intended Audience :: Science/Research
|
|
17
|
+
Classifier: Intended Audience :: Developers
|
|
18
|
+
Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
|
|
19
|
+
Classifier: Topic :: Software Development :: Libraries :: Python Modules
|
|
20
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
21
|
+
Classifier: Programming Language :: Python :: 3
|
|
22
|
+
Classifier: Programming Language :: Python :: 3.8
|
|
23
|
+
Classifier: Programming Language :: Python :: 3.9
|
|
24
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
25
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
26
|
+
Classifier: Operating System :: OS Independent
|
|
27
|
+
Requires-Python: >=3.8
|
|
28
|
+
Description-Content-Type: text/markdown
|
|
29
|
+
Requires-Dist: numpy>=1.24.0
|
|
30
|
+
Requires-Dist: pandas>=2.0.0
|
|
31
|
+
Requires-Dist: scikit-learn>=1.3.0
|
|
32
|
+
Requires-Dist: matplotlib>=3.7.0
|
|
33
|
+
Requires-Dist: seaborn>=0.12.0
|
|
34
|
+
Requires-Dist: scipy>=1.10.0
|
|
35
|
+
Provides-Extra: dev
|
|
36
|
+
Requires-Dist: pytest>=7.0.0; extra == "dev"
|
|
37
|
+
Requires-Dist: pytest-cov>=4.0.0; extra == "dev"
|
|
38
|
+
Requires-Dist: black>=23.0.0; extra == "dev"
|
|
39
|
+
Requires-Dist: flake8>=6.0.0; extra == "dev"
|
|
40
|
+
Requires-Dist: build>=0.10.0; extra == "dev"
|
|
41
|
+
Requires-Dist: twine>=4.0.0; extra == "dev"
|
|
42
|
+
Dynamic: author
|
|
43
|
+
Dynamic: home-page
|
|
44
|
+
Dynamic: requires-python
|
|
45
|
+
|
|
46
|
+
# IBRAHIM (Intelligent Benchmark Relational Analysis for Heuristic Index Modeling)
|
|
47
|
+
|
|
48
|
+
[](https://www.python.org/)
|
|
49
|
+
[](LICENSE)
|
|
50
|
+
[](https://badge.fury.io/py/ibrahim)
|
|
51
|
+
|
|
52
|
+
A novel machine learning framework for multi-criteria decision analysis and benchmark-based ranking.
|
|
53
|
+
|
|
54
|
+
## 📊 Overview
|
|
55
|
+
|
|
56
|
+
IBRAHIM is an intelligent analytical model that evaluates multiple records based on many variables, determines the highest benchmark, and computes ranking scores. It combines elements of multi-criteria decision analysis (MCDA) with machine learning for robust, automated benchmarking.
|
|
57
|
+
|
|
58
|
+
### Key Features
|
|
59
|
+
|
|
60
|
+
- **Automatic Feature Direction Detection**: Determines whether variables should be maximized or minimized
|
|
61
|
+
- **Intelligent Benchmark Generation**: Creates ideal benchmark records based on feature directions
|
|
62
|
+
- **Flexible Weight Assignment**: Supports both automatic (ML-based) and manual weight specification
|
|
63
|
+
- **0-100 Scoring Scale**: Intuitive, normalized scores for easy interpretation
|
|
64
|
+
- **New Record Evaluation**: Compare any new record against the established benchmark
|
|
65
|
+
- **Visualization Tools**: Built-in plotting for ranking analysis
|
|
66
|
+
|
|
67
|
+
## 🚀 Installation
|
|
68
|
+
|
|
69
|
+
### From PyPI (once published)
|
|
70
|
+
```bash
|
|
71
|
+
pip install ibrahim
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
# IBRAHIM (Intelligent Benchmark Relational Analysis for Heuristic Index Modeling)
|
|
2
|
+
|
|
3
|
+
[](https://www.python.org/)
|
|
4
|
+
[](LICENSE)
|
|
5
|
+
[](https://badge.fury.io/py/ibrahim)
|
|
6
|
+
|
|
7
|
+
A novel machine learning framework for multi-criteria decision analysis and benchmark-based ranking.
|
|
8
|
+
|
|
9
|
+
## 📊 Overview
|
|
10
|
+
|
|
11
|
+
IBRAHIM is an intelligent analytical model that evaluates multiple records based on many variables, determines the highest benchmark, and computes ranking scores. It combines elements of multi-criteria decision analysis (MCDA) with machine learning for robust, automated benchmarking.
|
|
12
|
+
|
|
13
|
+
### Key Features
|
|
14
|
+
|
|
15
|
+
- **Automatic Feature Direction Detection**: Determines whether variables should be maximized or minimized
|
|
16
|
+
- **Intelligent Benchmark Generation**: Creates ideal benchmark records based on feature directions
|
|
17
|
+
- **Flexible Weight Assignment**: Supports both automatic (ML-based) and manual weight specification
|
|
18
|
+
- **0-100 Scoring Scale**: Intuitive, normalized scores for easy interpretation
|
|
19
|
+
- **New Record Evaluation**: Compare any new record against the established benchmark
|
|
20
|
+
- **Visualization Tools**: Built-in plotting for ranking analysis
|
|
21
|
+
|
|
22
|
+
## 🚀 Installation
|
|
23
|
+
|
|
24
|
+
### From PyPI (once published)
|
|
25
|
+
```bash
|
|
26
|
+
pip install ibrahim
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"""IBRAHIM - Intelligent Benchmark Relational Analysis"""
|
|
2
|
+
|
|
3
|
+
# These imports will work once all files are created
|
|
4
|
+
from .model import IBRAHIM
|
|
5
|
+
from .utils import normalize_data, detect_directions, calculate_weights
|
|
6
|
+
from .visualization import plot_ranking, plot_feature_importance, plot_radar_comparison
|
|
7
|
+
|
|
8
|
+
__version__ = "0.1.0"
|
|
9
|
+
__all__ = [
|
|
10
|
+
"IBRAHIM",
|
|
11
|
+
"normalize_data",
|
|
12
|
+
"detect_directions",
|
|
13
|
+
"calculate_weights",
|
|
14
|
+
"plot_ranking",
|
|
15
|
+
"plot_feature_importance",
|
|
16
|
+
"plot_radar_comparison"
|
|
17
|
+
]
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
"""Core IBRAHIM model implementation"""
|
|
2
|
+
import numpy as np
|
|
3
|
+
import pandas as pd
|
|
4
|
+
from sklearn.preprocessing import MinMaxScaler
|
|
5
|
+
from sklearn.ensemble import RandomForestRegressor
|
|
6
|
+
from scipy import stats
|
|
7
|
+
|
|
8
|
+
class IBRAHIM:
|
|
9
|
+
def __init__(self, auto_weights=True, normalization='minmax',
|
|
10
|
+
distance_metric='euclidean', random_state=42):
|
|
11
|
+
self.auto_weights = auto_weights
|
|
12
|
+
self.normalization = normalization
|
|
13
|
+
self.distance_metric = distance_metric
|
|
14
|
+
self.random_state = random_state
|
|
15
|
+
self.is_fitted = False
|
|
16
|
+
|
|
17
|
+
def fit(self, X, y=None, directions=None, weights=None):
|
|
18
|
+
self.feature_names_ = X.columns.tolist()
|
|
19
|
+
self.n_features_ = X.shape[1]
|
|
20
|
+
self.X_original_ = X.copy()
|
|
21
|
+
|
|
22
|
+
# Simple minmax scaling for now
|
|
23
|
+
self.scaler_ = MinMaxScaler()
|
|
24
|
+
self.X_scaled_ = pd.DataFrame(
|
|
25
|
+
self.scaler_.fit_transform(X),
|
|
26
|
+
columns=X.columns,
|
|
27
|
+
index=X.index
|
|
28
|
+
)
|
|
29
|
+
|
|
30
|
+
# Default directions (all max)
|
|
31
|
+
self.directions_ = {col: 'max' for col in self.feature_names_}
|
|
32
|
+
|
|
33
|
+
# Simple benchmark
|
|
34
|
+
self.benchmark_ = {}
|
|
35
|
+
for col in self.feature_names_:
|
|
36
|
+
if self.directions_[col] == 'max':
|
|
37
|
+
self.benchmark_[col] = self.X_scaled_[col].max()
|
|
38
|
+
else:
|
|
39
|
+
self.benchmark_[col] = self.X_scaled_[col].min()
|
|
40
|
+
|
|
41
|
+
# Simple weights (equal)
|
|
42
|
+
self.weights_ = {col: 1/self.n_features_ for col in self.feature_names_}
|
|
43
|
+
|
|
44
|
+
self.is_fitted = True
|
|
45
|
+
return self
|
|
46
|
+
|
|
47
|
+
def calculate_distances(self, X=None):
|
|
48
|
+
if X is None:
|
|
49
|
+
X_scaled = self.X_scaled_
|
|
50
|
+
else:
|
|
51
|
+
X_scaled = pd.DataFrame(
|
|
52
|
+
self.scaler_.transform(X),
|
|
53
|
+
columns=X.columns,
|
|
54
|
+
index=X.index
|
|
55
|
+
)
|
|
56
|
+
|
|
57
|
+
distances = []
|
|
58
|
+
weight_vector = np.array([self.weights_[col] for col in self.feature_names_])
|
|
59
|
+
benchmark_vector = np.array([self.benchmark_[col] for col in self.feature_names_])
|
|
60
|
+
|
|
61
|
+
for idx in X_scaled.index:
|
|
62
|
+
record = X_scaled.loc[idx].values
|
|
63
|
+
dist = np.sqrt(np.sum(weight_vector * (record - benchmark_vector)**2))
|
|
64
|
+
distances.append(dist)
|
|
65
|
+
|
|
66
|
+
return np.array(distances)
|
|
67
|
+
|
|
68
|
+
def rank(self, X=None):
|
|
69
|
+
distances = self.calculate_distances(X)
|
|
70
|
+
|
|
71
|
+
if X is None:
|
|
72
|
+
ranking_df = self.X_original_.copy()
|
|
73
|
+
else:
|
|
74
|
+
ranking_df = X.copy()
|
|
75
|
+
|
|
76
|
+
max_dist = distances.max()
|
|
77
|
+
min_dist = distances.min()
|
|
78
|
+
|
|
79
|
+
if max_dist > min_dist:
|
|
80
|
+
scores = 100 * (1 - (distances - min_dist) / (max_dist - min_dist))
|
|
81
|
+
else:
|
|
82
|
+
scores = np.full_like(distances, 100)
|
|
83
|
+
|
|
84
|
+
ranking_df['distance'] = distances
|
|
85
|
+
ranking_df['score'] = scores
|
|
86
|
+
ranking_df['rank'] = pd.Series(scores).rank(ascending=False, method='min').astype(int).values
|
|
87
|
+
|
|
88
|
+
return ranking_df.sort_values('rank')
|
|
89
|
+
|
|
90
|
+
def compare_new(self, new_record):
|
|
91
|
+
new_df = pd.DataFrame([new_record])
|
|
92
|
+
distance = self.calculate_distances(new_df)[0]
|
|
93
|
+
|
|
94
|
+
existing = self.rank()
|
|
95
|
+
all_distances = np.append(existing['distance'].values, distance)
|
|
96
|
+
|
|
97
|
+
max_dist = all_distances.max()
|
|
98
|
+
min_dist = all_distances.min()
|
|
99
|
+
|
|
100
|
+
if max_dist > min_dist:
|
|
101
|
+
score = 100 * (1 - (distance - min_dist) / (max_dist - min_dist))
|
|
102
|
+
else:
|
|
103
|
+
score = 100
|
|
104
|
+
|
|
105
|
+
return {'score': score, 'distance': distance}
|
|
106
|
+
|
|
107
|
+
def get_summary(self):
|
|
108
|
+
ranking = self.rank()
|
|
109
|
+
return {
|
|
110
|
+
'n_features': self.n_features_,
|
|
111
|
+
'score_stats': {
|
|
112
|
+
'mean': ranking['score'].mean(),
|
|
113
|
+
'min': ranking['score'].min(),
|
|
114
|
+
'max': ranking['score'].max()
|
|
115
|
+
}
|
|
116
|
+
}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
"""Utility functions for IBRAHIM"""
|
|
2
|
+
import numpy as np
|
|
3
|
+
import pandas as pd
|
|
4
|
+
from sklearn.preprocessing import MinMaxScaler, StandardScaler, RobustScaler
|
|
5
|
+
|
|
6
|
+
def normalize_data(X, method='minmax'):
|
|
7
|
+
"""Normalize the input data"""
|
|
8
|
+
if method == 'minmax':
|
|
9
|
+
scaler = MinMaxScaler()
|
|
10
|
+
elif method == 'zscore':
|
|
11
|
+
scaler = StandardScaler()
|
|
12
|
+
elif method == 'robust':
|
|
13
|
+
scaler = RobustScaler()
|
|
14
|
+
else:
|
|
15
|
+
raise ValueError(f"Unknown method: {method}")
|
|
16
|
+
|
|
17
|
+
X_scaled = pd.DataFrame(
|
|
18
|
+
scaler.fit_transform(X),
|
|
19
|
+
columns=X.columns,
|
|
20
|
+
index=X.index
|
|
21
|
+
)
|
|
22
|
+
return X_scaled, scaler
|
|
23
|
+
|
|
24
|
+
def detect_directions(X_scaled, y=None, manual_directions=None):
|
|
25
|
+
"""Determine feature directions"""
|
|
26
|
+
if manual_directions:
|
|
27
|
+
return manual_directions
|
|
28
|
+
|
|
29
|
+
directions = {}
|
|
30
|
+
for col in X_scaled.columns:
|
|
31
|
+
directions[col] = 'max' # Default
|
|
32
|
+
return directions
|
|
33
|
+
|
|
34
|
+
def calculate_weights(X_scaled, y=None, manual_weights=None, auto_weights=True, random_state=42):
|
|
35
|
+
"""Calculate feature weights"""
|
|
36
|
+
if manual_weights:
|
|
37
|
+
weights = manual_weights
|
|
38
|
+
elif auto_weights:
|
|
39
|
+
# Simple variance-based weights
|
|
40
|
+
variances = X_scaled.var()
|
|
41
|
+
weights = (variances / variances.sum()).to_dict()
|
|
42
|
+
else:
|
|
43
|
+
n_features = X_scaled.shape[1]
|
|
44
|
+
weights = {col: 1/n_features for col in X_scaled.columns}
|
|
45
|
+
|
|
46
|
+
# Normalize
|
|
47
|
+
total = sum(weights.values())
|
|
48
|
+
weights = {k: v/total for k, v in weights.items()}
|
|
49
|
+
return weights
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
"""Visualization functions for IBRAHIM"""
|
|
2
|
+
import matplotlib.pyplot as plt
|
|
3
|
+
import numpy as np
|
|
4
|
+
|
|
5
|
+
def plot_ranking(model, top_n=10):
|
|
6
|
+
"""Plot ranking results"""
|
|
7
|
+
ranking = model.rank()
|
|
8
|
+
|
|
9
|
+
fig, ax = plt.subplots(figsize=(10, 6))
|
|
10
|
+
top_records = ranking.head(top_n)
|
|
11
|
+
|
|
12
|
+
ax.barh(range(len(top_records)), top_records['score'].values[::-1])
|
|
13
|
+
ax.set_yticks(range(len(top_records)))
|
|
14
|
+
ax.set_yticklabels(top_records.index[::-1])
|
|
15
|
+
ax.set_xlabel('Score (0-100)')
|
|
16
|
+
ax.set_title(f'Top {top_n} Rankings')
|
|
17
|
+
ax.set_xlim(0, 100)
|
|
18
|
+
|
|
19
|
+
plt.tight_layout()
|
|
20
|
+
plt.show()
|
|
21
|
+
return fig
|
|
22
|
+
|
|
23
|
+
def plot_feature_importance(model):
|
|
24
|
+
"""Plot feature importance"""
|
|
25
|
+
print("Feature importance plot - to be implemented")
|
|
26
|
+
return None
|
|
27
|
+
|
|
28
|
+
def plot_radar_comparison(model, records=None):
|
|
29
|
+
"""Plot radar comparison"""
|
|
30
|
+
print("Radar plot - to be implemented")
|
|
31
|
+
return None
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: ibrahimpy
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Intelligent Benchmark Relational Analysis for Heuristic Index Modeling
|
|
5
|
+
Home-page: https://github.com/AkmdAshraf/IBRAHIM
|
|
6
|
+
Author: AkmdAshraf
|
|
7
|
+
Author-email: AkmdAshraf <your-email@example.com>
|
|
8
|
+
Maintainer-email: AkmdAshraf <your-email@example.com>
|
|
9
|
+
License: MIT
|
|
10
|
+
Project-URL: Homepage, https://github.com/AkmdAshraf/IBRAHIM
|
|
11
|
+
Project-URL: Repository, https://github.com/AkmdAshraf/IBRAHIM
|
|
12
|
+
Project-URL: Documentation, https://github.com/AkmdAshraf/IBRAHIM#readme
|
|
13
|
+
Project-URL: Issues, https://github.com/AkmdAshraf/IBRAHIM/issues
|
|
14
|
+
Keywords: benchmark,ranking,multi-criteria,decision-analysis,mcdm
|
|
15
|
+
Classifier: Development Status :: 3 - Alpha
|
|
16
|
+
Classifier: Intended Audience :: Science/Research
|
|
17
|
+
Classifier: Intended Audience :: Developers
|
|
18
|
+
Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
|
|
19
|
+
Classifier: Topic :: Software Development :: Libraries :: Python Modules
|
|
20
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
21
|
+
Classifier: Programming Language :: Python :: 3
|
|
22
|
+
Classifier: Programming Language :: Python :: 3.8
|
|
23
|
+
Classifier: Programming Language :: Python :: 3.9
|
|
24
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
25
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
26
|
+
Classifier: Operating System :: OS Independent
|
|
27
|
+
Requires-Python: >=3.8
|
|
28
|
+
Description-Content-Type: text/markdown
|
|
29
|
+
Requires-Dist: numpy>=1.24.0
|
|
30
|
+
Requires-Dist: pandas>=2.0.0
|
|
31
|
+
Requires-Dist: scikit-learn>=1.3.0
|
|
32
|
+
Requires-Dist: matplotlib>=3.7.0
|
|
33
|
+
Requires-Dist: seaborn>=0.12.0
|
|
34
|
+
Requires-Dist: scipy>=1.10.0
|
|
35
|
+
Provides-Extra: dev
|
|
36
|
+
Requires-Dist: pytest>=7.0.0; extra == "dev"
|
|
37
|
+
Requires-Dist: pytest-cov>=4.0.0; extra == "dev"
|
|
38
|
+
Requires-Dist: black>=23.0.0; extra == "dev"
|
|
39
|
+
Requires-Dist: flake8>=6.0.0; extra == "dev"
|
|
40
|
+
Requires-Dist: build>=0.10.0; extra == "dev"
|
|
41
|
+
Requires-Dist: twine>=4.0.0; extra == "dev"
|
|
42
|
+
Dynamic: author
|
|
43
|
+
Dynamic: home-page
|
|
44
|
+
Dynamic: requires-python
|
|
45
|
+
|
|
46
|
+
# IBRAHIM (Intelligent Benchmark Relational Analysis for Heuristic Index Modeling)
|
|
47
|
+
|
|
48
|
+
[](https://www.python.org/)
|
|
49
|
+
[](LICENSE)
|
|
50
|
+
[](https://badge.fury.io/py/ibrahim)
|
|
51
|
+
|
|
52
|
+
A novel machine learning framework for multi-criteria decision analysis and benchmark-based ranking.
|
|
53
|
+
|
|
54
|
+
## 📊 Overview
|
|
55
|
+
|
|
56
|
+
IBRAHIM is an intelligent analytical model that evaluates multiple records based on many variables, determines the highest benchmark, and computes ranking scores. It combines elements of multi-criteria decision analysis (MCDA) with machine learning for robust, automated benchmarking.
|
|
57
|
+
|
|
58
|
+
### Key Features
|
|
59
|
+
|
|
60
|
+
- **Automatic Feature Direction Detection**: Determines whether variables should be maximized or minimized
|
|
61
|
+
- **Intelligent Benchmark Generation**: Creates ideal benchmark records based on feature directions
|
|
62
|
+
- **Flexible Weight Assignment**: Supports both automatic (ML-based) and manual weight specification
|
|
63
|
+
- **0-100 Scoring Scale**: Intuitive, normalized scores for easy interpretation
|
|
64
|
+
- **New Record Evaluation**: Compare any new record against the established benchmark
|
|
65
|
+
- **Visualization Tools**: Built-in plotting for ranking analysis
|
|
66
|
+
|
|
67
|
+
## 🚀 Installation
|
|
68
|
+
|
|
69
|
+
### From PyPI (once published)
|
|
70
|
+
```bash
|
|
71
|
+
pip install ibrahim
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
MANIFEST.in
|
|
2
|
+
README.md
|
|
3
|
+
pyproject.toml
|
|
4
|
+
requirements.txt
|
|
5
|
+
setup.py
|
|
6
|
+
ibrahim/__init__.py
|
|
7
|
+
ibrahim/model.py
|
|
8
|
+
ibrahim/utils.py
|
|
9
|
+
ibrahim/visualization.py
|
|
10
|
+
ibrahimpy.egg-info/PKG-INFO
|
|
11
|
+
ibrahimpy.egg-info/SOURCES.txt
|
|
12
|
+
ibrahimpy.egg-info/dependency_links.txt
|
|
13
|
+
ibrahimpy.egg-info/requires.txt
|
|
14
|
+
ibrahimpy.egg-info/top_level.txt
|
|
15
|
+
tests/test_model.py
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
ibrahim
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["setuptools>=61.0", "wheel"]
|
|
3
|
+
build-backend = "setuptools.build_meta"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = "ibrahimpy"
|
|
7
|
+
version = "0.1.0"
|
|
8
|
+
description = "Intelligent Benchmark Relational Analysis for Heuristic Index Modeling"
|
|
9
|
+
readme = "README.md"
|
|
10
|
+
requires-python = ">=3.8"
|
|
11
|
+
license = {text = "MIT"}
|
|
12
|
+
authors = [
|
|
13
|
+
{name = "AkmdAshraf", email = "your-email@example.com"},
|
|
14
|
+
]
|
|
15
|
+
maintainers = [
|
|
16
|
+
{name = "AkmdAshraf", email = "your-email@example.com"},
|
|
17
|
+
]
|
|
18
|
+
keywords = ["benchmark", "ranking", "multi-criteria", "decision-analysis", "mcdm"]
|
|
19
|
+
classifiers = [
|
|
20
|
+
"Development Status :: 3 - Alpha",
|
|
21
|
+
"Intended Audience :: Science/Research",
|
|
22
|
+
"Intended Audience :: Developers",
|
|
23
|
+
"Topic :: Scientific/Engineering :: Artificial Intelligence",
|
|
24
|
+
"Topic :: Software Development :: Libraries :: Python Modules",
|
|
25
|
+
"License :: OSI Approved :: MIT License",
|
|
26
|
+
"Programming Language :: Python :: 3",
|
|
27
|
+
"Programming Language :: Python :: 3.8",
|
|
28
|
+
"Programming Language :: Python :: 3.9",
|
|
29
|
+
"Programming Language :: Python :: 3.10",
|
|
30
|
+
"Programming Language :: Python :: 3.11",
|
|
31
|
+
"Operating System :: OS Independent",
|
|
32
|
+
]
|
|
33
|
+
|
|
34
|
+
dependencies = [
|
|
35
|
+
"numpy>=1.24.0",
|
|
36
|
+
"pandas>=2.0.0",
|
|
37
|
+
"scikit-learn>=1.3.0",
|
|
38
|
+
"matplotlib>=3.7.0",
|
|
39
|
+
"seaborn>=0.12.0",
|
|
40
|
+
"scipy>=1.10.0",
|
|
41
|
+
]
|
|
42
|
+
|
|
43
|
+
[project.optional-dependencies]
|
|
44
|
+
dev = [
|
|
45
|
+
"pytest>=7.0.0",
|
|
46
|
+
"pytest-cov>=4.0.0",
|
|
47
|
+
"black>=23.0.0",
|
|
48
|
+
"flake8>=6.0.0",
|
|
49
|
+
"build>=0.10.0",
|
|
50
|
+
"twine>=4.0.0",
|
|
51
|
+
]
|
|
52
|
+
|
|
53
|
+
[project.urls]
|
|
54
|
+
Homepage = "https://github.com/AkmdAshraf/IBRAHIM"
|
|
55
|
+
Repository = "https://github.com/AkmdAshraf/IBRAHIM"
|
|
56
|
+
Documentation = "https://github.com/AkmdAshraf/IBRAHIM#readme"
|
|
57
|
+
Issues = "https://github.com/AkmdAshraf/IBRAHIM/issues"
|
|
58
|
+
|
|
59
|
+
[tool.setuptools.packages.find]
|
|
60
|
+
where = ["."]
|
|
61
|
+
include = ["ibrahim*"]
|
|
62
|
+
exclude = ["tests*", "examples*"]
|
|
63
|
+
|
|
64
|
+
[tool.setuptools.package-data]
|
|
65
|
+
ibrahim = ["py.typed"]
|
ibrahimpy-0.1.0/setup.py
ADDED
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
from setuptools import setup, find_packages
|
|
2
|
+
|
|
3
|
+
with open("README.md", "r", encoding="utf-8") as fh:
|
|
4
|
+
long_description = fh.read()
|
|
5
|
+
|
|
6
|
+
with open("requirements.txt", "r", encoding="utf-8") as fh:
|
|
7
|
+
requirements = [line.strip() for line in fh if line.strip() and not line.startswith("#")]
|
|
8
|
+
|
|
9
|
+
setup(
|
|
10
|
+
name="ibrahim",
|
|
11
|
+
version="0.1.0",
|
|
12
|
+
author="AkmdAshraf",
|
|
13
|
+
author_email="your-email@example.com",
|
|
14
|
+
description="Intelligent Benchmark Relational Analysis for Heuristic Index Modeling",
|
|
15
|
+
long_description=long_description,
|
|
16
|
+
long_description_content_type="text/markdown",
|
|
17
|
+
url="https://github.com/AkmdAshraf/IBRAHIM",
|
|
18
|
+
packages=find_packages(),
|
|
19
|
+
classifiers=[
|
|
20
|
+
"Programming Language :: Python :: 3",
|
|
21
|
+
"Programming Language :: Python :: 3.8",
|
|
22
|
+
"Programming Language :: Python :: 3.9",
|
|
23
|
+
"Programming Language :: Python :: 3.10",
|
|
24
|
+
"Programming Language :: Python :: 3.11",
|
|
25
|
+
"License :: OSI Approved :: MIT License",
|
|
26
|
+
"Operating System :: OS Independent",
|
|
27
|
+
"Topic :: Scientific/Engineering :: Artificial Intelligence",
|
|
28
|
+
"Topic :: Scientific/Engineering :: Information Analysis",
|
|
29
|
+
],
|
|
30
|
+
python_requires=">=3.8",
|
|
31
|
+
install_requires=requirements,
|
|
32
|
+
extras_require={
|
|
33
|
+
"dev": [
|
|
34
|
+
"pytest>=7.0.0",
|
|
35
|
+
"pytest-cov>=4.0.0",
|
|
36
|
+
"black>=23.0.0",
|
|
37
|
+
"flake8>=6.0.0",
|
|
38
|
+
],
|
|
39
|
+
},
|
|
40
|
+
)
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
"""
|
|
2
|
+
Unit tests for IBRAHIM model.
|
|
3
|
+
"""
|
|
4
|
+
|
|
5
|
+
import unittest
|
|
6
|
+
import pandas as pd
|
|
7
|
+
import numpy as np
|
|
8
|
+
import sys
|
|
9
|
+
import os
|
|
10
|
+
sys.path.insert(0, os.path.abspath(os.path.join(os.path.dirname(__file__), '..')))
|
|
11
|
+
|
|
12
|
+
from ibrahim import IBRAHIM
|
|
13
|
+
|
|
14
|
+
class TestIBRAHIM(unittest.TestCase):
|
|
15
|
+
"""Test cases for IBRAHIM model"""
|
|
16
|
+
|
|
17
|
+
def setUp(self):
|
|
18
|
+
"""Set up test data"""
|
|
19
|
+
self.data = pd.DataFrame({
|
|
20
|
+
'A': [1, 2, 3, 4, 5],
|
|
21
|
+
'B': [5, 4, 3, 2, 1],
|
|
22
|
+
'C': [2, 3, 4, 5, 6]
|
|
23
|
+
})
|
|
24
|
+
|
|
25
|
+
def test_initialization(self):
|
|
26
|
+
"""Test model initialization"""
|
|
27
|
+
model = IBRAHIM(auto_weights=True)
|
|
28
|
+
self.assertEqual(model.auto_weights, True)
|
|
29
|
+
self.assertEqual(model.normalization, 'minmax')
|
|
30
|
+
self.assertEqual(model.distance_metric, 'euclidean')
|
|
31
|
+
|
|
32
|
+
def test_fit_and_rank(self):
|
|
33
|
+
"""Test fitting and ranking"""
|
|
34
|
+
model = IBRAHIM(auto_weights=True)
|
|
35
|
+
model.fit(self.data)
|
|
36
|
+
|
|
37
|
+
rankings = model.rank()
|
|
38
|
+
|
|
39
|
+
self.assertIn('score', rankings.columns)
|
|
40
|
+
self.assertIn('rank', rankings.columns)
|
|
41
|
+
self.assertIn('distance', rankings.columns)
|
|
42
|
+
self.assertEqual(len(rankings), len(self.data))
|
|
43
|
+
|
|
44
|
+
def test_compare_new(self):
|
|
45
|
+
"""Test comparing new record"""
|
|
46
|
+
model = IBRAHIM(auto_weights=True)
|
|
47
|
+
model.fit(self.data)
|
|
48
|
+
|
|
49
|
+
new_record = {'A': 3, 'B': 3, 'C': 4}
|
|
50
|
+
result = model.compare_new(new_record)
|
|
51
|
+
|
|
52
|
+
self.assertIn('score', result)
|
|
53
|
+
self.assertIn('distance', result)
|
|
54
|
+
self.assertIn('benchmark_comparison', result)
|
|
55
|
+
|
|
56
|
+
def test_directions(self):
|
|
57
|
+
"""Test manual directions"""
|
|
58
|
+
model = IBRAHIM(auto_weights=False)
|
|
59
|
+
directions = {'A': 'max', 'B': 'min', 'C': 'max'}
|
|
60
|
+
model.fit(self.data, directions=directions)
|
|
61
|
+
|
|
62
|
+
self.assertEqual(model.directions_, directions)
|
|
63
|
+
|
|
64
|
+
def test_weights(self):
|
|
65
|
+
"""Test manual weights"""
|
|
66
|
+
model = IBRAHIM(auto_weights=False)
|
|
67
|
+
weights = {'A': 0.5, 'B': 0.3, 'C': 0.2}
|
|
68
|
+
model.fit(self.data, weights=weights)
|
|
69
|
+
|
|
70
|
+
# Weights should be normalized
|
|
71
|
+
self.assertAlmostEqual(sum(model.weights_.values()), 1.0)
|
|
72
|
+
|
|
73
|
+
def test_score_range(self):
|
|
74
|
+
"""Test scores are between 0 and 100"""
|
|
75
|
+
model = IBRAHIM(auto_weights=True)
|
|
76
|
+
model.fit(self.data)
|
|
77
|
+
|
|
78
|
+
rankings = model.rank()
|
|
79
|
+
|
|
80
|
+
self.assertTrue(all(rankings['score'] >= 0))
|
|
81
|
+
self.assertTrue(all(rankings['score'] <= 100))
|
|
82
|
+
|
|
83
|
+
def test_different_normalizations(self):
|
|
84
|
+
"""Test different normalization methods"""
|
|
85
|
+
for norm in ['minmax', 'zscore', 'robust']:
|
|
86
|
+
model = IBRAHIM(normalization=norm)
|
|
87
|
+
model.fit(self.data)
|
|
88
|
+
self.assertEqual(model.normalization, norm)
|
|
89
|
+
|
|
90
|
+
def test_different_distances(self):
|
|
91
|
+
"""Test different distance metrics"""
|
|
92
|
+
for metric in ['euclidean', 'manhattan']:
|
|
93
|
+
model = IBRAHIM(distance_metric=metric)
|
|
94
|
+
model.fit(self.data)
|
|
95
|
+
self.assertEqual(model.distance_metric, metric)
|
|
96
|
+
|
|
97
|
+
if __name__ == '__main__':
|
|
98
|
+
unittest.main()
|