I have tried this code and I am facing error with map:
"gp.map(fit_random_forest, batch_size=10)
AttributeError: module 'genpipes' has no attribute 'map' "
import genpipes as gp
from sklearn.ensemble import RandomForestClassifier
from sklearn.datasets import load_iris
from sklearn.model_selection import train_test_split
I have tried this code and I am facing error with map: "gp.map(fit_random_forest, batch_size=10) AttributeError: module 'genpipes' has no attribute 'map' "
import genpipes as gp from sklearn.ensemble import RandomForestClassifier from sklearn.datasets import load_iris from sklearn.model_selection import train_test_split
Load the Iris dataset
iris = load_iris()
Split the data into training and testing sets
X_train, X_test, y_train, y_test = train_test_split(iris.data, iris.target, test_size=0.3)
Define a function to fit a random forest classifier
def fit_random_forest(X, y): rf = RandomForestClassifier() rf.fit(X, y) return rf
Define the pipeline using GenPipes
pipeline =( gp.map(fit_random_forest, batch_size=10) | gp.reduce(lambda x, y: x + y) )
Run the pipeline on the training data
models = pipeline(X_train, y_train)
Evaluate the models on the testing data
acc = [model.score(X_test, y_test) for model in models]
print(f"Accuracy: {acc}")