How to prepare a machine learning workflow in Python?
DATA MUNGING

How to prepare a machine learning workflow in Python?

How to prepare a machine learning workflow in Python?

This recipe helps you prepare a machine learning workflow in Python

0
In [2]:
## How to prepare a machine leaning workflow in Python 
def Kickstarter_Example_25():
    print()
    print(format('How to prepare a machine leaning workflow in Python', '*^82'))

    import warnings
    warnings.filterwarnings("ignore")

    # Load libraries
    from sklearn import datasets
    from sklearn.preprocessing import StandardScaler
    from sklearn.linear_model import Perceptron
    from sklearn.model_selection import train_test_split
    from sklearn.metrics import accuracy_score, confusion_matrix

    # Load the iris dataset
    iris = datasets.load_iris()

    # Create our X and y data
    X = iris.data
    y = iris.target

    # Split the data into 70% training data and 30% test data
    X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.3)

    # Preprocess The X Data By Scaling
    sc = StandardScaler(with_mean=True, with_std=True)
    sc.fit(X_train)

    # Apply the scaler to the X training data
    X_train_std = sc.transform(X_train)

    # Apply the SAME scaler to the X test data
    X_test_std = sc.transform(X_test)

    #Train A Perceptron Learner
    ppn = Perceptron(alpha=0.0001, class_weight=None, eta0=0.1,
                     fit_intercept=True, n_iter=40, n_jobs=4,
                     penalty=None, random_state=0, shuffle=True,
                     verbose=0, warm_start=False)

    # Train the perceptron
    ppn.fit(X_train_std, y_train)

    # Apply The Trained Learner To Test Data
    y_pred = ppn.predict(X_test_std)

    # Compare The Predicted Y With The True Y
    # View the predicted y test data
    print(); print("y_pred: ", y_pred)

    # View the true y test data
    print(); print("y_test: ", y_test)

    # Examine Accuracy Metric
    print(); print('Accuracy: %.2f' % accuracy_score(y_test, y_pred))
    print(); print('Comfusion Matrix:\n', confusion_matrix(y_test, y_pred))

Kickstarter_Example_25()
***************How to prepare a machine leaning workflow in Python****************

y_pred:  [1 1 1 1 2 0 0 1 2 0 1 1 1 1 1 1 2 0 1 1 0 1 0 1 2 1 2 1 0 1 0 2 1 0 1 0 1
 0 1 0 2 0 1 1 1]

y_test:  [2 2 2 1 2 0 0 2 2 0 2 1 2 1 1 2 2 0 1 1 0 1 0 1 2 2 2 2 0 2 0 2 1 0 2 0 2
 0 1 0 2 0 2 1 2]

Accuracy: 0.69

Comfusion Matrix:
 [[13  0  0]
 [ 0 11  0]
 [ 0 14  7]]

Relevant Projects

Human Activity Recognition Using Smartphones Data Set
In this deep learning project, you will build a classification system where to precisely identify human fitness activities.

Perform Time series modelling using Facebook Prophet
In this project, we are going to talk about Time Series Forecasting to predict the electricity requirement for a particular house using Prophet.

Music Recommendation System Project using Python and R
Machine Learning Project - Work with KKBOX's Music Recommendation System dataset to build the best music recommendation engine.

Sequence Classification with LSTM RNN in Python with Keras
In this project, we are going to work on Sequence to Sequence Prediction using IMDB Movie Review Dataset​ using Keras in Python.

Zillow’s Home Value Prediction (Zestimate)
Data Science Project in R -Build a machine learning algorithm to predict the future sale prices of homes.

Deep Learning with Keras in R to Predict Customer Churn
In this deep learning project, we will predict customer churn using Artificial Neural Networks and learn how to model an ANN in R with the keras deep learning package.

Credit Card Fraud Detection as a Classification Problem
In this data science project, we will predict the credit card fraud in the transactional dataset using some of the predictive models.

Predict Employee Computer Access Needs in Python
Data Science Project in Python- Given his or her job role, predict employee access needs using amazon employee database.

Time Series Forecasting with LSTM Neural Network Python
Deep Learning Project- Learn to apply deep learning paradigm to forecast univariate time series data.

Learn to prepare data for your next machine learning project
Text data requires special preparation before you can start using it for any machine learning project.In this ML project, you will learn about applying Machine Learning models to create classifiers and learn how to make sense of textual data.