modulift 0.0.2__tar.gz → 0.0.3__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.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: modulift
3
- Version: 0.0.2
3
+ Version: 0.0.3
4
4
  Summary: A powerful search tool for discovering Python packages based on user queries
5
5
  Home-page: https://github.com/okanyenigun/modulift
6
6
  Author: Okan Yenigün
@@ -68,7 +68,7 @@ print(result)
68
68
  'package': 'numpy',
69
69
  'description': 'NumPy is the fundamental package for scientific computing with Python. It provides powerful N-dimensional arrays, sophisticated mathematical functions, tools for integrating C/C++ and Fortran code, and useful linear algebra, Fourier transform, and random number capabilities.',
70
70
  'keywords': 'scientific computing, array, linear algebra, Fourier transform, random number generation, data processing, numerical analysis',
71
- 'popularity': 'very popular'
71
+ 'popularity': 5
72
72
  }
73
73
  ```
74
74
 
@@ -86,7 +86,7 @@ print(result)
86
86
  'package': 'nullsweep',
87
87
  'description': 'NullSweep is a Python library designed for detecting and handling patterns of missing data in pandas DataFrames. It provides a simple API to identify global missing data patterns across the entire dataset, patterns related to specific features within the dataset, and to impute missing values using various strategies.',
88
88
  'keywords': 'missing data, data imputation, pandas, pattern detection, feature-specific patterns',
89
- 'popularity': 'popular'
89
+ 'popularity': 4
90
90
  }
91
91
  ```
92
92
 
@@ -101,7 +101,7 @@ result = mf.search_by_package_name("numpy", markdown=True)
101
101
 
102
102
  - **Description**: NumPy is the fundamental package for scientific computing with Python. It provides powerful N-dimensional arrays, sophisticated mathematical functions, tools for integrating C/C++ and Fortran code, and useful linear algebra, Fourier transform, and random number capabilities.
103
103
  - **Keywords**: scientific computing, array, linear algebra, Fourier transform, random number generation, data processing, numerical analysis
104
- - **Popularity**: very popular
104
+ - **Popularity**: 5
105
105
 
106
106
  ### 2. Search by Keywords
107
107
 
@@ -145,7 +145,7 @@ Markdown Output
145
145
 
146
146
  - **Description**: The SageMaker Python SDK is an open-source library designed for training and deploying machine learning models on Amazon SageMaker. It supports popular deep learning frameworks like Apache MXNet and TensorFlow, as well as Amazon's own scalable algorithms optimized for SageMaker. Users can also deploy custom algorithms in Docker containers, making it versatile for various machine learning tasks.
147
147
  - **Keywords**: machine learning, deep learning, model deployment, Amazon SageMaker, data science, AI, Docker
148
- - **Popularity**: very popular
148
+ - **Popularity**: 5
149
149
 
150
150
  ---
151
151
 
@@ -153,7 +153,7 @@ Markdown Output
153
153
 
154
154
  - **Description**: fastbook is a comprehensive resource for learning deep learning through practical coding examples using the fastai library and PyTorch. It is designed for coders of all backgrounds, providing accessible education on deep learning techniques and applications across various domains, including computer vision and natural language processing.
155
155
  - **Keywords**: deep learning, fastai, PyTorch, computer vision, natural language processing, machine learning, data science, Jupyter Notebooks
156
- - **Popularity**: very popular
156
+ - **Popularity**: 5
157
157
 
158
158
  ---
159
159
 
@@ -161,7 +161,7 @@ Markdown Output
161
161
 
162
162
  - **Description**: ProAiLab is a Python library designed for building and deploying AI models. It provides tools for data preprocessing, model training, and evaluation, making it suitable for both beginners and experienced machine learning practitioners.
163
163
  - **Keywords**: machine learning, AI, deep learning, data science, model development
164
- - **Popularity**: popular
164
+ - **Popularity**: 4
165
165
 
166
166
  ### 3. Full-Text Search in Descriptions
167
167
 
@@ -177,7 +177,15 @@ Markdown Output
177
177
 
178
178
  - **Description**: The SageMaker Python SDK is an open-source library designed for training and deploying machine learning models on Amazon SageMaker. It supports popular deep learning frameworks like Apache MXNet and TensorFlow, as well as Amazon's own scalable algorithms optimized for SageMaker. Users can also deploy custom algorithms in Docker containers, making it versatile for various machine learning tasks.
179
179
  - **Keywords**: machine learning, deep learning, model deployment, Amazon SageMaker, data science, AI, Docker
180
- - **Popularity**: very popular
180
+ - **Popularity**: 5
181
+
182
+ ### 4. Find Similar Packages
183
+
184
+ Use cosine similarity to identify packages similar to a given package name.
185
+
186
+ ```python
187
+ similar_packages = mf.find_similar_package("nullsweep")
188
+ ```
181
189
 
182
190
  ## License
183
191
 
@@ -0,0 +1,3 @@
1
+ from .api import *
2
+
3
+ __version__ = '0.0.3'
@@ -1,5 +1,7 @@
1
+ from sklearn.feature_extraction.text import TfidfVectorizer
2
+ from sklearn.metrics.pairwise import cosine_similarity
1
3
  from IPython.display import display, Markdown
2
- from typing import List, Optional
4
+ from typing import List, Optional, Dict, Any
3
5
  from .data import load_data
4
6
 
5
7
 
@@ -226,4 +228,86 @@ def search_by_description(text: str, limit: Optional[int] = None, markdown: bool
226
228
  display(Markdown(markdown_text))
227
229
  else:
228
230
  print(f"No matches found for the text '{text}'.")
229
- return results
231
+ return results
232
+
233
+
234
+ def find_similar_package(package_name: str, top_n: int=5, markdown: bool=False) -> List[Dict[str, Any]]:
235
+ """
236
+ Finds and returns a list of packages similar to the given package based on textual similarity.
237
+
238
+ This function uses TF-IDF (Term Frequency-Inverse Document Frequency) vectorization and cosine similarity
239
+ to compare package descriptions and keywords. It identifies the most relevant packages based on
240
+ text similarity, ranking them from highest to lowest similarity.
241
+
242
+ If `markdown=True`, the results will also be displayed in a structured Markdown format (suitable for Jupyter Notebook usage).
243
+
244
+ Args:
245
+ package_name (str): The name of the package for which similar packages should be retrieved.
246
+ top_n (int, optional): The number of similar packages to return. Defaults to 5.
247
+ markdown (bool, optional): Whether to display the results in a Markdown table (useful in Jupyter). Defaults to False.
248
+
249
+ Returns:
250
+ List[Dict[str, Any]]: A list of dictionaries, where each dictionary contains:
251
+ - "package" (str): The name of the similar package.
252
+ - "description" (str): The description of the similar package.
253
+ - "similarity_score" (float): A numerical score representing similarity (range: 0 to 1).
254
+
255
+ Raises:
256
+ ValueError: If the provided `package_name` is not found in the dataset.
257
+ TypeError: If `package_name` is not a string, `top_n` is not a positive integer, or `markdown` is not a boolean.
258
+
259
+ Example:
260
+ >>> find_similar_package("numpy", top_n=3, markdown=False)
261
+ [
262
+ {"package": "scipy", "description": "Scientific computing library", "similarity_score": 0.89},
263
+ {"package": "pandas", "description": "Data analysis library", "similarity_score": 0.75},
264
+ {"package": "matplotlib", "description": "Plotting library", "similarity_score": 0.72}
265
+ ]
266
+
267
+ # If markdown=True in a Jupyter Notebook, it will also display a formatted table.
268
+ """
269
+ if not isinstance(package_name, str):
270
+ raise TypeError(f"Expected 'package_name' to be a string, got {type(package_name).__name__}.")
271
+ if not isinstance(top_n, int) or top_n <= 0:
272
+ raise TypeError(f"'top_n' should be a positive integer, got {top_n}.")
273
+ if not isinstance(markdown, bool):
274
+ raise TypeError(f"'markdown' should be a boolean, got {type(markdown).__name__}.")
275
+
276
+ df = load_data()
277
+
278
+ package_row = df.query("package == @package_name")
279
+
280
+ if package_row.empty:
281
+ raise ValueError(f"No package found with the name '{package_name}'. Ensure the name is correct.")
282
+
283
+ package_idx = package_row.index[0]
284
+
285
+ df["combined_text"] = df["description"].fillna("") + " " + df["keywords"].fillna("")
286
+
287
+ tfidf_vectorizer = TfidfVectorizer(stop_words="english")
288
+ tfidf_matrix = tfidf_vectorizer.fit_transform(df["combined_text"])
289
+
290
+ cosine_similarities = cosine_similarity(tfidf_matrix[package_idx], tfidf_matrix).flatten()
291
+
292
+ similar_indices = cosine_similarities.argsort()[::-1][1 : top_n + 1]
293
+
294
+ similar_packages = [
295
+ {
296
+ "package": df.iloc[i]["package"],
297
+ "description": df.iloc[i]["description"],
298
+ "similarity_score": round(cosine_similarities[i], 4),
299
+ }
300
+ for i in similar_indices
301
+ ]
302
+
303
+ if markdown:
304
+ markdown_text = f"### Similar Packages to '{package_name}'\n"
305
+ for package in similar_packages:
306
+ markdown_text += f"""
307
+ **{package['package']}**
308
+ - **Description**: {package['description']}
309
+ - **Similarity Score**: {package['similarity_score']}
310
+ """
311
+ display(Markdown(markdown_text))
312
+
313
+ return similar_packages
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: modulift
3
- Version: 0.0.2
3
+ Version: 0.0.3
4
4
  Summary: A powerful search tool for discovering Python packages based on user queries
5
5
  Home-page: https://github.com/okanyenigun/modulift
6
6
  Author: Okan Yenigün
@@ -68,7 +68,7 @@ print(result)
68
68
  'package': 'numpy',
69
69
  'description': 'NumPy is the fundamental package for scientific computing with Python. It provides powerful N-dimensional arrays, sophisticated mathematical functions, tools for integrating C/C++ and Fortran code, and useful linear algebra, Fourier transform, and random number capabilities.',
70
70
  'keywords': 'scientific computing, array, linear algebra, Fourier transform, random number generation, data processing, numerical analysis',
71
- 'popularity': 'very popular'
71
+ 'popularity': 5
72
72
  }
73
73
  ```
74
74
 
@@ -86,7 +86,7 @@ print(result)
86
86
  'package': 'nullsweep',
87
87
  'description': 'NullSweep is a Python library designed for detecting and handling patterns of missing data in pandas DataFrames. It provides a simple API to identify global missing data patterns across the entire dataset, patterns related to specific features within the dataset, and to impute missing values using various strategies.',
88
88
  'keywords': 'missing data, data imputation, pandas, pattern detection, feature-specific patterns',
89
- 'popularity': 'popular'
89
+ 'popularity': 4
90
90
  }
91
91
  ```
92
92
 
@@ -101,7 +101,7 @@ result = mf.search_by_package_name("numpy", markdown=True)
101
101
 
102
102
  - **Description**: NumPy is the fundamental package for scientific computing with Python. It provides powerful N-dimensional arrays, sophisticated mathematical functions, tools for integrating C/C++ and Fortran code, and useful linear algebra, Fourier transform, and random number capabilities.
103
103
  - **Keywords**: scientific computing, array, linear algebra, Fourier transform, random number generation, data processing, numerical analysis
104
- - **Popularity**: very popular
104
+ - **Popularity**: 5
105
105
 
106
106
  ### 2. Search by Keywords
107
107
 
@@ -145,7 +145,7 @@ Markdown Output
145
145
 
146
146
  - **Description**: The SageMaker Python SDK is an open-source library designed for training and deploying machine learning models on Amazon SageMaker. It supports popular deep learning frameworks like Apache MXNet and TensorFlow, as well as Amazon's own scalable algorithms optimized for SageMaker. Users can also deploy custom algorithms in Docker containers, making it versatile for various machine learning tasks.
147
147
  - **Keywords**: machine learning, deep learning, model deployment, Amazon SageMaker, data science, AI, Docker
148
- - **Popularity**: very popular
148
+ - **Popularity**: 5
149
149
 
150
150
  ---
151
151
 
@@ -153,7 +153,7 @@ Markdown Output
153
153
 
154
154
  - **Description**: fastbook is a comprehensive resource for learning deep learning through practical coding examples using the fastai library and PyTorch. It is designed for coders of all backgrounds, providing accessible education on deep learning techniques and applications across various domains, including computer vision and natural language processing.
155
155
  - **Keywords**: deep learning, fastai, PyTorch, computer vision, natural language processing, machine learning, data science, Jupyter Notebooks
156
- - **Popularity**: very popular
156
+ - **Popularity**: 5
157
157
 
158
158
  ---
159
159
 
@@ -161,7 +161,7 @@ Markdown Output
161
161
 
162
162
  - **Description**: ProAiLab is a Python library designed for building and deploying AI models. It provides tools for data preprocessing, model training, and evaluation, making it suitable for both beginners and experienced machine learning practitioners.
163
163
  - **Keywords**: machine learning, AI, deep learning, data science, model development
164
- - **Popularity**: popular
164
+ - **Popularity**: 4
165
165
 
166
166
  ### 3. Full-Text Search in Descriptions
167
167
 
@@ -177,7 +177,15 @@ Markdown Output
177
177
 
178
178
  - **Description**: The SageMaker Python SDK is an open-source library designed for training and deploying machine learning models on Amazon SageMaker. It supports popular deep learning frameworks like Apache MXNet and TensorFlow, as well as Amazon's own scalable algorithms optimized for SageMaker. Users can also deploy custom algorithms in Docker containers, making it versatile for various machine learning tasks.
179
179
  - **Keywords**: machine learning, deep learning, model deployment, Amazon SageMaker, data science, AI, Docker
180
- - **Popularity**: very popular
180
+ - **Popularity**: 5
181
+
182
+ ### 4. Find Similar Packages
183
+
184
+ Use cosine similarity to identify packages similar to a given package name.
185
+
186
+ ```python
187
+ similar_packages = mf.find_similar_package("nullsweep")
188
+ ```
181
189
 
182
190
  ## License
183
191
 
@@ -1,4 +1,6 @@
1
1
  datasets==3.1.0
2
+ scikit-learn==1.6.1
3
+ ipywidgets==8.1.5
2
4
 
3
5
  [dev]
4
6
  twine==5.1.1
@@ -7,7 +7,7 @@ with open("Readme.md", "r") as f:
7
7
 
8
8
  setup(
9
9
  name="modulift",
10
- version="0.0.2",
10
+ version="0.0.3",
11
11
  description="A powerful search tool for discovering Python packages based on user queries",
12
12
  packages=find_packages(),
13
13
  long_description=long_description,
@@ -35,7 +35,9 @@ setup(
35
35
  'Operating System :: OS Independent'
36
36
  ],
37
37
  install_requires=[
38
- 'datasets==3.1.0'
38
+ 'datasets==3.1.0',
39
+ 'scikit-learn==1.6.1',
40
+ 'ipywidgets==8.1.5',
39
41
  ],
40
42
  extras_require={
41
43
  'dev': ['twine==5.1.1'],
@@ -1,3 +0,0 @@
1
- from .api import *
2
-
3
- __version__ = '0.0.2'
File without changes
File without changes