How to prepare a machine learning workflow in Python?

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

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

    import warnings

    # 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 =
    y =

    # 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)

    # 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, 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))

***************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

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

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.

Natural language processing Chatbot application using NLTK for text classification
In this NLP AI application, we build the core conversational engine for a chatbot. We use the popular NLTK text classification library to achieve this.

Customer Churn Prediction Analysis using Ensemble Techniques
In this machine learning churn project, we implement a churn prediction model in python using ensemble techniques.

Resume parsing with Machine learning - NLP with Python OCR and Spacy
In this machine learning resume parser example we use the popular Spacy NLP python library for OCR and text classification.

Ensemble Machine Learning Project - All State Insurance Claims Severity Prediction
In this ensemble machine learning project, we will predict what kind of claims an insurance company will get. This is implemented in python using ensemble machine learning algorithms.

Ecommerce product reviews - Pairwise ranking and sentiment analysis
This project analyzes a dataset containing ecommerce product reviews. The goal is to use machine learning models to perform sentiment analysis on product reviews and rank them based on relevance. Reviews play a key role in product recommendation systems.

Predict Credit Default | Give Me Some Credit Kaggle
In this data science project, you will predict borrowers chance of defaulting on credit loans by building a credit score prediction model.

German Credit Dataset Analysis to Classify Loan Applications
In this data science project, you will work with German credit dataset using classification techniques like Decision Tree, Neural Networks etc to classify loan applications using R.

Predict Churn for a Telecom company using Logistic Regression
Machine Learning Project in R- Predict the customer churn of telecom sector and find out the key drivers that lead to churn. Learn how the logistic regression model using R can be used to identify the customer churn in telecom dataset.