-
Notifications
You must be signed in to change notification settings - Fork 81
Description
Hello haskell team,
It would be useful to have an AutoML framework in Haskell that, given a dataset, evaluates a set of candidate models (e.g., linear regression, random forest, decision tree, etc.) and automatically selects the best-performing one based on predefined metrics.
Example Code: How It Works
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE QuasiQuotes #-}
import Language.Python.Inline
-- Function to find the best ML model in Python
selectBestModel :: IO String
selectBestModel = [py|
from sklearn.model_selection import train_test_split
from sklearn.linear_model import LogisticRegression
from sklearn.tree import DecisionTreeClassifier
from sklearn.metrics import accuracy_score
import numpy as np
# Sample dataset (binary classification)
X = np.array([[0], [1], [2], [3], [4], [5]])
y = np.array([0, 0, 1, 1, 1, 1])
# Train-test split
X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.3, random_state=42)
# Train Logistic Regression
log_model = LogisticRegression()
log_model.fit(X_train, y_train)
log_acc = accuracy_score(y_test, log_model.predict(X_test))
# Train Decision Tree
tree_model = DecisionTreeClassifier()
tree_model.fit(X_train, y_train)
tree_acc = accuracy_score(y_test, tree_model.predict(X_test))
# Pick the best model
best_model = "Logistic Regression" if log_acc > tree_acc else "Decision Tree"
best_model # Return model name to Haskell
|]
-- Main function to test
main :: IO ()
main = do
bestModel <- selectBestModel
putStrLn $ "Best Model Selected: " ++ bestModel
Expected Output
Best Model Selected: Decision Tree
(Or Logistic Regression, depending on dataset & accuracy)
waiting for your approval..
Thank you
Mokshagna