This guide shows how to use the AI/ML functionalities in the ml_analysis
module of the AI-Aquatica library.
from ai_aquatica.ml_analysis import (
train_linear_regression,
train_logistic_regression,
train_classification_model,
evaluate_classification_model,
perform_clustering,
plot_clusters,
detect_anomalies,
generate_synthetic_data
)
import pandas as pd
import numpy as np
data = pd.DataFrame({
'feature1': np.random.randn(100),
'feature2': np.random.randn(100),
'target': np.random.randint(0, 2, 100)
})
X = data[['feature1', 'feature2']]
y = data['target']
model = train_linear_regression(X, y)
print("Coefficients:", model.coef_)
model = train_classification_model(X, y, model_type='random_forest')
from sklearn.model_selection import train_test_split
X_train, X_test, y_train, y_test = train_test_split(X, y)
metrics = evaluate_classification_model(model, X_test, y_test)
print(metrics)
cluster_model, labels = perform_clustering(X, algorithm='kmeans', n_clusters=3)
plot_clusters(X, labels)
anomalies = detect_anomalies(X, method='isolation_forest')
print("Detected:", anomalies)
synthetic = generate_synthetic_data(X, model_type='gan', epochs=100)
synthetic.head()
sklearn.metrics
.Use these tools in combination with preprocessing utilities such as ai_aquatica.data_cleaning
or ai_aquatica.data_standardization
, along with ai_aquatica.visualization
, for full pipelines!