View AI
  • Welcome to View AI's Documentation!
  • Product Tour
  • UI Guide
    • Explainable AI
    • Fairness
    • Monitoring
    • Analyze
  • Platform Guide
    • Interpretability
      • ML Tasks
      • Evaluate
    • Observability
  • Client Guide
    • Quickstart
    • Training Models
    • Deploying Models
    • Inference
    • Updating Schemas
Powered by GitBook
On this page

Was this helpful?

  1. Client Guide

Training Models

PreviousQuickstartNextDeploying Models

Last updated 1 year ago

Was this helpful?

To begin, you'll need to initialize the ViewAIClient. Ensure you have your API key ready.

from viewai import ViewAIClient

client = ViewAIClient(api_key=api_key)

Loading Data

Next, let's load the data you want to use for training.

import pandas as pd

# Load data
df = pd.read_csv("csv_file_path.csv")

Workspaces and Projects

Workspaces and projects help organize your machine learning models, making it easier to manage different workflows.

Listing Workspaces and Projects

To get an overview of all available workspaces and projects, you can list them using the following methods:

# List all workspaces
workspaces = client.list_all_workspaces()
for workspace in workspaces:
    print(f"Name: {workspace.workspace_name}")

# List all projects
projects = client.list_all_projects()
for project in projects:
    print(f"Name: {project.project_name}")

You might want to select a specific workspace or project by name for more detailed operations. Here's how you can retrieve them:

Retrieving a Workspace by Name

workspace_name = "Retention"
workspace = client.get_workspace_by_name(workspace_name)

Retrieving a Project by Name

project_name = "Sales"
project = client.get_project_by_name(project_name)

Training a Model

Now it's time to train your model. You need to specify the DataFrame and the target column. Optionally, you can provide a model name and description:

# Train the model
client.train(
    df=df,
    target="Churn",
    workspace=workspace,
    project=project,
    name="Retention",
    description="Churn Model"
)

If you don't specify a workspace or project, it will automatically use the default workspace.

↪ Questions? Chat with an AI or talk to a .

ℹ️
Learn more about how to set up your environment.
product expert