Welcome to the Google Cloud Vertex AI sample repository.
The repository contains notebooks and community content that demonstrate how to develop and manage ML workflows using Google Cloud Vertex AI.
├── community-content - Sample code and tutorials contributed by the community
├── notebooks
│ ├── community - Notebooks contributed by the community
│ ├── official - Notebooks demonstrating use of each Vertex AI service
│ │ ├── automl
│ │ ├── custom
│ │ ├── ...
Contributions welcome! See the Contributing Guide.
Please use the issues page to provide feedback or submit a bug report.
This is not an officially supported Google product. The code in this repository is for demonstrative purposes only.
Please feel free to fill out our survey to give us feedback on the repo and its content. import pandas as pd import numpy as np import requests
def collect_data(api_url): response = requests.get(api_url) data = response.json() df = pd.DataFrame(data) return df
api_url = "https://example.com/api/system_status" data = collect_data(api_url)from sklearn.ensemble import IsolationForest
def detect_anomalies(data): model = IsolationForest(contamination=0.01) model.fit(data) data['anomaly'] = model.predict(data) anomalies = data[data['anomaly'] == -1] return anomalies
anomalies = detect_anomalies(data)from twilio.rest import Client
def send_alert(anomalies): if not anomalies.empty: account_sid = 'your_account_sid' auth_token = 'your_auth_token' client = Client(account_sid, auth_token) message = client.messages.create( body=f"Anomalias detectadas: {anomalies}", from_='+1234567890', to='+0987654321' ) print(message.sid)
send_alert(anomalies) from flask import Flask, render_template import pandas as pd
app = Flask(name)
@app.route('/') def index(): data = collect_data(api_url) anomalies = detect_anomalies(data) return render_template('index.html', tables=[data.to_html(classes='data', header="true"), anomalies.to_html(classes='data', header="true")])
if name == 'main': app.run(debug=True)from apscheduler.schedulers.blocking import BlockingScheduler
scheduler = BlockingScheduler()
@scheduler.scheduled_job('interval', minutes=5) def scheduled_job(): data = collect_data(api_url) anomalies = detect_anomalies(data) send_alert(anomalies)
scheduler.start()
<title>TechGuardian Dashboard</title>