Farrah's Notebook


  • Home

  • About

  • Tags

  • Categories

  • Archives

TensorFlow and Deep Neural Network (DNN)

Posted on 2019-08-30 | In Machine Learning

In this note, I use iris dataset from Kaggle to learn how to use TensorFlow Estimators to construct a DNN model.

Estimator Steps

  1. Read in data (+ normalize)
  2. Train/test split
  3. Create feature columns
  4. Create estimator input function and estimator model
  5. Train estimator model
  6. Predict with test input function
  7. Evaluation
Read more »

TensorFlow and MNIST Data Set

Posted on 2019-08-30 | In Machine Learning

TensorFlow

This note shows how to use TensorFlow with MNIST Data Set .

We will briefly go through the installation and common elements of TensorFlow. Then we will start to input the MNIST data, and use Matplotlib to display some of our MNIST images. After that we start to construct our TensorFlow model with cross entropy error measure and gradient descent optimization. Finally we will compare our output y to test dataset to estimate our model performance.

Read more »

Hexo-MathJax

Posted on 2019-08-27 | In Hexo

Setup MathJax in themes/next/_config.yml

Test MathJax

Inline:

$a = b + c$.

Simple inline $a = b + c$.

Equations:

$$
\frac{\partial u}{\partial t}
= h^2 \left( \frac{\partial^2 u}{\partial x^2} +
\frac{\partial^2 u}{\partial y^2} +
\frac{\partial^2 u}{\partial z^2}\right)
$$

$$
\frac{\partial u}{\partial t}
= h^2 \left( \frac{\partial^2 u}{\partial x^2} +
\frac{\partial^2 u}{\partial y^2} +
\frac{\partial^2 u}{\partial z^2}\right)
$$

Note of Convolutional Neural Networks

Posted on 2019-08-18 | In Machine Learning

Lecture Video:
https://www.youtube.com/watch?v=FmpDIaiMIeA&feature=youtu.be&t=1m43s
by Brandon Rohrer

Convolutional Neural Networks(CNN / 卷積神經網路)

CNN: Match pieces of image

Read more »

Data Analysis and Logistic Regression

Posted on 2019-08-15 | In Machine Learning

In this project we use Titanic Data Set from Kaggle, to see how to analysis data and deal with missing data.

The features include Name, Sex, Age, SibSp(number of sibling or husband), Our prediction target is a classification problem: whether the people ‘suvival or deceased’.

After data analysis and data cleaning, we will use a logistic model later for the classification.

Finally, we evaluate the resulting model and see the performance.

Data Analysis and Data Cleaning

import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
import seaborn as sns
%matplotlib inline
train = pd.read_csv('titanic_train.csv')
train.head()

PassengerId Survived Pclass Name Sex Age SibSp Parch Ticket Fare Cabin Embarked
0 1 0 3 Braund, Mr. Owen Harris male 22.0 1 0 A/5 21171 7.2500 NaN S
1 2 1 1 Cumings, Mrs. John Bradley (Florence Briggs Th... female 38.0 1 0 PC 17599 71.2833 C85 C
2 3 1 3 Heikkinen, Miss. Laina female 26.0 0 0 STON/O2. 3101282 7.9250 NaN S
3 4 1 1 Futrelle, Mrs. Jacques Heath (Lily May Peel) female 35.0 1 0 113803 53.1000 C123 S
4 5 0 3 Allen, Mr. William Henry male 35.0 0 0 373450 8.0500 NaN S
Read more »

Python-SKlearn

Posted on 2019-08-07 | In Python

Scikit-learn Introduction

  • Scikit-learn介紹
    https://ithelp.ithome.com.tw/articles/10204845
    https://ithelp.ithome.com.tw/articles/10204920
  • Scikit-learn介紹 - Feature Engineering
    https://ithelp.ithome.com.tw/articles/10205475
  • Scikit-learn介紹 - Bayes Classification
    https://ithelp.ithome.com.tw/articles/10205582
Read more »

Pandas - Missing Data

Posted on 2019-08-05 | In Python

Missing Data

Let’s show a few convenient methods to deal with Missing Data in pandas:
pd.dropna(axis, thresh)
pd.fillna(value)

import numpy as np
import pandas as pd

df = pd.DataFrame({'A':[1,2,np.nan],
'B':[5,np.nan,np.nan],
'C':[1,2,3]})
Read more »

Pandas

Posted on 2019-08-05 | In Python

Pandas

  1. Pandas is for fast analysis and data cleaning and preparation.
  2. Built on top of Numpy.
  3. Work with data from a wide variety of sources.

1. Pandas Series

Just like dictionary of Python:

import pandas as pd

pd.Series(data = mylist, index = labelList)
pd.Series(myDict)
Read more »

NumPy Indexing and Selection

Posted on 2019-08-03 | In Python

NumPy Indexing and Selection

In this lecture we will discuss how to select elements or groups of elements from an array.

import numpy as np
#Creating sample array
arr = np.arange(0,11)

Bracket Indexing and Selection

The simplest way to pick one or some elements of an array looks very similar to python lists:

Read more »

Perceptron Model (PLA)

Posted on 2019-08-02 | In Machine Learning

In this note I used the homework1’s dataset from Coursera course: Machine Learning Foundations

First I import the data by Pandas.read_csv funciton and spilt the dataset by train_test_split, which can split the dataset to train / test data with random sorting.
Then I’m going to implemnt two perceptron models: In the first perceptron I use sklearn.line_model.Perceptron to train a Perceptron then evaluate the accuracy. In the second preceptron, I do the perceptron manually by scratching its graph y = W’X, and evaluate the accuracy.
Finally, the average of iteration of perceptron convergence is counted with the operation time, to check the performance of our manually perceptron model.

Import Data

import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
import seaborn as sns
%matplotlib inline
column_names = ['x1', 'x2', 'x3', 'x4', 'y']
data = pd.read_csv('hw1_15_train.dat', sep="\s+", header = None, names = column_names)
data.head()

x1 x2 x3 x4 y
0 0.97681 0.107230 0.64385 0.29556 1
1 0.67194 0.241800 0.83075 0.42741 1
2 0.20619 0.233210 0.81004 0.98691 1
3 0.51583 0.055814 0.92274 0.75797 1
4 0.70893 0.108360 0.33951 0.77058 1
Read more »
12

Farrah Tsai

15 posts
3 categories
21 tags
0%
© 2019 Farrah Tsai