scikit-learn / keras basic implementation...

Post on 23-Sep-2020

41 Views

Category:

Documents

1 Downloads

Preview:

Click to see full reader

TRANSCRIPT

Scikit-learn / Keras Basic Implementation Tutorial

2019.03.20Jacky, Chun-Yen Yeh

!1

Goal

• Introduce Scikit-learn, Keras Python library(framework).

• Go through the workflow of the classification problem.

• Lead you to step-by-step implement classification problem with Scikit-learn / Keras.

!2

Overview

!3

Artificial IntelligenceMachine Learning

Deep LearningDecision Tree

Nearest NegihborsLogistic Regression CNN

RNNTf-idf

Data Engineering . . .

.

.

.

Overview

!4

Artificial IntelligenceMachine Learning

Deep Learningdecision tree

Nearest NegihborsLogistic Regression CNN

RNNTf-idf

Data Engineering . . .

.

.

.

Scikit-learn

Keras

Scikit-learn

!5

What’s Scikit-learn?

!6

• A free software machine learning library for the Python language.

• Simple and efficient tools for data mining and data analysis.

• Derived from SciPy, which is a Python-based ecosystem of open-source software for mathematics, science, and engineering. (e.g. Numpy, pandas, jupyter notebook)

Why’s Scikit-learn• Commitment to documentation and usability.

• Covers most machine-learning tasks: classification, regression, clustering, dimension reduction, data preprocessing, etc…

!7

!8

Supervised Classification

!9

Species Features

Iris Dataset

Split the Dataset

!10

Training Data Testing Data

ALL Data

Typically 75% : 25% = 3 : 1

!11

Training Data

Supervised Workflow

Model

Prediction

Evaluation

Training phase

Inference phase

Training LabelTraining Labels

Testing Data

Testing Labels

Model Construction

!12

Training Data

Supervised Workflow

Model

Prediction

Evaluation

Training phase

Inference phase

Training LabelTraining Labels

Testing Data

Testing Labels

Model Construction

classifier.fit(X_train, y_train)

classifier = LogisticRegression()

classifier.predict(X_test)

classifier.score(X_test, y_test)

Exercise time

!13

Please enter this file and click your link. https://reurl.cc/nN28n

Keras

!14

What’s Keras?

!15

Keras is a high-level deep learning API, written in Python and capable of running on top of TensorFlow, CNTK, or Theano.

Why’s Keras?

• Allows for easy and fast prototyping (through user friendliness, modularity, and extensibility).

• Supports both convolutional networks and recurrent networks, as well as combinations of the two.

• Runs seamlessly on CPU and GPU.

• Complete documentation (keras.io)

!16

Three Steps of Deep Learning

!17

Step1 Define a set of

function

Step2 Goodness of

function

Step3 Pick the best

function

!18Output

Like lego :)

!19

Prediction Real Label

loss (difference)

!20

parameters

choose optimizer (SGD, RMSProp, …)

!21

Training Data

Supervised Workflow

Model

Prediction

Evaluation

Training phase

Inference phase

Training LabelTraining Labels

Testing Data

Testing Labels

Model Construction

classifier.predict_classes(X_test)

classifier.score(X_test, y_test)

Exercise time

!22

Please enter this file and click your link. https://reurl.cc/nN28n

!23

top related