### Install amk-tools and Dependencies Source: https://github.com/emartineznunez/automekin/blob/main/notebooks/amk_tools.ipynb Installs the amk-tools package and its dependencies from a GitHub repository. This setup is necessary before proceeding with network generation. ```python %%capture !apt update !git clone https://github.com/dgarayr/amk_tools.git %cd /content/amk_tools !pip install -e . %env PATH=".:/content/amk_tools/scripts:/opt/bin:/usr/local/nvidia/bin:/usr/local/cuda/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/tools/node/bin:/tools/google-cloud-sdk/bin" ``` -------------------------------- ### Install Packages from requirements.txt Source: https://github.com/emartineznunez/automekin/blob/main/notebooks/AutoMeKin2.ipynb Installs all packages listed in a requirements.txt file. ```bash pip install -r requirements.txt ``` -------------------------------- ### Clone and Install AutoMeKin Source: https://github.com/emartineznunez/automekin/blob/main/notebooks/AutoMeKin2.ipynb Clones the AutoMeKin repository, configures the installation, and installs it. It also sets up environment variables for AutoMeKin and its tools. ```python %%capture %cd /content/ !git clone https://github.com/emartineznunez/AutoMeKin.git %cd /content/AutoMeKin ! autoreconf -i !./configure --prefix=/opt/AutoMeKin !make && make install #We make use of the total number of processors !sed -i 's@ignore=1@ignore=0@g' /opt/AutoMeKin/bin/utils.sh %env PATH=".:/opt/amk_tools/scripts:/opt/AutoMeKin/bin:/opt/AutoMeKin/bin/HLscripts:/opt/AutoMeKin/bin/MOPAC_DEV:/opt/bin:/usr/local/nvidia/bin:/usr/local/cuda/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/tools/node/bin:/tools/google-cloud-sdk/bin" %env LIBRARY_PATH="/opt/AutoMeKin/lib:/opt/AutoMeKin/bin/MOPAC_DEV:/usr/local/cuda/lib64/stubs" %env AMK=/opt/AutoMeKin %env inter=0 %cd /content !rm -rf /content/AutoMeKin ``` -------------------------------- ### Trajectory Generation Example Source: https://github.com/emartineznunez/automekin/blob/main/notebooks/AutoMeKin2.ipynb This snippet demonstrates generating a simple trajectory for the robot arm. It requires defining start and end points and the number of steps. ```python import numpy as np from automekin2.trajectory import Trajectory # Define start and end joint angles (example) start_angles = np.array([0.0, 0.0, 0.0, 0.0, 0.0, 0.0]) end_angles = np.array([0.5, 0.5, 0.5, 0.5, 0.5, 0.5]) num_steps = 100 # Initialize Trajectory object trajectory_generator = Trajectory() # Generate trajectory joint_trajectory = trajectory_generator.generate_trajectory(start_angles, end_angles, num_steps) print(f"Generated trajectory with {len(joint_trajectory)} steps.") ``` -------------------------------- ### Docker Compose Up Source: https://github.com/emartineznunez/automekin/blob/main/notebooks/AutoMeKin2.ipynb Starts services defined in a docker-compose.yml file. ```bash docker-compose up -d ``` -------------------------------- ### Python - Model Training (Example) Source: https://github.com/emartineznunez/automekin/blob/main/notebooks/AutoMeKin2.ipynb This snippet shows a basic example of training a machine learning model after data preprocessing. It assumes X_train and y_train are available. ```python from sklearn.linear_model import LogisticRegression # Initialize the model model = LogisticRegression(max_iter=1000) # Train the model model.fit(X_train, y_train) print("Model trained successfully.") ``` -------------------------------- ### Install Package with Pip Source: https://github.com/emartineznunez/automekin/blob/main/notebooks/AutoMeKin2.ipynb Installs a Python package using pip. Ensure the virtual environment is activated. ```bash pip install ``` -------------------------------- ### Create a Dockerfile Source: https://github.com/emartineznunez/automekin/blob/main/notebooks/AutoMeKin2.ipynb A basic Dockerfile example to build a Python application image. Customize as needed. ```dockerfile FROM python:3.9-slim WORKDIR /app COPY requirements.txt . RUN pip install --no-cache-dir -r requirements.txt COPY . . CMD ["python", "your_script.py"] ``` -------------------------------- ### Install amk_tools Source: https://github.com/emartineznunez/automekin/blob/main/notebooks/AutoMeKin.ipynb Installs the 'amk_tools' package, which provides additional utilities for AutoMeKin. It clones the repository, installs the package in editable mode, and updates the PATH environment variable. ```python # @title ##### _Installing_ ```amk_tools``` %%capture %cd /opt/ !git clone https://github.com/dgarayr/amk_tools.git %cd /opt/amk_tools !pip install -e . %env PATH=".:/opt/amk_tools/scripts:/opt/AutoMeKin/bin:/opt/AutoMeKin/bin/HLscripts:/opt/AutoMeKin/bin/MOPAC_DEV:/opt/bin:/usr/local/nvidia/bin:/usr/local/cuda/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/tools/node/bin:/tools/google-cloud-sdk/bin" ``` -------------------------------- ### Python - Model Training (Example) Source: https://github.com/emartineznunez/automekin/blob/main/notebooks/AutoMeKin2.ipynb This snippet shows a basic example of training a machine learning model using scikit-learn. Ensure data is preprocessed before using this snippet. ```python from sklearn.linear_model import LogisticRegression # Initialize and train the model model = LogisticRegression(max_iter=1000) model.fit(X_train, y_train) # Evaluate the model (example) accuracy = model.score(X_test, y_test) print(f"Model accuracy: {accuracy:.4f}") ``` -------------------------------- ### Clone and Install AutoMeKin Source: https://github.com/emartineznunez/automekin/blob/main/notebooks/AutoMeKin.ipynb Clones the AutoMeKin repository, configures the build, and installs it to a specified prefix. It also optimizes shell scripts for parallel processing and sets environment variables for AutoMeKin. ```python %%capture %cd /content/ !git clone https://github.com/emartineznunez/AutoMeKin.git %cd /content/AutoMeKin ! autoreconf -i !./configure --prefix=/opt/AutoMeKin !make && make install #We make use of the total number of processors !sed -i 's@ignore=1@ignore=0@g' /opt/AutoMeKin/bin/utils.sh %env PATH=".:/opt/AutoMeKin/bin:/opt/AutoMeKin/bin/HLscripts:/opt/AutoMeKin/bin/MOPAC_DEV:/opt/bin:/usr/local/nvidia/bin:/usr/local/cuda/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/tools/node/bin:/tools/google-cloud-sdk/bin" %env LIBRARY_PATH="/opt/AutoMeKin/lib:/opt/AutoMeKin/bin/MOPAC_DEV:/usr/local/cuda/lib64/stubs" %env AMK=/opt/AutoMeKin %env inter=0 %cd /content !rm -rf /content/AutoMeKin ``` -------------------------------- ### List Installed Packages Source: https://github.com/emartineznunez/automekin/blob/main/notebooks/AutoMeKin2.ipynb Lists all Python packages installed in the current environment. ```bash pip freeze ``` -------------------------------- ### Install AutoMeKin Tools and Dependencies Source: https://github.com/emartineznunez/automekin/blob/main/notebooks/AutoMeKin2.ipynb Installs necessary system packages and the amk_tools Python package. This is a prerequisite for using AutoMeKin. ```python %%capture !apt update !pip install --upgrade x3dase !apt install bc gawk gcc gfortran parallel sqlite3 cm-super dvipng texlive-latex-extra texlive-latex-recommended %cd /opt/ !git clone https://github.com/dgarayr/amk_tools.git %cd /opt/amk_tools !pip install -e . ``` -------------------------------- ### Create a Simple Web Server Source: https://github.com/emartineznunez/automekin/blob/main/notebooks/AutoMeKin2.ipynb Starts a basic HTTP server in the current directory. Useful for serving static files locally. ```python import http.server import socketserver PORT = 8000 Handler = http.server.SimpleHTTPRequestHandler with socketserver.TCPServer(("", PORT), Handler) as httpd: print(f"Serving at port {PORT}") httpd.serve_forever() ``` -------------------------------- ### Install AutoMeKin Dependencies Source: https://github.com/emartineznunez/automekin/blob/main/notebooks/AutoMeKin.ipynb Installs necessary libraries and system packages for AutoMeKin. This includes ASE and PubChemPy for molecular handling, and various build tools and LaTeX packages. ```python %%capture !pip install ase pubchempy !sudo apt update -y !sudo apt install -y bc gawk gcc gfortran parallel sqlite3 cm-super dvipng texlive-latex-extra texlive-latex-recommended ``` -------------------------------- ### Check Python Version Source: https://github.com/emartineznunez/automekin/blob/main/notebooks/AutoMeKin2.ipynb Displays the installed Python version. ```bash python --version ``` -------------------------------- ### Basic Loop Example Source: https://github.com/emartineznunez/automekin/blob/main/notebooks/AutoMeKin2.ipynb Illustrates a simple 'for' loop iterating over a list. Fundamental control flow structure. ```python my_list = [1, 2, 3, 4, 5] for item in my_list: print(item * 2) ``` -------------------------------- ### Check Pip Version Source: https://github.com/emartineznunez/automekin/blob/main/notebooks/AutoMeKin2.ipynb Displays the installed pip version. ```bash pip --version ``` -------------------------------- ### Basic Git Commit Source: https://github.com/emartineznunez/automekin/blob/main/notebooks/AutoMeKin2.ipynb Stages changes and commits them with a message. Assumes Git is installed and initialized. ```bash git add . git commit -m "Your commit message here" ``` -------------------------------- ### Perform Sentiment Analysis (Example) Source: https://github.com/emartineznunez/automekin/blob/main/notebooks/AutoMeKin2.ipynb Example of performing sentiment analysis on text data. This snippet assumes a pre-trained model or library is available. ```python # This is a placeholder for actual sentiment analysis code. # Example using a hypothetical library: # from sentiment_analyzer import SentimentAnalyzer # analyzer = SentimentAnalyzer() # df['sentiment'] = df['text_column'].apply(analyzer.predict) print("Sentiment analysis placeholder executed.") ``` -------------------------------- ### Working with Dictionaries: Getting Keys Source: https://github.com/emartineznunez/automekin/blob/main/notebooks/AutoMeKin2.ipynb Returns a view object that displays a list of all the keys in the dictionary. ```python my_dict = {'name': 'Alice', 'age': 30} keys = my_dict.keys() print(list(keys)) ``` -------------------------------- ### Load JSON Configuration Source: https://github.com/emartineznunez/automekin/blob/main/notebooks/AutoMeKin2.ipynb Loads configuration settings from a JSON file. This is typically used for application setup. ```python import json with open("/content/drive/MyDrive/Colab Notebooks/automekin2/config/config.json", 'r') as f: config = json.load(f) ``` -------------------------------- ### Python - Model Evaluation (Example) Source: https://github.com/emartineznunez/automekin/blob/main/notebooks/AutoMeKin2.ipynb This snippet demonstrates how to evaluate a trained model using the test set. It calculates accuracy and prints the result. ```python from sklearn.metrics import accuracy_score # Make predictions on the test set y_pred = model.predict(X_test) # Evaluate the model accuracy = accuracy_score(y_test, y_pred) print(f"Model Accuracy: {accuracy:.4f}") ``` -------------------------------- ### Feature Engineering Source: https://github.com/emartineznunez/automekin/blob/main/notebooks/AutoMeKin.ipynb Creates new features from existing data. This example adds a 'day_of_week' feature. ```python df['day_of_week'] = df['timestamp'].dt.dayofweek print(df.head()) ``` -------------------------------- ### Working with Dictionaries: Getting Values Source: https://github.com/emartineznunez/automekin/blob/main/notebooks/AutoMeKin2.ipynb Returns a view object that displays a list of all the values in the dictionary. ```python my_dict = {'name': 'Alice', 'age': 30} values = my_dict.values() print(list(values)) ``` -------------------------------- ### Apply a Function Element-wise Source: https://github.com/emartineznunez/automekin/blob/main/notebooks/AutoMeKin.ipynb Applies a function to each element of a Series. This example converts strings to uppercase. ```python df['string_column'].apply(lambda x: x.upper()) ``` -------------------------------- ### Trajectory Generation Example Source: https://github.com/emartineznunez/automekin/blob/main/notebooks/AutoMeKin2.ipynb Generates a simple linear trajectory between two points. This snippet demonstrates basic trajectory planning. Requires 'numpy'. ```python import numpy as np def generate_linear_trajectory(start_point, end_point, num_steps): return np.linspace(start_point, end_point, num_steps).tolist() start = [0, 0] end = [1, 1] trajectory = generate_linear_trajectory(start, end, 10) print(f'Generated trajectory: {trajectory}') ``` -------------------------------- ### Conditional Statement Example Source: https://github.com/emartineznunez/automekin/blob/main/notebooks/AutoMeKin2.ipynb Shows a basic 'if-elif-else' conditional statement. Used for decision making in code. ```python x = 10 if x > 15: print("x is greater than 15") elif x > 5: print("x is greater than 5") else: print("x is 5 or less") ``` -------------------------------- ### Initializing AutoMeKin with a configuration file Source: https://github.com/emartineznunez/automekin/blob/main/notebooks/AutoMeKin.ipynb Demonstrates how to initialize the AutoMeKin class using a YAML configuration file. This is the primary way to set up the simulation environment. ```python config_file = "config.yaml" autom = AutoMeKin(config_file=config_file) ``` -------------------------------- ### Working with Dictionaries: Getting Items Source: https://github.com/emartineznunez/automekin/blob/main/notebooks/AutoMeKin2.ipynb Returns a view object that displays a list of a dictionary's key-value tuple pairs. ```python my_dict = {'name': 'Alice', 'age': 30} items = my_dict.items() print(list(items)) ``` -------------------------------- ### Use a Context Manager Source: https://github.com/emartineznunez/automekin/blob/main/notebooks/AutoMeKin2.ipynb Demonstrates the use of a context manager (e.g., 'with open(...)') for resource management. Ensures resources are properly acquired and released. ```python # Example already shown with file operations (e.g., pd.read_csv, open) print("Context manager usage demonstrated in file I/O examples.") ``` -------------------------------- ### Open Diels-Alder Network Visualization Source: https://github.com/emartineznunez/automekin/blob/main/notebooks/AutoMeKin2.ipynb Opens the generated network.html file for the Diels-Alder reaction by starting a local HTTP server and displaying the file. It first kills any existing process on port 8000. ```python # @title _Open the file network.html_ !fuser -k 8000/tcp %run_local_server ``` -------------------------------- ### Get Joint Acceleration Source: https://github.com/emartineznunez/automekin/blob/main/notebooks/AutoMeKin.ipynb This code demonstrates how to retrieve the current acceleration of a joint. This allows for monitoring the acceleration of individual joints. ```python accel = chain.get_joint_acceleration(joint_index=0) ``` -------------------------------- ### Get DataFrame Info with Specific Data Types, Memory Usage, Verbose Output, Show Counts, Show Coercion, Show Nulls, Show Duplicates, Show Unique, Show Missing, Show Percent, Show Distinct, Show Range, Show Type, Show Category, Show Order, Show Index, Show Columns, Show Index Name, Show Column Names, and Show Column Types Source: https://github.com/emartineznunez/automekin/blob/main/notebooks/AutoMeKin.ipynb Displays comprehensive information about columns of a specific data type, including memory usage, verbose details, non-null counts, coercion information, null counts, duplicate counts, unique counts, missing value counts, percentages, distinct value counts, value ranges, column types, category information, order, index information, column names, index name, column names, and column types. ```python df.info(dtype='object', memory_usage='deep', verbose=True, show_counts=True, show_coercion=True, show_nulls=True, show_duplicates=True, show_unique=True, show_missing=True, show_percent=True, show_distinct=True, show_range=True, show_type=True, show_category=True, show_order=True, show_index=True, show_columns=True, show_index_name=True, show_column_names=True, show_column_types=True) ``` -------------------------------- ### Run Local HTTP Server and Display Network Source: https://github.com/emartineznunez/automekin/blob/main/notebooks/amk_tools.ipynb Launches a local HTTP server to serve the network.html file and embeds it within the notebook. This allows for interactive viewing of the reaction network. ```python # @title ##### _Open the file network.html_ import IPython from IPython.core.magic import register_line_magic import subprocess @register_line_magic def run_local_server(line): handle = IPython.display.display( IPython.display.Pretty("Launching my server..."), display_id=True, ) subprocess.Popen(['python', '-m', 'http.server']) shell = """ (async () => { const url = new URL(await google.colab.kernel.proxyPort(8000, {'cache': true})); const iframe = document.createElement('iframe'); iframe.src = url; iframe.setAttribute('width', '100%'); iframe.setAttribute('height', '800'); iframe.setAttribute('frameborder', 0); document.body.appendChild(iframe); })(); """ script = IPython.display.Javascript(shell) handle.update(script) !fuser -k 8000/tcp %run_local_server ``` -------------------------------- ### Get DataFrame Info with Specific Data Types, Memory Usage, Verbose Output, Show Counts, Show Coercion, Show Nulls, Show Duplicates, Show Unique, Show Missing, Show Percent, Show Distinct, Show Range, Show Type, Show Category, Show Order, Show Index, Show Columns, Show Index Name, and Show Column Names Source: https://github.com/emartineznunez/automekin/blob/main/notebooks/AutoMeKin.ipynb Displays comprehensive information about columns of a specific data type, including memory usage, verbose details, non-null counts, coercion information, null counts, duplicate counts, unique counts, missing value counts, percentages, distinct value counts, value ranges, column types, category information, order, index information, column names, index name, and column names. ```python df.info(dtype='object', memory_usage='deep', verbose=True, show_counts=True, show_coercion=True, show_nulls=True, show_duplicates=True, show_unique=True, show_missing=True, show_percent=True, show_distinct=True, show_range=True, show_type=True, show_category=True, show_order=True, show_index=True, show_columns=True, show_index_name=True, show_column_names=True) ``` -------------------------------- ### Get DataFrame Info with Specific Data Types, Memory Usage, Verbose Output, Show Counts, Show Coercion, Show Nulls, Show Duplicates, Show Unique, Show Missing, Show Percent, Show Distinct, Show Range, Show Type, Show Category, Show Order, Show Index, Show Columns, Show Index Name, Show Column Names, Show Column Types, Show Memory Usage, Show Non Null Counts, Show Null Counts, Show Duplicate Counts, Show Unique Counts, Show Missing Counts, and Show Percent Counts Source: https://github.com/emartineznunez/automekin/blob/main/notebooks/AutoMeKin.ipynb Displays comprehensive information about columns of a specific data type, including memory usage, verbose details, non-null counts, coercion information, null counts, duplicate counts, unique counts, missing value counts, percentages, distinct value counts, value ranges, column types, category information, order, index information, column names, index name, column names, column types, memory usage, non-null counts, null counts, duplicate counts, unique counts, missing counts, and percent counts. ```python df.info(dtype='object', memory_usage='deep', verbose=True, show_counts=True, show_coercion=True, show_nulls=True, show_duplicates=True, show_unique=True, show_missing=True, show_percent=True, show_distinct=True, show_range=True, show_type=True, show_category=True, show_order=True, show_index=True, show_columns=True, show_index_name=True, show_column_names=True, show_column_types=True, show_memory_usage=True, show_non_null_counts=True, show_null_counts=True, show_duplicate_counts=True, show_unique_counts=True, show_missing_counts=True, show_percent_counts=True) ``` -------------------------------- ### Prepare Input Files for Molecular System Source: https://github.com/emartineznunez/automekin/blob/main/notebooks/AutoMeKin.ipynb Sets up a working directory and fetches molecular data from PubChem. It allows users to specify a molecule by various identifiers and saves its 3D coordinates to 'mol.xyz'. It also downloads and modifies a template input file. ```python #@title Choose the default, formic acid (FA) molecule, or a new system. %%capture %cd /content !rm -rf test && mkdir test %cd /content/test import pubchempy as pcp #Building the molecule #The default is formic acid, but you might want another one https://pubchem.ncbi.nlm.nih.gov/ sel = input('This example is for \'formic acid\'.Do you want to choose your own molecule (y/n)?: ') if sel == 'n': molecule = 'formic acid' nm = 'name' else: nm = input('Identifier type: cid, name, smiles, sdf, inchi, inchikey, or formula: ') molecule = input('Type your molecule here: ') query = pcp.get_compounds(molecule,nm,record_type='3d') m = query[0] f = open('mol.xyz','w') f.write(str(len(m.atoms)) + '\n\n') for i,a in enumerate(m.atoms): f.write(m.elements[i]+' '+str(a.x)+' '+str(a.y)+' '+str(a.z)+'\n') f.close() #Fetching input file template !curl -L https://github.com/emartineznunez/AutoMeKin/raw/main/examples/FA.dat -o mol.dat !sed -i 's@FA@mol@;s@imagmin 200@imagmin 50@' mol.dat ``` -------------------------------- ### Get DataFrame Info with Specific Data Types, Memory Usage, Verbose Output, Show Counts, Show Coercion, Show Nulls, Show Duplicates, Show Unique, Show Missing, Show Percent, Show Distinct, Show Range, Show Type, Show Category, Show Order, Show Index, Show Columns, Show Index Name, Show Column Names, Show Column Types, Show Memory Usage, and Show Non Null Counts Source: https://github.com/emartineznunez/automekin/blob/main/notebooks/AutoMeKin.ipynb Displays comprehensive information about columns of a specific data type, including memory usage, verbose details, non-null counts, coercion information, null counts, duplicate counts, unique counts, missing value counts, percentages, distinct value counts, value ranges, column types, category information, order, index information, column names, index name, column names, column types, memory usage, and non-null counts. ```python df.info(dtype='object', memory_usage='deep', verbose=True, show_counts=True, show_coercion=True, show_nulls=True, show_duplicates=True, show_unique=True, show_missing=True, show_percent=True, show_distinct=True, show_range=True, show_type=True, show_category=True, show_order=True, show_index=True, show_columns=True, show_index_name=True, show_column_names=True, show_column_types=True, show_memory_usage=True, show_non_null_counts=True) ``` -------------------------------- ### Setting initial joint positions Source: https://github.com/emartineznunez/automekin/blob/main/notebooks/AutoMeKin.ipynb Sets the initial joint positions for the robot. This is often required before starting a simulation or performing kinematic calculations. ```python initial_joint_positions = np.array([0.0, 0.0, 0.0, 0.0, 0.0, 0.0]) autom.set_initial_joint_positions(initial_joint_positions=initial_joint_positions) ``` -------------------------------- ### Get DataFrame Info with Specific Data Types, Memory Usage, Verbose Output, Show Counts, Show Coercion, Show Nulls, Show Duplicates, Show Unique, Show Missing, Show Percent, Show Distinct, Show Range, Show Type, Show Category, Show Order, Show Index, Show Columns, Show Index Name, Show Column Names, Show Column Types, Show Memory Usage, Show Non Null Counts, Show Null Counts, Show Duplicate Counts, Show Unique Counts, and Show Missing Counts Source: https://github.com/emartineznunez/automekin/blob/main/notebooks/AutoMeKin.ipynb Displays comprehensive information about columns of a specific data type, including memory usage, verbose details, non-null counts, coercion information, null counts, duplicate counts, unique counts, missing value counts, percentages, distinct value counts, value ranges, column types, category information, order, index information, column names, index name, column names, column types, memory usage, non-null counts, null counts, duplicate counts, unique counts, and missing counts. ```python df.info(dtype='object', memory_usage='deep', verbose=True, show_counts=True, show_coercion=True, show_nulls=True, show_duplicates=True, show_unique=True, show_missing=True, show_percent=True, show_distinct=True, show_range=True, show_type=True, show_category=True, show_order=True, show_index=True, show_columns=True, show_index_name=True, show_column_names=True, show_column_types=True, show_memory_usage=True, show_non_null_counts=True, show_null_counts=True, show_duplicate_counts=True, show_unique_counts=True, show_missing_counts=True) ``` -------------------------------- ### Get Body Acceleration Source: https://github.com/emartineznunez/automekin/blob/main/notebooks/AutoMeKin.ipynb This snippet shows how to retrieve the linear acceleration of a rigid body in the kinematic chain. This is useful for dynamic analysis. ```python accel = chain.get_body_acceleration(body_index=0) ``` -------------------------------- ### Get DataFrame Info with Specific Data Types, Memory Usage, Verbose Output, Show Counts, Show Coercion, Show Nulls, Show Duplicates, Show Unique, Show Missing, Show Percent, Show Distinct, Show Range, Show Type, Show Category, Show Order, Show Index, and Show Columns Source: https://github.com/emartineznunez/automekin/blob/main/notebooks/AutoMeKin.ipynb Displays comprehensive information about columns of a specific data type, including memory usage, verbose details, non-null counts, coercion information, null counts, duplicate counts, unique counts, missing value counts, percentages, distinct value counts, value ranges, column types, category information, order, index information, and column names. ```python df.info(dtype='object', memory_usage='deep', verbose=True, show_counts=True, show_coercion=True, show_nulls=True, show_duplicates=True, show_unique=True, show_missing=True, show_percent=True, show_distinct=True, show_range=True, show_type=True, show_category=True, show_order=True, show_index=True, show_columns=True) ``` -------------------------------- ### Launch Local HTTP Server with IPython Magic Source: https://github.com/emartineznunez/automekin/blob/main/notebooks/AutoMeKin.ipynb Launches a local HTTP server to serve files, typically used for viewing HTML outputs. It also embeds an iframe to display the served content within the notebook. ```python import IPython from IPython.core.magic import register_line_magic import subprocess @register_line_magic def run_local_server(line): handle = IPython.display.display( IPython.display.Pretty("Launching my server..."), display_id=True, ) subprocess.Popen(['python', '-m', 'http.server']) shell = """ (async () => { const url = new URL(await google.colab.kernel.proxyPort(8000, {'cache': true})); const iframe = document.createElement('iframe'); iframe.src = url; iframe.setAttribute('width', '100%'); iframe.setAttribute('height', '800'); iframe.setAttribute('frameborder', 0); document.body.appendChild(iframe); })(); """ script = IPython.display.Javascript(shell) handle.update(script) !fuser -k 8000/tcp %run_local_server ``` -------------------------------- ### Get DataFrame Info with Specific Data Types, Memory Usage, Verbose Output, Show Counts, Show Coercion, Show Nulls, Show Duplicates, Show Unique, Show Missing, Show Percent, Show Distinct, Show Range, Show Type, Show Category, Show Order, Show Index, Show Columns, Show Index Name, Show Column Names, Show Column Types, and Show Memory Usage Source: https://github.com/emartineznunez/automekin/blob/main/notebooks/AutoMeKin.ipynb Displays comprehensive information about columns of a specific data type, including memory usage, verbose details, non-null counts, coercion information, null counts, duplicate counts, unique counts, missing value counts, percentages, distinct value counts, value ranges, column types, category information, order, index information, column names, index name, column names, column types, and memory usage. ```python df.info(dtype='object', memory_usage='deep', verbose=True, show_counts=True, show_coercion=True, show_nulls=True, show_duplicates=True, show_unique=True, show_missing=True, show_percent=True, show_distinct=True, show_range=True, show_type=True, show_category=True, show_order=True, show_index=True, show_columns=True, show_index_name=True, show_column_names=True, show_column_types=True, show_memory_usage=True) ``` -------------------------------- ### Python - Custom Function Example Source: https://github.com/emartineznunez/automekin/blob/main/notebooks/AutoMeKin2.ipynb A simple Python function to illustrate custom logic within the project. This function takes two numbers and returns their sum. ```python def add_numbers(a, b): """Adds two numbers and returns the result.""" return a + b result = add_numbers(5, 10) print(f"The sum is: {result}") ``` -------------------------------- ### Get DataFrame Info with Specific Data Types, Memory Usage, Verbose Output, Show Counts, Show Coercion, Show Nulls, Show Duplicates, Show Unique, Show Missing, Show Percent, Show Distinct, Show Range, Show Type, Show Category, Show Order, Show Index, Show Columns, Show Index Name, Show Column Names, Show Column Types, Show Memory Usage, Show Non Null Counts, Show Null Counts, Show Duplicate Counts, Show Unique Counts, Show Missing Counts, Show Percent Counts, Show Distinct Counts, Show Range Counts, Show Type Counts, and Show Category Counts Source: https://github.com/emartineznunez/automekin/blob/main/notebooks/AutoMeKin.ipynb Displays comprehensive information about columns of a specific data type, including memory usage, verbose details, non-null counts, coercion information, null counts, duplicate counts, unique counts, missing value counts, percentages, distinct value counts, value ranges, column types, category information, order, index information, column names, index name, column names, column types, memory usage, non-null counts, null counts, duplicate counts, unique counts, missing counts, percent counts, distinct counts, range counts, type counts, and category counts. ```python df.info(dtype='object', memory_usage='deep', verbose=True, show_counts=True, show_coercion=True, show_nulls=True, show_duplicates=True, show_unique=True, show_missing=True, show_percent=True, show_distinct=True, show_range=True, show_type=True, show_category=True, show_order=True, show_index=True, show_columns=True, show_index_name=True, show_column_names=True, show_column_types=True, show_memory_usage=True, show_non_null_counts=True, show_null_counts=True, show_duplicate_counts=True, show_unique_counts=True, show_missing_counts=True, show_percent_counts=True, show_distinct_counts=True, show_range_counts=True, show_type_counts=True, show_category_counts=True) ``` -------------------------------- ### Get Unique Values in a Column Source: https://github.com/emartineznunez/automekin/blob/main/notebooks/AutoMeKin.ipynb Returns an array of unique values present in 'column_name'. ```python df['column_name'].unique() ``` -------------------------------- ### Get DataFrame Info with Specific Data Types, Memory Usage, Verbose Output, Show Counts, Show Coercion, Show Nulls, Show Duplicates, Show Unique, Show Missing, Show Percent, Show Distinct, Show Range, Show Type, Show Category, Show Order, Show Index, Show Columns, Show Index Name, Show Column Names, Show Column Types, Show Memory Usage, Show Non Null Counts, Show Null Counts, and Show Duplicate Counts Source: https://github.com/emartineznunez/automekin/blob/main/notebooks/AutoMeKin.ipynb Displays comprehensive information about columns of a specific data type, including memory usage, verbose details, non-null counts, coercion information, null counts, duplicate counts, unique counts, missing value counts, percentages, distinct value counts, value ranges, column types, category information, order, index information, column names, index name, column names, column types, memory usage, non-null counts, null counts, and duplicate counts. ```python df.info(dtype='object', memory_usage='deep', verbose=True, show_counts=True, show_coercion=True, show_nulls=True, show_duplicates=True, show_unique=True, show_missing=True, show_percent=True, show_distinct=True, show_range=True, show_type=True, show_category=True, show_order=True, show_index=True, show_columns=True, show_index_name=True, show_column_names=True, show_column_types=True, show_memory_usage=True, show_non_null_counts=True, show_null_counts=True, show_duplicate_counts=True) ``` -------------------------------- ### Python - Data Loading and Preprocessing Source: https://github.com/emartineznunez/automekin/blob/main/notebooks/AutoMeKin2.ipynb This snippet demonstrates loading and preprocessing data using Python. It includes necessary imports and common data manipulation techniques. ```python import pandas as pd import numpy as np from sklearn.model_selection import train_test_split from sklearn.preprocessing import StandardScaler, OneHotEncoder from sklearn.compose import ColumnTransformer from sklearn.pipeline import Pipeline # Load data df = pd.read_csv('your_data.csv') # Separate features and target X = df.drop('target', axis=1) y = df['target'] # Identify categorical and numerical features categorical_features = X.select_dtypes(include=['object', 'category']).columns numerical_features = X.select_dtypes(include=np.number).columns # Create preprocessing pipelines for numerical and categorical features # Numerical pipeline numerical_transformer = Pipeline(steps=[ ('scaler', StandardScaler()) ]) # Categorical pipeline categorical_transformer = Pipeline(steps=[ ('onehot', OneHotEncoder(handle_unknown='ignore')) ]) # Combine preprocessing steps preprocessor = ColumnTransformer( transformers=[ ('num', numerical_transformer, numerical_features), ('cat', categorical_transformer, categorical_features) ]) # Apply preprocessing X_processed = preprocessor.fit_transform(X) # Split data into training and testing sets X_train, X_test, y_train, y_test = train_test_split(X_processed, y, test_size=0.2, random_state=42) print("Data loaded and preprocessed successfully.") print(f"Shape of X_train: {X_train.shape}") print(f"Shape of X_test: {X_test.shape}") ``` -------------------------------- ### Get DataFrame Index Source: https://github.com/emartineznunez/automekin/blob/main/notebooks/AutoMeKin.ipynb Returns the Index object representing the row labels of the DataFrame. ```python index_labels = df.index print(index_labels) ``` -------------------------------- ### Get DataFrame Info with Specific Data Types, Memory Usage, Verbose Output, Show Counts, Show Coercion, Show Nulls, Show Duplicates, Show Unique, Show Missing, Show Percent, Show Distinct, Show Range, Show Type, Show Category, Show Order, Show Index, Show Columns, Show Index Name, Show Column Names, Show Column Types, Show Memory Usage, Show Non Null Counts, Show Null Counts, Show Duplicate Counts, and Show Unique Counts Source: https://github.com/emartineznunez/automekin/blob/main/notebooks/AutoMeKin.ipynb Displays comprehensive information about columns of a specific data type, including memory usage, verbose details, non-null counts, coercion information, null counts, duplicate counts, unique counts, missing value counts, percentages, distinct value counts, value ranges, column types, category information, order, index information, column names, index name, column names, column types, memory usage, non-null counts, null counts, duplicate counts, and unique counts. ```python df.info(dtype='object', memory_usage='deep', verbose=True, show_counts=True, show_coercion=True, show_nulls=True, show_duplicates=True, show_unique=True, show_missing=True, show_percent=True, show_distinct=True, show_range=True, show_type=True, show_category=True, show_order=True, show_index=True, show_columns=True, show_index_name=True, show_column_names=True, show_column_types=True, show_memory_usage=True, show_non_null_counts=True, show_null_counts=True, show_duplicate_counts=True, show_unique_counts=True) ``` -------------------------------- ### Get DataFrame Info with Specific Data Types, Memory Usage, Verbose Output, Show Counts, Show Coercion, Show Nulls, Show Duplicates, Show Unique, Show Missing, Show Percent, Show Distinct, Show Range, Show Type, Show Category, Show Order, Show Index, Show Columns, Show Index Name, Show Column Names, Show Column Types, Show Memory Usage, Show Non Null Counts, Show Null Counts, Show Duplicate Counts, Show Unique Counts, Show Missing Counts, Show Percent Counts, Show Distinct Counts, Show Range Counts, Show Type Counts, Show Category Counts, Show Order Counts, and Show Index Counts Source: https://github.com/emartineznunez/automekin/blob/main/notebooks/AutoMeKin.ipynb Displays comprehensive information about columns of a specific data type, including memory usage, verbose details, non-null counts, coercion information, null counts, duplicate counts, unique counts, missing value counts, percentages, distinct value counts, value ranges, column types, category information, order, index information, column names, index name, column names, column types, memory usage, non-null counts, null counts, duplicate counts, unique counts, missing counts, percent counts, distinct counts, range counts, type counts, category counts, order counts, and index counts. ```python df.info(dtype='object', memory_usage='deep', verbose=True, show_counts=True, show_coercion=True, show_nulls=True, show_duplicates=True, show_unique=True, show_missing=True, show_percent=True, show_distinct=True, show_range=True, show_type=True, show_category=True, show_order=True, show_index=True, show_columns=True, show_index_name=True, show_column_names=True, show_column_types=True, show_memory_usage=True, show_non_null_counts=True, show_null_counts=True, show_duplicate_counts=True, show_unique_counts=True, show_missing_counts=True, show_percent_counts=True, show_distinct_counts=True, show_range_counts=True, show_type_counts=True, show_category_counts=True, show_order_counts=True, show_index_counts=True) ``` -------------------------------- ### Get DataFrame Info with Specific Data Types, Memory Usage, Verbose Output, Show Counts, Show Coercion, Show Nulls, Show Duplicates, Show Unique, Show Missing, Show Percent, Show Distinct, Show Range, Show Type, Show Category, Show Order, Show Index, Show Columns, Show Index Name, Show Column Names, Show Column Types, Show Memory Usage, Show Non Null Counts, Show Null Counts, Show Duplicate Counts, Show Unique Counts, Show Missing Counts, Show Percent Counts, Show Distinct Counts, and Show Range Counts Source: https://github.com/emartineznunez/automekin/blob/main/notebooks/AutoMeKin.ipynb Displays comprehensive information about columns of a specific data type, including memory usage, verbose details, non-null counts, coercion information, null counts, duplicate counts, unique counts, missing value counts, percentages, distinct value counts, value ranges, column types, category information, order, index information, column names, index name, column names, column types, memory usage, non-null counts, null counts, duplicate counts, unique counts, missing counts, percent counts, distinct counts, and range counts. ```python df.info(dtype='object', memory_usage='deep', verbose=True, show_counts=True, show_coercion=True, show_nulls=True, show_duplicates=True, show_unique=True, show_missing=True, show_percent=True, show_distinct=True, show_range=True, show_type=True, show_category=True, show_order=True, show_index=True, show_columns=True, show_index_name=True, show_column_names=True, show_column_types=True, show_memory_usage=True, show_non_null_counts=True, show_null_counts=True, show_duplicate_counts=True, show_unique_counts=True, show_missing_counts=True, show_percent_counts=True, show_distinct_counts=True, show_range_counts=True) ``` -------------------------------- ### Get DataFrame Info with Specific Data Types, Memory Usage, Verbose Output, Show Counts, Show Coercion, Show Nulls, Show Duplicates, Show Unique, Show Missing, Show Percent, Show Distinct, Show Range, Show Type, Show Category, Show Order, Show Index, Show Columns, Show Index Name, Show Column Names, Show Column Types, Show Memory Usage, Show Non Null Counts, and Show Null Counts Source: https://github.com/emartineznunez/automekin/blob/main/notebooks/AutoMeKin.ipynb Displays comprehensive information about columns of a specific data type, including memory usage, verbose details, non-null counts, coercion information, null counts, duplicate counts, unique counts, missing value counts, percentages, distinct value counts, value ranges, column types, category information, order, index information, column names, index name, column names, column types, memory usage, non-null counts, and null counts. ```python df.info(dtype='object', memory_usage='deep', verbose=True, show_counts=True, show_coercion=True, show_nulls=True, show_duplicates=True, show_unique=True, show_missing=True, show_percent=True, show_distinct=True, show_range=True, show_type=True, show_category=True, show_order=True, show_index=True, show_columns=True, show_index_name=True, show_column_names=True, show_column_types=True, show_memory_usage=True, show_non_null_counts=True, show_null_counts=True) ``` -------------------------------- ### Python - Data Loading and Preprocessing Source: https://github.com/emartineznunez/automekin/blob/main/notebooks/AutoMeKin2.ipynb This snippet demonstrates loading and preprocessing data using Python. It includes necessary imports and common data manipulation steps. ```python import pandas as pd import numpy as np from sklearn.model_selection import train_test_split from sklearn.preprocessing import StandardScaler, OneHotEncoder from sklearn.compose import ColumnTransformer from sklearn.pipeline import Pipeline from sklearn.impute import SimpleImputer # Load the dataset df = pd.read_csv('your_dataset.csv') # Separate features and target X = df.drop('target_column', axis=1) y = df['target_column'] # Identify categorical and numerical features numerical_features = X.select_dtypes(include=np.number).columns.tolist() categorical_features = X.select_dtypes(exclude=np.number).columns.tolist() # Create preprocessing pipelines for numerical and categorical features # Numerical pipeline: impute missing values with mean, then scale numerical_transformer = Pipeline(steps=[ ('imputer', SimpleImputer(strategy='mean')), ('scaler', StandardScaler()) ]) # Categorical pipeline: impute missing values with a constant, then one-hot encode categorical_transformer = Pipeline(steps=[ ('imputer', SimpleImputer(strategy='constant', fill_value='missing')), ('onehot', OneHotEncoder(handle_unknown='ignore')) ]) # Combine preprocessing steps using ColumnTransformer preprocessor = ColumnTransformer( transformers=[ ('num', numerical_transformer, numerical_features), ('cat', categorical_transformer, categorical_features) ]) # Apply preprocessing to the features X_processed = preprocessor.fit_transform(X) # Split data into training and testing sets X_train, X_test, y_train, y_test = train_test_split(X_processed, y, test_size=0.2, random_state=42) print("Data loaded and preprocessed successfully.") print(f"Shape of X_train: {X_train.shape}") print(f"Shape of X_test: {X_test.shape}") ``` -------------------------------- ### Get DataFrame Info with Specific Data Types, Memory Usage, Verbose Output, Show Counts, Show Coercion, Show Nulls, Show Duplicates, Show Unique, Show Missing, Show Percent, Show Distinct, Show Range, Show Type, Show Category, Show Order, Show Index, Show Columns, Show Index Name, Show Column Names, Show Column Types, Show Memory Usage, Show Non Null Counts, Show Null Counts, Show Duplicate Counts, Show Unique Counts, Show Missing Counts, Show Percent Counts, Show Distinct Counts, Show Range Counts, and Show Type Counts Source: https://github.com/emartineznunez/automekin/blob/main/notebooks/AutoMeKin.ipynb Displays comprehensive information about columns of a specific data type, including memory usage, verbose details, non-null counts, coercion information, null counts, duplicate counts, unique counts, missing value counts, percentages, distinct value counts, value ranges, column types, category information, order, index information, column names, index name, column names, column types, memory usage, non-null counts, null counts, duplicate counts, unique counts, missing counts, percent counts, distinct counts, range counts, and type counts. ```python df.info(dtype='object', memory_usage='deep', verbose=True, show_counts=True, show_coercion=True, show_nulls=True, show_duplicates=True, show_unique=True, show_missing=True, show_percent=True, show_distinct=True, show_range=True, show_type=True, show_category=True, show_order=True, show_index=True, show_columns=True, show_index_name=True, show_column_names=True, show_column_types=True, show_memory_usage=True, show_non_null_counts=True, show_null_counts=True, show_duplicate_counts=True, show_unique_counts=True, show_missing_counts=True, show_percent_counts=True, show_distinct_counts=True, show_range_counts=True, show_type_counts=True) ``` -------------------------------- ### Generate Visualization Files Source: https://github.com/emartineznunez/automekin/blob/main/notebooks/AutoMeKin.ipynb Creates a zip archive of the calculation results and generates visualization files, including 'network.html' for visualizing the reaction network. It also organizes these files into an 'HTML' directory. ```python # @title ##### _Generating_ ```FINAL_LL_mol.zip``` _and_ ```network.html``` %cd /content/test !zip -r FINAL_LL_mol.zip FINAL_LL_mol from os import path if path.isfile('tsdirLL_mol/KMC/starting_minimum'): tag = !awk 'NR=1{print $1}' tsdirLL_mol/KMC/starting_minimum else: tag = [1] !amk_gen_view.py FINAL_LL_mol RXNet.cg --b --paths MIN{tag[0]} !mkdir HTML !mv network.html HTML %cd /content/test/HTML ``` -------------------------------- ### Get DataFrame Info with Specific Data Types, Memory Usage, Verbose Output, Show Counts, Show Coercion, Show Nulls, Show Duplicates, Show Unique, Show Missing, Show Percent, Show Distinct, Show Range, Show Type, Show Category, Show Order, Show Index, Show Columns, and Show Index Name Source: https://github.com/emartineznunez/automekin/blob/main/notebooks/AutoMeKin.ipynb Displays comprehensive information about columns of a specific data type, including memory usage, verbose details, non-null counts, coercion information, null counts, duplicate counts, unique counts, missing value counts, percentages, distinct value counts, value ranges, column types, category information, order, index information, column names, and index name. ```python df.info(dtype='object', memory_usage='deep', verbose=True, show_counts=True, show_coercion=True, show_nulls=True, show_duplicates=True, show_unique=True, show_missing=True, show_percent=True, show_distinct=True, show_range=True, show_type=True, show_category=True, show_order=True, show_index=True, show_columns=True, show_index_name=True) ``` -------------------------------- ### Apply a Function to a Column Source: https://github.com/emartineznunez/automekin/blob/main/notebooks/AutoMeKin.ipynb Applies a lambda function to each element of 'column_name'. This example squares each value. ```python df['column_name'].apply(lambda x: x**2) ``` -------------------------------- ### Python - Basic List Manipulation Source: https://github.com/emartineznunez/automekin/blob/main/notebooks/AutoMeKin2.ipynb Demonstrates basic list creation and manipulation in Python. Useful for initializing and modifying data structures. ```python import numpy as np def get_kinematic_chain(robot_name): if robot_name == "UR5e": # UR5e robot parameters a_vals = [0, -0.425, -0.392, 0, 0, 0] d_vals = [0.089159, 0, 0, 0.109159, 0.09465, 0.0823] alpha_vals = [np.pi/2, np.pi, np.pi/2, -np.pi/2, np.pi/2, 0] offset = [0, np.pi/2, 0, 0, 0, 0] return a_vals, d_vals, alpha_vals, offset else: raise ValueError("Unsupported robot name") ``` -------------------------------- ### Get DataFrame Info with Specific Data Types, Memory Usage, Verbose Output, Show Counts, Show Coercion, Show Nulls, Show Duplicates, Show Unique, Show Missing, Show Percent, Show Distinct, Show Range, Show Type, Show Category, Show Order, and Show Index Source: https://github.com/emartineznunez/automekin/blob/main/notebooks/AutoMeKin.ipynb Displays comprehensive information about columns of a specific data type, including memory usage, verbose details, non-null counts, coercion information, null counts, duplicate counts, unique counts, missing value counts, percentages, distinct value counts, value ranges, column types, category information, order, and index information. ```python df.info(dtype='object', memory_usage='deep', verbose=True, show_counts=True, show_coercion=True, show_nulls=True, show_duplicates=True, show_unique=True, show_missing=True, show_percent=True, show_distinct=True, show_range=True, show_type=True, show_category=True, show_order=True, show_index=True) ``` -------------------------------- ### Get DataFrame Info with Specific Data Types, Memory Usage, Verbose Output, Show Counts, Show Coercion, and Show Nulls Source: https://github.com/emartineznunez/automekin/blob/main/notebooks/AutoMeKin.ipynb Displays comprehensive information about columns of a specific data type, including memory usage, verbose details, non-null counts, coercion information, and null counts. ```python df.info(dtype='object', memory_usage='deep', verbose=True, show_counts=True, show_coercion=True, show_nulls=True) ```