### Run Training Pipeline with Configuration Source: https://github.com/niketkumardheeryan/ml-capsule/wiki/_Sidebar Example command to start a model training pipeline using a specified configuration file. Ensure the path to the script and config file are correct. ```bash python src/train_model.py --config config.yaml ``` -------------------------------- ### Setup and Run Chicken Disease Classification Pipeline Source: https://context7.com/niketkumardheeryan/ml-capsule/llms.txt Commands to set up the Python environment, install dependencies, initialize DVC, and run the training pipeline. Includes instructions for starting the MLflow experiment tracker. ```bash # 1. Setup environment conda create -n cnncls python=3.8 -y && conda activate cnncls pip install -r requirements.txt # 2. Run full training pipeline (DVC) dvc init && dvc repro # OR run stages individually: python main.py # 3. Start MLflow experiment tracker export MLFLOW_TRACKING_URI=https://dagshub.com//project.mlflow export MLFLOW_TRACKING_USERNAME= export MLFLOW_TRACKING_PASSWORD= mlflow ui # browse at http://localhost:5000 ``` -------------------------------- ### Python Environment Setup Source: https://github.com/niketkumardheeryan/ml-capsule/blob/master/Machine Hack -1.ipynb This code block sets up a Python 3 environment on Kaggle, including comments on how to list input files and save output. It's a standard starting point for Kaggle notebooks. ```python # This Python 3 environment comes with many helpful analytics libraries installed # It is defined by the kaggle/python Docker image: https://github.com/kaggle/docker-python # For example, here's several helpful packages to load #import numpy as np # linear algebra #import pandas as pd # data processing, CSV file I/O (e.g. pd.read_csv) # Input data files are available in the read-only "../input/" directory # For example, running this (by clicking run or pressing Shift+Enter) will list all files under the input directory #import os #for dirname, _, filenames in os.walk('/kaggle/input'): # for filename in filenames: # print(os.path.join(dirname, filename)) # You can write up to 20GB to the current directory (/kaggle/working/) that gets preserved as output when you create a version using "Save & Run All" # You can also write temporary files to /kaggle/temp/, but they won't be saved outside of the current session ``` -------------------------------- ### Clone and Install iconv-lite Source: https://github.com/niketkumardheeryan/ml-capsule/blob/master/Social Media Fake Accounts Detection with Interactive UI/server/node_modules/iconv-lite/README.md Clone the repository, navigate to the directory, and install dependencies using npm. ```bash git clone git@github.com:ashtuchkin/iconv-lite.git cd iconv-lite npm install ``` -------------------------------- ### Basic GET Request with Needle Source: https://github.com/niketkumardheeryan/ml-capsule/blob/master/Social Media Fake Accounts Detection with Interactive UI/server/node_modules/needle/README.md Demonstrates how to perform a basic GET request using the Needle library. Ensure Needle is installed and imported before use. ```javascript var needle = require('needle'); needle.get('http://www.google.com', function(error, response, body) { console.log('Got response: ', response.statusCode); }); ``` -------------------------------- ### Install Necessary Libraries Source: https://github.com/niketkumardheeryan/ml-capsule/blob/master/Bidirectional LSTM/README.md Installs the required Python libraries for the project. Ensure these are installed before running the code. ```bash pip install pandas pip install tensorflow pip install numpy pip install sklearn pip install keras ``` -------------------------------- ### Install Dependencies Source: https://github.com/niketkumardheeryan/ml-capsule/blob/master/Indian Elections/Election_prediction-WebApp/Readme.md Installs the necessary Python libraries for the application. Ensure you have Python and pip installed. ```bash pip install streamlit pandas numpy seaborn scikit-learn matplotlib ``` -------------------------------- ### Install LightGBM Source: https://github.com/niketkumardheeryan/ml-capsule/blob/master/Machine Hack -1.ipynb Installs the LightGBM library. This is a prerequisite for using LightGBM models. ```python #!pip install lightgbm ``` -------------------------------- ### Clone Repository and Install Dependencies Source: https://github.com/niketkumardheeryan/ml-capsule/blob/master/Lane Line Detection [OPEN CV]/README.md Instructions for cloning the project repository and installing necessary Python packages. ```bash git clone https://github.com/your_username/Lane-Line-Detection.git cd Lane-Line-Detection ``` -------------------------------- ### Install Project Dependencies Source: https://github.com/niketkumardheeryan/ml-capsule/blob/master/Skin Disease Predictor/README.md Installs the necessary Python libraries for the project. Ensure these are installed before running the project. ```bash pip install keras pip install tensorflow pip install numpy pip install glob ``` -------------------------------- ### Install pyttsx3 Library Source: https://github.com/niketkumardheeryan/ml-capsule/blob/master/Sign-Language-Translator/code file sign language translator.ipynb Installs the pyttsx3 library, used for text-to-speech conversion to vocalize translated sign language. ```bash pip install pyttsx3 ``` -------------------------------- ### Install CatBoost Source: https://github.com/niketkumardheeryan/ml-capsule/blob/master/Machine Hack -1.ipynb Installs the CatBoost library. This is required for using CatBoost models. ```python #!pip install catboost ``` -------------------------------- ### Install Dependencies Source: https://github.com/niketkumardheeryan/ml-capsule/blob/master/Employee_attrittion_prediction_using_ML/readme.md Install all necessary Python packages listed in the requirements.txt file. ```sh pip install -r requirements.txt ``` -------------------------------- ### Install PyCaret Source: https://github.com/niketkumardheeryan/ml-capsule/blob/master/Statistical_modeling_python/Statistical_modeling.ipynb Installs the PyCaret library using pip. Ensure you have pip installed and updated. ```bash pip install pycaret ``` -------------------------------- ### Install Project Dependencies Source: https://github.com/niketkumardheeryan/ml-capsule/blob/master/Poker Hand Prediction/README.md Installs necessary Python libraries for the project using pip. Ensure these are installed before running the notebook. ```bash pip install pandas numpy scikit-learn matplotlib seaborn ``` -------------------------------- ### Install PyTorch Source: https://github.com/niketkumardheeryan/ml-capsule/blob/master/Machine Hack -1.ipynb Installs the PyTorch library. This command is executed in a shell environment. ```bash ! pip install torch ``` -------------------------------- ### Install Dependencies Source: https://github.com/niketkumardheeryan/ml-capsule/blob/master/Artifical neural network from scratch/README.md Install the required dependencies for the project using pip. ```bash pip install -r requirements.txt ``` -------------------------------- ### Install Dependencies with Pip Source: https://github.com/niketkumardheeryan/ml-capsule/blob/master/MNIST English Classification/Readme.md Installs the necessary Python libraries for the project. Ensure you have pip installed. ```bash pip install torch torchvision numpy pandas seaborn matplotlib scikit-learn ``` -------------------------------- ### Install dotenv with npm Source: https://github.com/niketkumardheeryan/ml-capsule/blob/master/Social Media Fake Accounts Detection with Interactive UI/server/node_modules/dotenv/README.md Install dotenv locally to your project using npm. This is the recommended installation method. ```bash npm install dotenv --save ``` -------------------------------- ### Install and Import Libraries Source: https://github.com/niketkumardheeryan/ml-capsule/blob/master/Web-Scraping-with-Beautiful-Soup-master/scrape_amazon_reviews.ipynb Installs and imports necessary libraries for web scraping, including requests and BeautifulSoup. Ensure these are installed before running the script. ```python import requests from bs4 import BeautifulSoup ``` -------------------------------- ### Install DBGenie Package Source: https://github.com/niketkumardheeryan/ml-capsule/blob/master/PyPI Package/README.md Install the DBGenie package using pip. This command fetches and installs the latest version from the Python Package Index. ```bash pip install dbgenie2 ``` -------------------------------- ### Install Dependencies and Run Tests Source: https://github.com/niketkumardheeryan/ml-capsule/blob/master/Social Media Fake Accounts Detection with Interactive UI/server/node_modules/cors/CONTRIBUTING.md Before submitting a pull request, ensure you have installed the necessary dependencies and that all tests pass. ```bash npm install npm test ``` -------------------------------- ### Install mediapipe Library Source: https://github.com/niketkumardheeryan/ml-capsule/blob/master/Sign-Language-Translator/code file sign language translator.ipynb Installs the mediapipe library, which is essential for hand tracking and gesture recognition. ```bash pip install mediapipe ``` -------------------------------- ### Install apyori library Source: https://github.com/niketkumardheeryan/ml-capsule/blob/master/market-basket-recommendation/Apriori.ipynb Installs the apyori library, which is necessary for implementing the Apriori algorithm. ```python !pip install apyori ``` -------------------------------- ### Install Project Dependencies Source: https://github.com/niketkumardheeryan/ml-capsule/blob/master/Automated Financial Reporting with Deep Learning/readme.md Installs the necessary Python packages for the project. Ensure you have pip available. ```bash pip install pandas numpy scikit-learn tensorflow ``` -------------------------------- ### Clone Repository and Navigate Source: https://github.com/niketkumardheeryan/ml-capsule/blob/master/Spam Mail Classifier/README.md Clone the project repository and navigate into the project directory. This is the first step for local setup. ```sh git clone https://github.com/yourusername/spam-mail-detection.git cd spam-mail-detection ``` -------------------------------- ### Install PyCaret Library Source: https://github.com/niketkumardheeryan/ml-capsule/blob/master/Machine Hack -1.ipynb Installs the PyCaret library, a low-code machine learning tool, using pip. ```python #! pip install pycaret ``` -------------------------------- ### Install tld library Source: https://github.com/niketkumardheeryan/ml-capsule/blob/master/Malicious Url Detection/MaliciousUrlDetection.ipynb Installs the 'tld' library, which is used for extracting the Top Level Domain from URLs. ```bash !pip install tld ``` -------------------------------- ### Run the Application Source: https://github.com/niketkumardheeryan/ml-capsule/blob/master/Chicken_Disease_Classification/README.md Execute the main application script to start the project. Access the application via your local host and port. ```bash python app.py ``` ```bash open up you local host and port ``` -------------------------------- ### Get Unique Start Locations Source: https://github.com/niketkumardheeryan/ml-capsule/blob/master/UBER_DATA_ANALYSIS.ipynb Extracts the 'START*' column, removes any missing values, and converts it into a set to get a collection of unique starting locations. Useful for understanding the geographical scope of the rides. ```python start= df['START*'].dropna() un_start=set(start) un_start ``` -------------------------------- ### Install TensorFlow Source: https://github.com/niketkumardheeryan/ml-capsule/blob/master/Sudoku Solver using CNN/sudoku.ipynb Installs the TensorFlow library, which is required for building and running the CNN model. ```bash pip install tensorflow ``` -------------------------------- ### Install scikit-optimize Source: https://github.com/niketkumardheeryan/ml-capsule/blob/master/HyperParameter Tuning/Bayesian Optimization/GaussianProcesses.ipynb Installs the scikit-optimize library, which is used for hyperparameter tuning. ```bash !pip install scikit-optimize ``` -------------------------------- ### Promise-based GET Request Example Source: https://github.com/niketkumardheeryan/ml-capsule/blob/master/Social Media Fake Accounts Detection with Interactive UI/server/node_modules/needle/README.md An example of making a GET request using Promises. The response and potential errors are handled using .then() and .catch(). ```javascript // using promises needle('get', 'https://server.com/posts/123') .then(function(resp) { // ... }) .catch(function(err) { // ... }); ``` -------------------------------- ### Clone the Repository Source: https://github.com/niketkumardheeryan/ml-capsule/blob/master/SQL injection detection/readme.md Use this command to download the project files. Navigate into the cloned directory to proceed with setup. ```bash git clone https://github.com/yourusername/sql-injection-detection.git cd sql-injection-detection ``` -------------------------------- ### Clone Repository and Navigate Source: https://github.com/niketkumardheeryan/ml-capsule/blob/master/Dark Pattern Detection/Readme.md Instructions for cloning the project repository and navigating into the project directory. ```bash git clone cd Dark Pattern Detection ``` -------------------------------- ### Basic GET Request with Callback Source: https://github.com/niketkumardheeryan/ml-capsule/blob/master/Social Media Fake Accounts Detection with Interactive UI/server/node_modules/needle/README.md Performs a simple HTTP GET request and logs the response body if successful. This is a fundamental example for fetching data from a URL. ```javascript var needle = require('needle'); needle.get('http://www.google.com', function(error, response) { if (!error && response.statusCode == 200) console.log(response.body); }); ``` -------------------------------- ### Install Requests Package Source: https://github.com/niketkumardheeryan/ml-capsule/blob/master/Web-Scraping-with-Beautiful-Soup-master/README.md Use pip to install the requests library for making HTTP requests. ```sh pip install requests ``` -------------------------------- ### Get Scikit-learn Version Source: https://github.com/niketkumardheeryan/ml-capsule/blob/master/Plagiarism-detector-using-machine-learning-main/Building Plagiarism checker using Machine Learning.ipynb Retrieves and prints the currently installed version of the scikit-learn library. ```python # sklearn version import sklearn sklearn.__version__ ``` -------------------------------- ### Install Kaggle API and Authenticate Source: https://github.com/niketkumardheeryan/ml-capsule/blob/master/Defective Captcha Image Recognition/Models/models_Defective_Captcha_Image_Recognition_.ipynb Installs the Kaggle API, uploads Kaggle credentials, and sets up the necessary directory permissions for downloading datasets. ```python !pip install -q kaggle from google.colab import files files.upload() !mkdir ~/.kaggle !cp kaggle.json ~/.kaggle/ !chmod 600 ~/.kaggle/kaggle.json ``` -------------------------------- ### Get User Input to Start or End Game Source: https://github.com/niketkumardheeryan/ml-capsule/blob/master/Rock Paper Scissors Python Game/RockPaperScissorsPythonGame.ipynb Prompts the user to start the game by entering '1' or end the game by entering '2'. Includes input validation to ensure only '1' or '2' is accepted. ```python x = int(input("(1)Start. (2)End the game. \n")) if x != 1 and x != 2: x = int(input("Invalid input! Please enter '1' or '2': \n")) ``` -------------------------------- ### Install NLTK using pip Source: https://github.com/niketkumardheeryan/ml-capsule/blob/master/NLTK Documentation/README.md Use this command to install the NLTK library on your local system. ```bash pip install nltk ``` -------------------------------- ### Stemming Example Source: https://github.com/niketkumardheeryan/ml-capsule/blob/master/NLP-Project/README.md Tokenizes a sentence and then applies stemming to each word to get its root form. Requires 'punkt' to be downloaded. ```python string_for_stemming = "The crew of the USS Discovery discovered many discoveries. Discovering is what explorers do." words = word_tokenize(string_for_stemming) words ``` ```python stemmed_words = [stemmer.stem(word) for word in words] stemmed_words ``` -------------------------------- ### Clone Repository and Navigate Source: https://github.com/niketkumardheeryan/ml-capsule/blob/master/Diseases_Prediction/Readme.md Clone the project repository and change the directory to the project's root. This is the initial step before installing dependencies. ```bash git clone https://github.com/Niketkumardheeryan/ML-CaPsule.git cd ML-CaPsule ``` -------------------------------- ### Install Contractions Library Source: https://github.com/niketkumardheeryan/ml-capsule/blob/master/Sentiment-Analysis/Sentiment_Analysis_Major_Project.ipynb Installs the 'contractions' library, which is used for expanding contracted words in text. ```bash !pip install contractions ``` -------------------------------- ### Configuration Manager for Training and Callbacks Source: https://github.com/niketkumardheeryan/ml-capsule/blob/master/Chicken_Disease_Classification/research/04_training.ipynb Manages the loading of configuration and parameters, and creates necessary directories. Use this to initialize and retrieve configurations for preparing callbacks and training. ```python import os from dataclasses import dataclass from pathlib import Path import tensorflow as tf # Assuming TrainingConfig and PrepareCallbacksConfig are defined as above class ConfigurationManager: def __init__( self, config_filepath = CONFIG_FILE_PATH, params_filepath = PARAMS_FILE_PATH): self.config = read_yaml(config_filepath) self.params = read_yaml(params_filepath) create_directories([self.config.artifacts_root]) def get_prepare_callback_config(self) -> PrepareCallbacksConfig: config = self.config.prepare_callbacks model_ckpt_dir = os.path.dirname(config.checkpoint_model_filepath) create_directories([ Path(model_ckpt_dir), Path(config.tensorboard_root_log_dir) ]) prepare_callback_config = PrepareCallbacksConfig( root_dir=Path(config.root_dir), tensorboard_root_log_dir=Path(config.tensorboard_root_log_dir), checkpoint_model_filepath=Path(config.checkpoint_model_filepath) ) return prepare_callback_config def get_training_config(self) -> TrainingConfig: training = self.config.training prepare_base_model = self.config.prepare_base_model params = self.params training_data = os.path.join(self.config.data_ingestion.unzip_dir, "Chicken-fecal-images") create_directories([ Path(training.root_dir) ]) training_config = TrainingConfig( root_dir=Path(training.root_dir), trained_model_path=Path(training.trained_model_path), updated_base_model_path=Path(prepare_base_model.updated_base_model_path), training_data=Path(training_data), params_epochs=params.EPOCHS, params_batch_size=params.BATCH_SIZE, params_is_augmentation=params.AUGMENTATION, params_image_size=params.IMAGE_SIZE ) return training_config ``` -------------------------------- ### Get TensorFlow Version Source: https://github.com/niketkumardheeryan/ml-capsule/blob/master/Pneumonia Classification using Chest X-Ray/Model/pneumonia_classification.ipynb Retrieves and prints the installed TensorFlow version. This is useful for ensuring compatibility with libraries and model architectures. ```python tf.__version__ ``` -------------------------------- ### Install Keras Source: https://github.com/niketkumardheeryan/ml-capsule/blob/master/Sudoku Solver using CNN/sudoku.ipynb Installs the Keras library, a high-level API for neural networks, often used with TensorFlow. ```bash pip install keras ``` -------------------------------- ### Custom Accept Header and Deflate Compression Source: https://github.com/niketkumardheeryan/ml-capsule/blob/master/Social Media Fake Accounts Detection with Interactive UI/server/node_modules/needle/README.md Example of making a GET request with a custom Accept header and enabling deflate compression. ```APIDOC ## Custom Accept header, deflate ### Description Makes a GET request with a custom Accept header and enables deflate compression. ### Method GET ### Endpoint `api.github.com/users/tomas` ### Parameters #### Request Body - **compressed** (boolean) - Optional - Set to `true` to enable deflate compression. - **follow** (number) - Optional - The maximum number of redirects to follow. - **accept** (string) - Optional - The value for the Accept header. ### Request Example ```js var options = { compressed : true, follow : 10, accept : 'application/vnd.github.full+json' } needle.get('api.github.com/users/tomas', options, function(err, resp, body) { // body will contain a JSON.parse(d) object // if parsing fails, you'll simply get the original body }); ``` ``` -------------------------------- ### JavaScript for DOM Ready Installation Source: https://github.com/niketkumardheeryan/ml-capsule/blob/master/Dark Pattern Detection/Tesseract-OCR/unicharambigs.5.html This JavaScript function installs footnote and table of contents generation logic. It uses `setInterval` to periodically check for DOM readiness and then calls the respective functions. It also attaches an event listener for `DOMContentLoaded` or `window.onload` for initial setup. ```javascript var timerId; function reinstall() { asciidoc.footnotes(); if (toclevels) asciidoc.toc(toclevels); } function reinstallAndRemoveTimer() { clearInterval(timerId); reinstall(); } timerId = setInterval(reinstall, 500); if (document.addEventListener) document.addEventListener("DOMContentLoaded", reinstallAndRemoveTimer, false); else window.onload = reinstallAndRemoveTimer; ``` -------------------------------- ### Instantiate and Get Callback List Source: https://github.com/niketkumardheeryan/ml-capsule/blob/master/Chicken_Disease_Classification/research/03_prepare_callbacks.ipynb Instantiates the ConfigurationManager and PrepareCallback classes, then retrieves the list of callbacks. Includes basic error handling. ```python try: config = ConfigurationManager() prepare_callbacks_config = config.get_prepare_callback_config() prepare_callbacks = PrepareCallback(config=prepare_callbacks_config) callback_list = prepare_callbacks.get_tb_ckpt_callbacks() except Exception as e: raise e ``` -------------------------------- ### Load Seaborn Dataset and Display Head Source: https://github.com/niketkumardheeryan/ml-capsule/blob/master/Visualization with Seaborn & Matplotlib.ipynb Imports the Seaborn library and loads the 'tips' dataset. Use this to get started with sample data for visualization. ```python import seaborn as sns # importing seaborn library #getting data inbuilt df=sns.load_dataset('tips') # Dataset df.head() ``` -------------------------------- ### Get Dataset Index Locations Source: https://github.com/niketkumardheeryan/ml-capsule/blob/master/Covid_Third_Wave_Forecasting/covid-19-forecasting-using-arima.ipynb This snippet retrieves the start and end indices for specific dates within a dataset. It's useful for slicing time series data. ```python start = dataset.index.get_loc('2020-05-1') end = dataset.index.get_loc('2022-02-02') print(start,'to',end) ``` -------------------------------- ### DVC Commands Source: https://github.com/niketkumardheeryan/ml-capsule/blob/master/Chicken_Disease_Classification/README.md Initialize DVC, reproduce experiments, and view the DVC DAG. ```bash dvc init ``` ```bash dvc repro ``` ```bash dvc dag ``` -------------------------------- ### Clone Repository and Install Dependencies Source: https://github.com/niketkumardheeryan/ml-capsule/blob/master/face-recognition/Readme.md Clone the ML-CaPsule repository and install the required Python packages using pip. ```bash git clone https://github.com/Raghucharan16/ML-CaPsule.git cd ML-CaPsule/face-recognition ``` ```bash pip install -r requirements.txt ``` -------------------------------- ### Initialize and Reset Hedging Environment Source: https://github.com/niketkumardheeryan/ml-capsule/blob/master/Dynamic Hedging Strategies using Reinforcement Learning/Dynamic_Hedging_StrategiesReinforcementLear.ipynb Initializes the hedging environment with provided data and resets it to get the initial observation. This is a common starting point for any reinforcement learning task. ```python env = HedgingEnv(data) initial_observation = env.reset() print(initial_observation) ``` -------------------------------- ### Import Libraries and Setup Source: https://github.com/niketkumardheeryan/ml-capsule/blob/master/Chronic Kidney Disease Prediction/Chronic_kidney_disease_prediction.ipynb Imports necessary libraries for data manipulation, visualization, and machine learning. Sets up plotting style and display options. ```python import pandas as pd import numpy as np import matplotlib.pyplot as plt import seaborn as sns import plotly.express as px import warnings warnings.filterwarnings('ignore') plt.style.use('fivethirtyeight') %matplotlib inline pd.set_option('display.max_columns', 26) from mlxtend.plotting import plot_confusion_matrix ``` -------------------------------- ### Starting TensorBoard for Visualization Source: https://github.com/niketkumardheeryan/ml-capsule/blob/master/Football_Analyser_using_YOLO/training/Football_training_yolov5.ipynb This command initiates TensorBoard, a visualization tool for machine learning experiments. It allows you to monitor training metrics, view model graphs, and analyze results. The log directory specifies where training logs are stored. ```bash tensorboard --logdir runs/detect/train2 --view at http://localhost:6006/ ``` -------------------------------- ### Initialize RL Agent and Environment Source: https://github.com/niketkumardheeryan/ml-capsule/blob/master/Dynamic Hedging Strategies using Reinforcement Learning/Dynamic_Hedging_StrategiesReinforcementLear.ipynb Sets up the state and action sizes for the RL agent and initializes the DQNAgent. This is a prerequisite for training. ```python state_size = 5 action_size = 3 agent = DQNAgent(state_size, action_size) ``` -------------------------------- ### Update Many Documents in PyMongo Source: https://github.com/niketkumardheeryan/ml-capsule/blob/master/Basics of ML and DL/ML/pymongo tutorial.ipynb Modify all documents that match the specified query criteria using `update_many()`. This example uses a regular expression to find names starting with 'S' and updates their name. ```python myquery = { "name": { "$regex": "^S" } } newvalues = { "$set": { "name": "Minnie" } } collection.update_many(myquery, newvalues) ``` -------------------------------- ### Run Objective Function with Default Hyperparameters Source: https://github.com/niketkumardheeryan/ml-capsule/blob/master/HyperParameter Tuning/Bayesian Optimization/SMAC(SequentialModelBasedAlgorithmConfiguration).ipynb Executes the defined objective function with a set of default hyperparameters to test the setup. This is useful for verifying the function's behavior before starting the full optimization. ```python # Ppassing some default hyper-parameters. default_parameters = [1e-5, 1, 1, 16, 'relu'] objective(x=default_parameters) ``` -------------------------------- ### Initialize LightGBM Parameters and Variables Source: https://github.com/niketkumardheeryan/ml-capsule/blob/master/ensemble-methods-notebooks-master/Ch5.5-case-study-document-retrieval.ipynb Imports necessary libraries and defines fixed parameters for LightGBM, including early stopping and evaluation metrics. It also sets up variables for hyperparameter tuning and performance tracking. ```python # LightGBM has numerous parameters that we want to optimize over import numpy as np from scipy.stats import randint, uniform from sklearn.model_selection import RandomizedSearchCV from sklearn.metrics import accuracy_score import lightgbm as lgb import time fixed_params = {'early_stopping_rounds': 25, 'eval_metric' : 'multi_logloss', 'eval_set' : [(Xtst, ytst)], 'eval_names': ['test set'], 'verbose': 100} num_random_iters = 20 num_cv_folds = 5 cv_scores = {} tst_scores = {} run_time = {} ``` -------------------------------- ### Clone Repository and Navigate Source: https://github.com/niketkumardheeryan/ml-capsule/blob/master/MNIST English Classification/Readme.md Clones the ML-CaPsule repository and navigates into the specific project directory. This is the first step to set up the project locally. ```bash git https://github.com/Niketkumardheeryan/ML-CaPsule.git cd MNIST English Classification cd CNN cd .py files ``` -------------------------------- ### Get File Dataset Loader Source: https://github.com/niketkumardheeryan/ml-capsule/blob/master/Music Generation using LSTM/Music_Generation.ipynb Initializes a dataset loader for audio files using glob patterns. Configures parameters for audio processing, batching, and shuffling. This function is a starting point for creating a data pipeline. ```python def get_files_dataset( glob_location, total_seconds=2, out_len = 3.3, hop_size=1, max_feats = 2048, batch_size=4, shuffer_size=1000, scale=1, rate=10_000, mdct_feats=256 ): """Get file dataset loader for a glob of audio files.""" files = glob( glob_location, recursive=True ) ``` -------------------------------- ### Install PyTorch Tabular (Basic) Source: https://github.com/niketkumardheeryan/ml-capsule/blob/master/pytorch_tabular/pytorch_tabular_tutorial.ipynb Installs the basic PyTorch Tabular library. Use this if you don't need all optional dependencies. ```bash pip install pytorch_tabular ``` -------------------------------- ### Python range() Function Usage Source: https://github.com/niketkumardheeryan/ml-capsule/blob/master/Basics of the Python/Basic of Python/2.TUPLES_LECTURE/LISTS_AND_RANGE.ipynb Shows how to use the range() function to generate a list of numbers. The range() function takes start, stop, and step arguments. This example generates odd numbers from 1 up to (but not including) 10. ```python list(range(1,10,2)) ``` -------------------------------- ### Tkinter GUI Setup and Send Function Source: https://github.com/niketkumardheeryan/ml-capsule/blob/master/CBT_ChatBot/CBT_ChatBot.ipynb Initializes the Tkinter GUI for the chatbot, including the chat log, entry box, and send button. The send function handles user input, displays messages, and gets bot responses. ```python #Creating GUI with tkinter import tkinter from tkinter import * def send(): msg = EntryBox.get("1.0",'end-1c').strip() EntryBox.delete("0.0",END) if msg != '': ChatLog.config(state=NORMAL) ChatLog.insert(END, "You: " + msg + '\n\n') ChatLog.config(foreground="#442265", font=("Verdana", 12 )) res = chatbot_response(msg) ChatLog.insert(END, "Bot: " + res + '\n\n') ChatLog.config(state=DISABLED) ChatLog.yview(END) base = Tk() base.title("Aishika") base.geometry("400x500") base.resizable(width=FALSE, height=FALSE) #Create Chat window ChatLog = Text(base, bd=0, bg="white", height="8", width="50", font="Arial",) ChatLog.config(state=DISABLED) #Bind scrollbar to Chat window scrollbar = Scrollbar(base, command=ChatLog.yview, cursor="heart") ChatLog['yscrollcommand'] = scrollbar.set #Create Button to send message SendButton = Button(base, font=("Verdana",12,'bold'), text="Send", width="12", height=5, bd=0, bg="#32de97", activebackground="#3c9d9b",fg='#ffffff', command= send ) #Create the box to enter message EntryBox = Text(base, bd=0, bg="white",width="29", height="5", font="Arial") #EntryBox.bind("", send) #Place all components on the screen scrollbar.place(x=376,y=6, height=386) ChatLog.place(x=6,y=6, height=386, width=370) EntryBox.place(x=128, y=401, height=90, width=265) SendButton.place(x=6, y=401, height=90) base.mainloop() ``` -------------------------------- ### Install PyTorch Geometric and Dependencies Source: https://github.com/niketkumardheeryan/ml-capsule/blob/master/Molecule_Property_Analysis/molecule_property_analysis.ipynb Installs PyTorch Geometric and its required dependencies. Ensure PyTorch is installed first, as the installation command is version-specific. ```python import torch pyg_url = f"https://data.pyg.org/whl/torch-{torch.__version__}.html" %pip install torch-scatter torch-sparse torch-cluster torch-spline-conv torch-geometric -f $pyg_url ``` -------------------------------- ### Install required packages Source: https://github.com/niketkumardheeryan/ml-capsule/blob/master/market-basket-recommendation/readme.md Install all necessary Python packages for the project by running this command. Ensure you have a 'req.txt' file in your project directory. ```bash pip install -r req.txt ``` -------------------------------- ### Initialize Teachable Machine Model and Webcam Source: https://github.com/niketkumardheeryan/ml-capsule/blob/master/Google Teachable Machine/Deployment/deploy_model.html Loads the Teachable Machine image model and sets up the webcam. Ensure the model and metadata URLs are correctly specified. The webcam is configured to be 200x200 pixels and flipped horizontally. ```javascript const URL = "../Model/keras_model.h5"; let model, webcam, labelContainer, maxPredictions; async function init() { const modelURL = URL + "model.json"; const metadataURL = URL + "metadata.json"; model = await tmImage.load(modelURL, metadataURL); maxPredictions = model.getTotalClasses(); const flip = true; webcam = new tmImage.Webcam(200, 200, flip); await webcam.setup(); await webcam.play(); window.requestAnimationFrame(loop); document.getElementById("webcam-container").appendChild(webcam.canvas); labelContainer = document.getElementById("label-container"); for (let i = 0; i < maxPredictions; i++) { labelContainer.appendChild(document.createElement("div")); } } ``` -------------------------------- ### Create a virtual environment Source: https://github.com/niketkumardheeryan/ml-capsule/blob/master/market-basket-recommendation/readme.md It is recommended to create a virtual environment to manage project dependencies. Activate it using the provided command based on your operating system. ```bash python3 -m venv venv source venv/bin/activate # On Windows, use venv\Scripts\activate ``` -------------------------------- ### Python String Basics: Creation and Properties Source: https://github.com/niketkumardheeryan/ml-capsule/blob/master/Basics of ML and DL/ML/Strings.ipynb Demonstrates how to create strings, print them, check their type, and get their length. Also shows how to access individual characters using indexing. ```python # strings and its properties a = "this is a string" print(a) print(type(a)) print(len(a)) print(a[0],a[len(a)-1]) ``` -------------------------------- ### Install Project Dependencies Source: https://github.com/niketkumardheeryan/ml-capsule/blob/master/Medical Insurance Cost Prediction/README.md Installs necessary Python libraries for the project using pip. Ensure you have Python 3.x installed. ```bash pip install numpy pandas matplotlib seaborn scikit-learn jupyter ``` -------------------------------- ### PyScript Installation Source: https://github.com/niketkumardheeryan/ml-capsule/blob/master/PyScript Tutorial/README.md Reference PyScript using HTML script tags for installation. This is typically done in the head section of your HTML file. ```html ``` -------------------------------- ### Install PyCaret Source: https://github.com/niketkumardheeryan/ml-capsule/blob/master/AutoML_GSSoC.ipynb Installs the PyCaret library, a low-code machine learning framework. Ensure you have a stable internet connection for the download. ```python !pip install pycaret ``` -------------------------------- ### Install Project Dependencies Source: https://github.com/niketkumardheeryan/ml-capsule/blob/master/GUI-JARVIS/README.md Installs the required packages and libraries for the AI-JARVIS project. Ensure Python 3.9.2 or higher is installed. ```bash pip install pyttsx3 pip install random pip install re pip install smtplib pip install winsound pip install wikipedia pip install sys pip install os pip install webbrowser pip install datetime pip install speech_recognition pip install urllib pip install PyQt5 pip install geopy pip install bs4 pip install yahoo_fin pip install stock_info ``` -------------------------------- ### Install Python Dependencies Source: https://github.com/niketkumardheeryan/ml-capsule/blob/master/Foreign Exchange Rate Prediction/Readme.md Installs the necessary Python libraries for the project using pip. Ensure these are installed before running the project. ```bash pip install keras pip install tensorflow pip install numpy pip install scikit-learn pip install matplotlib pip install pandas ``` -------------------------------- ### Initialize Data Structures and Parameters Source: https://github.com/niketkumardheeryan/ml-capsule/blob/master/SongGenreClassifier/SongGenreClassifier.ipynb Sets up parameters and initializes DataFrames for training and testing the genre classifier. ```python from sklearn.utils import shuffle from nltk.corpus import stopwords genres = ['Country','alt rock', 'Hip Hop','pop','rhythm and blues'] LYRIC_LEN = 400 N = 10000 RANDOM_SEED = 200 train_df = pd.DataFrame() test_df = pd.DataFrame() ``` -------------------------------- ### Count Unique Start Locations Source: https://github.com/niketkumardheeryan/ml-capsule/blob/master/UBER_DATA_ANALYSIS.ipynb Determines the total number of distinct starting locations present in the 'START*' column of the DataFrame. ```python len(df['START*'].unique()) ``` -------------------------------- ### Install specific pyyaml version Source: https://github.com/niketkumardheeryan/ml-capsule/blob/master/Gender Pay Gap Analysis/analyze_gender_pay_gap.ipynb Installs a specific version of the pyyaml library. This is often done to ensure compatibility with other installed packages. ```python !pip install pyyaml==5.4.1 ``` -------------------------------- ### Tesseract Configuration File Example Source: https://github.com/niketkumardheeryan/ml-capsule/blob/master/Dark Pattern Detection/Tesseract-OCR/tesseract.1.html Example of a Tesseract configuration file that disables system dictionaries and loads user-defined word and pattern lists. ```text load_system_dawg F load_freq_dawg F user_words_suffix user-words user_patterns_suffix user-patterns ``` -------------------------------- ### Run Streamlit Application Source: https://github.com/niketkumardheeryan/ml-capsule/blob/master/emotion-based music recommendtion/README.md Launches the Streamlit application for the emotion-based music recommender. This command starts the local development server. ```bash streamlit run front.py ``` -------------------------------- ### Install Project Dependencies Source: https://github.com/niketkumardheeryan/ml-capsule/blob/master/Traffic Sign Recognition/Readme.md Run this command to install all the necessary Python packages for the traffic sign recognition project. Ensure you have pip installed. ```bash pip install pandas keras tensorflow matplotlib pillow sklearn ``` -------------------------------- ### Install TPOT Package Source: https://github.com/niketkumardheeryan/ml-capsule/blob/master/Statistical_modeling_python/Statistical_modeling.ipynb This command installs the TPOT (Tree-based Pipeline Optimization Tool) library, which automates the process of building and optimizing machine learning pipelines. ```bash pip install tpot ``` -------------------------------- ### Example Usage of Text Summarization Source: https://github.com/niketkumardheeryan/ml-capsule/blob/master/Text Summarization Model/Model/text_summary.ipynb Demonstrates how to use the generate_summary function with a sample text and prints the resulting summary. ```python # Example usage: text = """A week ago a friend invited a couple of other couples over for dinner. Eventually, the food (but not the wine) was cleared off the table for what turned out to be some fierce Scrabbling. Heeding the strategy of going for the shorter, more valuable word over the longer cheaper word, our final play was “Bon,” which–as luck would have it!–happens to be a Japanese Buddhist festival, and not, as I had originally asserted while laying the tiles on the board, one half of a chocolate-covered cherry treat. Anyway, the strategy worked. My team only lost by 53 points instead of 58.""" summary = generate_summary(text) print(summary) ``` -------------------------------- ### Install Python Libraries Source: https://github.com/niketkumardheeryan/ml-capsule/blob/master/Bitcoin Price Predictor/README.md Installs necessary Python libraries for data manipulation, machine learning, and visualization. Ensure these are installed before running the project. ```bash pip install sklearn pip install tensorflow pip install pandas pip install matplotlib ``` -------------------------------- ### TPOT Installation Output Source: https://github.com/niketkumardheeryan/ml-capsule/blob/master/Statistical_modeling_python/Statistical_modeling.ipynb This output details the process of installing the TPOT package and its dependencies using pip. It shows which packages are being collected, downloaded, and installed. ```text Collecting tpot Downloading TPOT-0.12.2-py3-none-any.whl (87 kB) ⌒⌒⌒⌒⌒⌒⌒⌒⌒⌒⌒⌒⌒⌒⌒⌒⌒⌒⌒⌒ 87.4/87.4 kB ⌒ 2.4 MB/s eta ⌒ 0:00:00 Requirement already satisfied: numpy>=1.16.3 in /usr/local/lib/python3.10/dist-packages (from tpot) (1.25.2) Requirement already satisfied: scipy>=1.3.1 in /usr/local/lib/python3.10/dist-packages (from tpot) (1.11.4) Requirement already satisfied: scikit-learn>=1.4.1 in /usr/local/lib/python3.10/dist-packages (from tpot) (1.4.2) Collecting deap>=1.2 (from tpot) Downloading deap-1.4.1-cp310-cp310-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl (135 kB) ⌒⌒⌒⌒⌒⌒⌒⌒⌒⌒⌒⌒⌒⌒⌒⌒⌒⌒⌒⌒ 135.4/135.4 kB ⌒ 5.9 MB/s eta ⌒ 0:00:00 Collecting update-checker>=0.16 (from tpot) Downloading update_checker-0.18.0-py3-none-any.whl (7.0 kB) Requirement already satisfied: tqdm>=4.36.1 in /usr/local/lib/python3.10/dist-packages (from tpot) (4.66.4) Collecting stopit>=1.1.1 (from tpot) Downloading stopit-1.1.2.tar.gz (18 kB) Preparing metadata (setup.py) ... ⌒ 25l⌒ 25hdone Requirement already satisfied: pandas>=0.24.2 in /usr/local/lib/python3.10/dist-packages (from tpot) (2.0.3) Requirement already satisfied: joblib>=0.13.2 in /usr/local/lib/python3.10/dist-packages (from tpot) (1.3.2) Requirement already satisfied: xgboost>=1.1.0 in /usr/local/lib/python3.10/dist-packages (from tpot) (2.0.3) Requirement already satisfied: python-dateutil>=2.8.2 in /usr/local/lib/python3.10/dist-packages (from pandas>=0.24.2->tpot) (2.8.2) Requirement already satisfied: pytz>=2020.1 in /usr/local/lib/python3.10/dist-packages (from pandas>=0.24.2->tpot) (2023.4) Requirement already satisfied: tzdata>=2022.1 in /usr/local/lib/python3.10/dist-packages (from pandas>=0.24.2->tpot) (2024.1) Requirement already satisfied: threadpoolctl>=2.0.0 in /usr/local/lib/python3.10/dist-packages (from scikit-learn>=1.4.1->tpot) (3.5.0) Requirement already satisfied: requests>=2.3.0 in /usr/local/lib/python3.10/dist-packages (from update-checker>=0.16->tpot) (2.31.0) Requirement already satisfied: six>=1.5 in /usr/local/lib/python3.10/dist-packages (from python-dateutil>=2.8.2->pandas>=0.24.2->tpot) (1.16.0) Requirement already satisfied: charset-normalizer<4,>=2 in /usr/local/lib/python3.10/dist-packages (from requests>=2.3.0->update-checker>=0.16->tpot) (3.3.2) Requirement already satisfied: idna<4,>=2.5 in /usr/local/lib/python3.10/dist-packages (from requests>=2.3.0->update-checker>=0.16->tpot) (3.7) Requirement already satisfied: urllib3<3,>=1.21.1 in /usr/local/lib/python3.10/dist-packages (from requests>=2.3.0->update-checker>=0.16->tpot) (2.0.7) Requirement already satisfied: certifi>=2017.4.17 in /usr/local/lib/python3.10/dist-packages (from requests>=2.3.0->update-checker>=0.16->tpot) (2024.6.2) Building wheels for collected packages: stopit Building wheel for stopit (setup.py) ... ⌒ 25l⌒ 25hdone Created wheel for stopit: filename=stopit-1.1.2-py3-none-any.whl size=11938 sha256=d1f6477161421803d96ec931ee6b733f64adfb8adfa4fa91d4aa1eeb71891866 Stored in directory: /root/.cache/pip/wheels/af/f9/87/bf5b3d565c2a007b4dae9d8142dccc85a9f164e517062dd519 Successfully built stopit ``` -------------------------------- ### Install PyTorch for CPU Source: https://github.com/niketkumardheeryan/ml-capsule/blob/master/NLP-Project/README.md Installs PyTorch version 1.12.1 with CPU support. This is a prerequisite for installing and running iNLTK, especially in environments without CUDA. ```bash pip install torch==1.12.1+cpu -f https://download.pytorch.org/whl/torch_stable.html ``` -------------------------------- ### Install Project Dependencies Source: https://github.com/niketkumardheeryan/ml-capsule/blob/master/Bitcoin Price Prediction Web App/requirements.txt List of Python packages required for the Bitcoin Price Prediction Web App. Install these using pip. ```text joblib==1.1.0 numpy==1.22.0 scikit-learn==1.0.2 scipy==1.7.3 threadpoolctl==3.0.0 ``` -------------------------------- ### Count Occurrences of Each Start Location Source: https://github.com/niketkumardheeryan/ml-capsule/blob/master/UBER_DATA_ANALYSIS.ipynb Calculates and returns the frequency of each unique value in the 'START*' column. This helps identify the most common starting points for Uber rides. ```python df['START*'].value_counts() ``` -------------------------------- ### Install twitter-api-v2 Source: https://github.com/niketkumardheeryan/ml-capsule/blob/master/Social Media Fake Accounts Detection with Interactive UI/server/node_modules/twitter-api-v2/README.md Install the library using yarn or npm. ```bash yarn add twitter-api-v2 # or npm i twitter-api-v2 ``` -------------------------------- ### Initialize Video Capture and MediaPipe Hands Source: https://github.com/niketkumardheeryan/ml-capsule/blob/master/Sign-Language-Translator/code file sign language translator.ipynb Sets up video capture from the default camera and initializes MediaPipe Hands for detecting up to two hands with specified confidence thresholds. ```python cap = cv2.VideoCapture(0) mphands = mp.solutions.hands hands = mphands.Hands(static_image_mode=False,max_num_hands=2, min_detection_confidence=0.5, min_tracking_confidence=0.5) mpDraw = mp.solutions.drawing_utils() txt1 = "1" txt2 = "2" txt3 = "3" txt4 = "4" txt5 = "5" txt6 = "6" txt7 = "7" txt8 = "8" ``` -------------------------------- ### Install and Import Deployment Libraries Source: https://github.com/niketkumardheeryan/ml-capsule/blob/master/Sentiment-Analysis/Sentiment_Analysis_Major_Project.ipynb Installs the Streamlit and pyngrok libraries, then imports ngrok from pyngrok. Streamlit is used for building web applications, and pyngrok for creating secure tunnels. ```python !pip install streamlit !pip install pyngrok===4.1.1 from pyngrok import ngrok ``` -------------------------------- ### Install PaddlePaddle GPU Source: https://github.com/niketkumardheeryan/ml-capsule/blob/master/OCR-Medicine-Reader/Medicine_Label_Reader_OCR.ipynb Installs the paddlepaddle-gpu package version 2.0.0 from a Baidu mirror. Ensure you have the necessary GPU drivers and CUDA toolkit installed for GPU acceleration. ```python # Installation of paddle github repository !python -m pip install paddlepaddle-gpu==2.0.0 -i https://mirror.baidu.com/pypi/simple ``` -------------------------------- ### Initialize YouTube API and Emotion Detection Model Source: https://github.com/niketkumardheeryan/ml-capsule/blob/master/emotion-based music recommendtion/work.ipynb Sets up the necessary libraries and loads the pre-trained emotion detection model. Ensure you replace 'your-api' with your actual YouTube API key. ```python import googleapiclient.discovery from transformers import pipeline # YouTube API credentials api_key = 'your-api' # Load pre-trained emotion detection model emotion_classifier = pipeline('text-classification', model='bhadresh-savani/bert-base-go-emotion') ``` -------------------------------- ### Install Docker on EC2 Source: https://github.com/niketkumardheeryan/ml-capsule/blob/master/Chicken_Disease_Classification/README.md Commands to install Docker on an Ubuntu EC2 instance. This includes updating packages, downloading the Docker installation script, and adding the current user to the docker group. ```bash sudo apt-get update -y sudo apt-get upgrade curl -fsSL https://get.docker.com -o get-docker.sh sudo sh get-docker.sh sudo usermod -aG docker ubuntu newgrp docker ```