Python Forum
Automate Machine Learning Workflows with Pipelines
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Automate Machine Learning Workflows with Pipelines
#1
# Create a pipeline that standardizes (prepares) the data then evaluates a model
import pandas as pd
import numpy as np
from sklearn.model_selection import KFold
from sklearn.model_selection import cross_val_score
from sklearn.preprocessing import StandardScaler
from sklearn.pipeline import Pipeline
from sklearn.discriminant_analysis import LinearDiscriminantAnalysis
filename = 'pima-indians-diabetes.data.csv'
names = ['preg', 'plas', 'pres', 'skin', 'test', 'mass', 'pedi', 'age', 'class']
dataframe = pd.read_csv(filename, names=names)
array = dataframe.values
X = array[:,0:8]
y = array[:,8]
# create pipeline
estimators = []
estimators.append(('standardize', StandardScaler()))
estimators.append(('lda', LinearDiscriminantAnalysis()))
model = Pipeline(estimators)
# evaluate the model
seed = 7
kfold = KFold(n_splits=10, shuffle=True, random_state=seed)
results = cross_val_score(model, X, y, cv=kfold)
print(results.mean())
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Choosing the Best Machine Learning Model FelixLarry 1 2,527 Dec-23-2022, 07:36 AM
Last Post: praveencqr
  Compare Machine Learning Regression Algorithms Consistently FelixLarry 0 1,819 Sep-06-2022, 09:25 PM
Last Post: FelixLarry
  Evaluating the Performance of Machine Learning Algorithms FelixLarry 0 2,001 Sep-02-2022, 09:20 PM
Last Post: FelixLarry
  Module for creating kernels and convoluting images (Machine Learning) dibsonthis 0 2,159 Dec-14-2017, 11:58 AM
Last Post: dibsonthis

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020