Last active
September 9, 2025 12:33
-
-
Save houmanka/d828518b070af514c339d9efa548f525 to your computer and use it in GitHub Desktop.
Handle ML functions
This file contains hidden or 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
| # Usage: | |
| # !git clone https://gist.github.com/d828518b070af514c339d9efa548f525.git gist_code | |
| # !ls -la gist_code | |
| # import glob, importlib.util, sys | |
| # | |
| # helper_path = glob.glob("gist_code/*.py")[0] | |
| # spec = importlib.util.spec_from_file_location("helpers", helper_path) | |
| # helpers = importlib.util.module_from_spec(spec) | |
| # sys.modules["helpers"] = helpers | |
| # spec.loader.exec_module(helpers) | |
| # | |
| # print("Loaded:", helper_path) | |
| # print("Found functions:", [n for n in dir(helpers) if not n.startswith("_")]) | |
| def plot_label_distribution(df, label_col): | |
| import seaborn as sns, matplotlib.pyplot as plt | |
| plt.figure(figsize=(8, 4)) | |
| sns.countplot(y=df[label_col], order=df[label_col].value_counts().index) | |
| plt.title("Label distribution") | |
| plt.tight_layout() | |
| plt.show() | |
| # kaggle_dataset_download("a_name", file_type="*.csv") | |
| def kaggle_dataset_download(dataset_name: str, file_type: str): | |
| import kagglehub | |
| import os, glob | |
| path = kagglehub.dataset_download(dataset_name) | |
| csv_files = glob.glob(os.path.join(path, file_type)) | |
| return csv_files |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment