VerticaPy

repository·master·Indexed 42 days ago

https://github.com/vertica/verticapy

A Python library for data science workflows directly on Vertica databases. It provides a scikit-learn-like API for in-database data exploration, preparation, machine learning, and deployment, utilizing vDataFrame to execute logic within the database to avoid moving large datasets to local memory.

Tokens
180.6K
Snippets
668
Records
840
Agent score
48%

What's inside VerticaPy

  1. What is VerticaPyLab

    master

    VerticaPyLab is a Docker-based JupyterLab environment designed to provide a GUI-based platform for using Vertica and VerticaPy. It eliminates the need for manual installation and dependency management by using two containers: one for the Vertica database and one for JupyterLab containing VerticaPy and its dependencies.

    Key features include:

    • QueryProfiler: Investigate and identify reasons for slow query performance.
    • Graphics and visualizations: Create plots using Grafana, Matplotlib, Plotly, and other libraries.
    • Run vsql: Execute the Vertica vsql editor directly from the interface.
    • Seamless data ingestion: Effortlessly load and process massive datasets from Vertica.
    • Interactive tutorials: Access VerticaPy lessons to learn core concepts.
  2. Overview of VerticaPy Public API

    master

    VerticaPy provides a comprehensive API for data science and database interaction. The public API is organized into several functional modules:

    • vDataFrame: The core object of VerticaPy used for data manipulation.
    • Connection: Tools to view and modify database connections.
    • Parsers: Methods for ingesting data into the database.
    • Machine Learning: APIs to create and optimize ML models.
    • SDK-Vertica: Support for User Defined Functions (UDFs).
    • SQL: Interfaces for executing and using SQL.
    • Stats: Statistical functions for data analysis.
    • Plotting: Tools for generating charts and graphs.
    • Performance: Metrics for monitoring performance.
    • Utilities: Functions to ingest, read, and drop data.
    • Datasets: Built-in datasets like Titanic, Iris, and Amazon.
    • Jupyter Extensions: Enhancements for Jupyter, including Magic SQL and specialized charts.
    • TableSample: The TableSample object for sampling data.
    • Error handling: Standardized error types for troubleshooting.
  3. Overview of Data Preparation in VerticaPy

    master

    VerticaPy provides a comprehensive suite of tools for preparing datasets for analysis and machine learning. The data preparation workflow includes the following key capabilities:

    • Joins: Combine datasets using various join techniques to enrich and consolidate data.
    • Duplicates: Identify and manage duplicate records to ensure data integrity.
    • Outliers: Detect and handle outliers to ensure robust and reliable analyses.
    • Missing values: Address missing data through imputation techniques to improve dataset completeness.
    • Encoding: Transform categorical data into numerical formats suitable for machine learning models.
    • Scaling Techniques: Standardize numerical features to a common scale to optimize model performance.
    • Decomposition: Break down complex data structures into simpler components.
    • Feature engineering: Create new informative features to enhance the predictive power of models.
  4. Overview of VerticaPy capabilities

    master

    VerticaPy provides an end-to-end analytical workflow integrated with Vertica. The core capabilities include:

    • Core Data Structures: Working with vDataFrame and vDataColumn for data manipulation.
    • Data Ingestion: Streamlining ETL processes to ingest data from databases, spreadsheets, and external sources into Vertica.
    • Data Exploration: Using interactive visualizations, charts, and graphs to uncover patterns.
    • Data Preparation: Cleaning, reshaping, and enriching datasets through pre-processing tools.
    • Machine Learning: Performing predictive analysis, including model training and evaluation.
    • Full Stack Integration: Combining data processing, analysis, and visualization, including support for User Defined Functions (UDFs) and GeoPandas.
    • Performance Optimization: Using the QueryProfiler tool to identify bottlenecks and optimize query performance.
  5. Overview of VerticaPy

    master

    VerticaPy is a Python library designed for data science projects where data is stored in a Vertica database. It provides scikit-learn-like functionality but operates by bringing the logic to the data (in-database processing) rather than moving data to an in-memory Python process. This approach leverages Vertica's speed and built-in analytics/ML features.

    Key Advantages:

    • Easy Data Exploration
    • Fast Data Preparation
    • In-Database Machine Learning
    • Easy Model Evaluation
    • Easy Model Deployment
    • Flexibility to use either Python or SQL
  6. Getting started with VerticaPy

    master

    VerticaPy is designed for seamless analytical exploration on Vertica databases. To begin using the library, you should follow these primary workflows:

    1. Setup and Connection: Configure your workspace and establish a connection to your Vertica database to ensure an optimal environment for data journeys.
    2. Data Manipulation with Virtual DataFrames: Use the vDataFrame module to store and manipulate data. The Virtual DataFrame is a core abstraction designed to optimize data manipulation processes and elevate analytical capabilities.
    3. Workflow Optimization: Follow established best practices for data management and visualization to maximize the efficiency of your analytical workflows.
  7. Benchmark: Vertica vs Spark Linear Regression

    master

    This benchmark evaluates the performance of Vertica's Linear Regression algorithm against Apache Spark. The comparison focuses on speed, accuracy, and scalability across different data sizes and optimization methods.

    Test Configuration

    • Vertica Version: 8.0.1
    • Spark Version: 2.02
    • Convergence Criteria (both): max iter = 100, e = 10^-6

    Dataset

    The benchmark uses an artificial dataset generated from a Linear Regression model with added noise.

  8. Explore VerticaPy Full Stack capabilities

    master

    VerticaPy provides a comprehensive suite of tools for end-to-end data science workflows, ranging from data manipulation to advanced machine learning. The full-stack capabilities include:

    • Complex Data Handling: Using VMaps to work with intricate data structures.
    • Data Access: Seamlessly querying external databases via DBLink integration.
    • Spatial Analytics: Integrating with GeoPandas for Geo DataFrame and map visualization.
    • Predictive Modeling: Implementing techniques like Linear regression and XGBoost (including exporting models to JSON).
    • Time-Series Analysis: Utilizing slices, interpolation, and joins for temporal data.
    • Model Evaluation: Using Train/Test splits for dataset partitioning.
    • Extensibility: Creating User-defined functions (UDFs) and leveraging Magic methods within the vDataFrame for enhanced manipulation.
  9. Explore Vertica integration options and connectors

    master

    Vertica supports a wide range of integration options to facilitate data access and compatibility across different ecosystems. Depending on your technology stack, you can use various connectors for Python, Spark, Hadoop, Node.js, and more.

    Key integration technologies include:

    • Python: Use vertica-python as the native Python client.
    • Big Data & Distributed Computing:
      • Spark: Connect Spark and Vertica for data retrieval and storage.
      • vertica-hadoop-connector: Integration for Apache Hadoop and Pig.
    • Database Connectivity & Transformation:
      • ODBC: Load data directly or run queries from a remote database.
      • DBLINK: A Vertica UDTF to run SQL against other databases.
      • dbt-vertica: An adapter for database transformations using dbt.
    • Application Development:
      • vertica-nodejs: A pure Javascript client for Node.js.
      • vertica-sql-go: A native Go adapter for Vertica.
    • Orchestration:
      • Apache Airflow: Integration for managing Vertica workflows.
  10. Explore VerticaPy Chart Gallery

    master

    VerticaPy provides an extensive selection of plotting graphics for data visualization and business insight extraction. The chart gallery is categorized into different types such as Basic, Machine Learning, and Geo-spatial charts.

    Most charts in VerticaPy support multiple visualization engines and interfaces:

    • Available Engines: Plotly, Matplotlib, and Highcharts.
    • Available Interfaces: Python and SQL.

    Common chart types include:

    • Basic Charts: Area, Bar, Boxplot, Candlestick, Contour, Correlation Matrix, Density, Histogram, Line, Pie, Pivot, Range, Scatter, and Spider charts.

    For detailed technical guidance on how to implement these graphics, refer to the VerticaPy chart gallery guide.

  11. Benchmark: Vertica ARIMA vs. Python Statsmodels

    master

    This benchmark compares the performance of the Vertica ARIMA algorithm against the Python statsmodels library. The comparison evaluates three key metrics across varying dataset sizes (from 10K to 100M rows):

    1. Training Run Time: How long it takes to train the model.
    2. Prediction Run Time: How long it takes to generate predictions.
    3. Mean Squared Error (MSE): The accuracy of the model. For Vertica, the MSE is retrieved from the summary table using the GET_MODEL_SUMMARY command.

    Benchmark Configuration:

    • Parameters: p = 5, d = 1, q = 1
    • Dataset: Artificially created using a Linear model with random noise.
    • Vertica Version: 23.3.0-5
    • Python Statsmodels Version: 0.14.0