SlideShare une entreprise Scribd logo
1  sur  159
Télécharger pour lire hors ligne
NTUT provides two
email accounts
NTUT Cloud
• https://my.vmware.com/en/web/vmware/downloads/info/sl
ug/desktop_end_user_computing/vmware_horizon_clients/ho
rizon_8
• vdesk.ntut.edu.tw
NTUT Cloud
• vdesk.ntut.edu.tw
NTUT Software Cloud
A bunch of softwares
Use Ubuntu in NTUT Cloud
• Console/ Terminal is the first step.
Google Cloud is
convinient
Use Google Colab for
python excise.
Create your own
environment
by vmware + ubuntu
Data grabbing
Get Open Data Sources on the
internet browser
– Restful API
• https://ci.taiwan.gov.tw/dsp/environmental.aspx
• https://mis.twse.com.tw/stock/api/getStockInfo.jsp?ex_ch=tse_23
30.tw&json=1&delay=0
• https://api.dictionaryapi.dev/api/v2/entries/en/similar
• https://sta.ci.taiwan.gov.tw/STA_AirQuality_v2/v1.0/Datastreams?
$expand=Thing,Observations($orderby=phenomenonTime%20des
c;$top=1)&$filter=name%20eq%20%27PM2.5%27%20and%20Thing/
properties/authority%20eq%20%27%E8%A1%8C%E6%94%BF%E9%99
%A2%E7%92%B0%E5%A2%83%E4%BF%9D%E8%AD%B7%E7%BD%B2%
27%20and%20substringof(%27%E7%A9%BA%E6%B0%A3%E5%93%81
%E8%B3%AA%E6%B8%AC%E7%AB%99%27,Thing/name)&$count=tr
ue
JSON format
• 'https://mis.twse.com.tw/stock/api/getSto
ckInfo.jsp?ex_ch=tse_2330.tw&json=1&del
ay=0'
Get Open Data Sources on
Advanced Rest Client
• Advanced Rest Client run on chrome
• https://chrome.google.com/webstore/detail/ad
vanced-rest-
client/hgmloofddffdnphfgcellkdfbfbjeloo?page=
1&hl=zh-tw&itemlang=sv
Online Restful Client
• https://restninja.io/
Basic knowledge of
CLI(commandline)
• Install needed packages whenever login in the
google colab
• apt-get install jq
• cd : Change directory
• pwd : Show the current directory
• cd .. : Leave the current directory
• cd [Directory name] : Enter the [Directory name]
• wget [URL] : Download the file from the URL
• curl [URL] : Powerfully download the anything from
the URL
Basic knowledge of google
colab CLI(commandline)
• Install needed packages whenever login in the google colab
• !apt-get install jq
• % : Use % if the command needs to be run on the specific
notebook
• ! : Use ! if the command is run in a separate shell.
• %cd : Change directory
• !pwd : Show the current directory
• !cd .. : Leave the current directory
• !cd [Directory name] : Enter the [Directory name]
• !wget [URL] : Download the file from the URL
• !curl [URL] : Powerfully download the anything from the URL
Retrieve Open data on Linux CLI
• curl -s
'https://mis.twse.com.tw/stock/api/getStockInfo.jsp?ex_ch=tse_23
30.tw&json=1&delay=0' | jq '.["msgArray"][0]["h"] '
• curl -s 'https://api.dictionaryapi.dev/api/v2/entries/en/similar'
• curl -s
'https://sta.ci.taiwan.gov.tw/STA_AirQuality_v2/v1.0/Datastreams?
$expand=Thing,Observations($orderby=phenomenonTime%20des
c;$top=1)&$filter=name%20eq%20%27PM2.5%27%20and%20Thing/
properties/authority%20eq%20%27%E8%A1%8C%E6%94%BF%E9%99
%A2%E7%92%B0%E5%A2%83%E4%BF%9D%E8%AD%B7%E7%BD%B2%
27%20and%20substringof(%27%E7%A9%BA%E6%B0%A3%E5%93%81
%E8%B3%AA%E6%B8%AC%E7%AB%99%27,Thing/name)&$count=tr
ue' | jq '.["value"][0]["Observations"][0]["result"] '
API Key
• Proprietary Restful API needs to register a API Key
• https://newsapi.org/
• Registered Newsapi API Key
• 1ac7db45547b4a6d928a6dedb7296d4e
• Get data from any browser :
• https://newsapi.org/v2/top-
headlines?country=us&apiKey=1ac7db45547b4a6d92
8a6dedb7296d4e
• Get data from Colab CLI:
• !curl -s 'https://newsapi.org/v2/top-
headlines?country=us&apiKey=1ac7db45547b4a6d92
8a6dedb7296d4e' | jq '.["articles"][]["content"]?'
Find the whole headlines
with Trump in all media
• Step 1 : Read the available news contents in the NewsApi
• curl ‐s 'https://newsapi.org/v2/top‐
headlines?country=us&apiKey=1ac7db45547b4a6d928a6dedb7296d4e'
• Step 2 : List every article of the whole media from the above
JSON data
• jq '.["articles"][]["content"]?'
• Step 3 : Filter out the articles relevant to “Trump”
• grep -i 'Trump'
• Process in batch
• curl ‐s 'https://newsapi.org/v2/top‐
headlines?country=us&apiKey=1ac7db45547b4a6d928a6dedb7296
d4e' | jq '.["articles"][]["content"]?' | grep ‐i 'Trump'
Alternative google cloud
for CLI
• https://shell.cloud.google.com/
Google cloud shell or
jupyter-lab
• https://shell.cloud.google.com/
• Jupyter-lab run on the conda
• run -i “script.py”
Control modeling with
python
• https://www.youtube.com/watch?v=fI9Q_haTnVI
Regular Expression
Regular Expression
• What is regular expression?
• An expression of a pattern in a string using
special characters and words.
• When and where we use it?
• Regular expression is used to parse an output
from a software , for example, BLAST, or used
to extract information you need from a text file.
When a string | line matches the pattern, it is
extracted. Therefore, it is extremely useful.
[Ref]:https://www.slideshare.net/vtriqn/regular-expressions-grep-and-egrep
Download the materials
• Move to AIEMBA directory
• Move to user’s home directory
$ cd ~
• Create the AIEMBA directory
$ mkdir AIEMBA
• Download the materials
$ wget
"https://drive.google.com/uc?export=download&id=1Rq3
h3rdRYLoEJsAei_0H7VnXI0XjfYI-" -O AIEMBA_20201111.zip
• Extract the zip file
• unzip AIEMBA_20201111.zip
What Is a Regular Expression?
• A regular expression (regex) describes a set of possible
input strings.
• Regular expressions descend from a fundamental concept in
Computer Science called finite automata theory
• Regular expressions are endemic to Unix
– vi, ed, sed, and emacs
– awk, tcl, perl and Python
– grep, egrep, fgrep
– compilers
[Ref]:https://www.slideshare.net/vtriqn/regular-expressions-grep-and-egrep
Regular Expressions
• The simplest regular expressions are a
string of literal characters to match.
• The string matches the regular expression if
it contains the substring.
[Ref]:https://www.slideshare.net/vtriqn/regular-expressions-grep-and-egrep
grep Family
• Syntax
grep [-ilnv] [-e expression] [filename]
egrep [-ilnv] [-e expression] [-f filename] [expression]
[filename]
– -i Ignore case
– -l List only filenames containing matching lines
– -n Precede each matching line with its line number
– -v Negate matches
– -e expression
– -f filename
Specify expression as option
Take the regular expression (egrep) or
a list of strings (fgrep) from filename
[Ref]:https://www.slideshare.net/vtriqn/regular-expressions-grep-and-egrep
Test document
"Open Source" is a good mechanism to develop programs.
apple is my favorite food.
Football game is not use feet only.
this dress doesn't fit me.
However, this dress is about $ 3183 dollars.
GNU is free air not free beer.
Her hair is very beauty.
I can’t finish the test.
Oh! The soup taste good.
motorcycle is cheap than car.
This window is clear.
the symbol '*' is represented as start.
Oh! My god!
The gd software is a library for drafting programs.
You are the best is mean you are the no. 1.
The world is the same with "glad".
I like dog.
google is the best tools for search keyword.
goooooogle yes!
go! go! Let's go.
# I am VBird
CLI $ grep 'good' regular_express.txt
Print out the line with “good” in the regular_express.txt
UNIX Tools rocks.
match
UNIX Tools sucks.
match
UNIX Tools is ock.
no match
regular expression c k s
[Ref]:https://www.slideshare.net/vtriqn/regular-expressions-grep-and-egrep
Keyword matching
Ex : Find the lines with 'the' in the file
CLI $ grep ‐n 'the' regular_express.txt
8:I can't finish the test.
12:the symbol '*' is represented as start.
15:You are the best is mean you are the no. 1.
16:The world is the same with "glad".
18:google is the best tools for search keyword.
Case insensitive
Ex : Find the lines with case insensitive ‘the’ in the file
CLI $ grep ‐in 'the' regular_express.txt
8:I can't finish the test.
9:Oh! The soup taste good.
12:the symbol '*' is represented as start.
14:The gd software is a library for drafting programs.
15:You are the best is mean you are the no. 1.
16:The world is the same with "glad".
18:google is the best tools for search keyword.
Regular Expressions
• A regular expression can match a string in
more than one place.
Scrapple from the apple.
match 1 match 2
regular expression a p p l e
[Ref]:https://www.slideshare.net/vtriqn/regular-expressions-grep-and-egrep
Character Classes
• Character classes [] can be used to match
any specific set of characters.
beat a brat on a boat
match 1 match 2
regular expression b [eor] a t
match 3
[Ref]:https://www.slideshare.net/vtriqn/regular-expressions-grep-and-egrep
Character Classes
• Ex:
• t[ae]st == tast OR test
≠ taest
CLI $ grep ‐n ‘t[ae]st’ regular_express.txt
8:I can't finish the test.
9:Oh! The soup taste good.
Find the line with ‘oo’
• Ex:
CLI $ grep ‐n 'oo' regular_express.txt
1:"Open Source" is a good mechanism to develop programs.
2:apple is my favorite food.
3:Football game is not use feet only.
9:Oh! The soup taste good.
18:google is the best tools for search keyword.
19:goooooogle yes!
Negated Character
Classes
• Character classes can be negated with the
[^] syntax.
beat a brat on a boat
match
regular expression b [^eo] a t
[Ref]:https://www.slideshare.net/vtriqn/regular-expressions-grep-and-egrep
Negative lookahead
•Find the lines without g in front of oo.
•不想要 oo 前面有 g
• Ex:
CLI $ grep ‐n '[^g]oo' regular_express.txt
2:apple is my favorite food.
3:Football game is not use feet only.
18:google is the best tools for search keyword.
19:goooooogle
More About Character Classes
– [aeiou] will match any of the characters a, e, i, o,
or u
– [kK]orn will match korn or Korn
• Ranges can also be specified in character classes
– [1-9] is the same as [123456789]
– [abcde] is equivalent to [a-e]
– You can also combine multiple ranges
• [abcde123456789] is equivalent to [a-e1-9]
– Note that the - character has a special meaning in a
character class but only if it is used within a range,
[-123] would match the characters -, 1, 2, or 3
[Ref]:https://www.slideshare.net/vtriqn/regular-expressions-grep-and-egrep
Named Character Classes
• Commonly used character classes can be
referred to by name (alpha, lower, upper,
alnum, digit, punct, cntrl)
• Syntax [:name:]
– [a-zA-Z]
– [a-zA-Z0-9]
– [45a-z]
[[:alpha:]]
[[:alnum:]]
[45[:lower:]]
• Important for portability across languages
[Ref]:https://www.slideshare.net/vtriqn/regular-expressions-grep-and-egrep
Find a span
•The digits inside the brackets can be any
numbers or span of numbers from 0 to 9.
• Ex:
CLI $ grep ‐n '[0‐9]' regular_express.txt
5:However, this dress is about $ 3183 dollars.
15:You are the best is mean you are the no. 1.
Negative matching
•Find the ASCII characters which is not in the
range from a to z
• Ex:
CLI $ grep ‐n '[^a‐z]oo' regular_express.txt
3:Football game is not use feet only.
Anchors
• Anchors are used to match at the beginning or end
of a line (or both).
• ^ means beginning of the line
• $ means end of the line
[Ref]:https://www.slideshare.net/vtriqn/regular-expressions-grep-and-egrep
• Ex:
CLI $ grep ‐n '^the' regular_express.txt
12:the symbol '*' is represented as start.
beat a brat on a boat
regular expression ^ b [eor] a t
match
regular expression b [eor] a t $
beat a brat on a boat
match
^$
^word$
[Ref]:https://www.slideshare.net/vtriqn/regular-expressions-grep-and-egrep
Define the beginning
• Ex:
•Find the lowercase characters which exists in the
beginning of the line
CLI $ grep ‐n '^[a‐z]' regular_express.txt
2:apple is my favorite food.
4:this dress doesn't fit me.
10:motorcycle is cheap than car.
12:the symbol '*' is represented as start.
18:google is the best tools for search keyword.
19:goooooogle yes!
Complex regex pattern
CLI $ grep ‐n '^[^a‐zA‐Z]' regular_express.txt
1:"Open Source" is a good mechanism to develop programs.
20:# I am VBird
Match the special characters
• ! $ % ^ & * ( ) _ + | ~ - = ` { } [ ] : “ ; ‘ < > ? , . /
• Slash symbol ‘’ can escape the function of the special
characters
CLI $ grep ‐n '.$' regular_express.txt
1:"Open Source" is a good mechanism to develop programs.
2:apple is my favorite food.
3:Football game is not use feet only.
4:this dress doesn't fit me.
10:motorcycle is cheap than car.
11:This window is clear.
12:the symbol '*' is represented as start.
15:You are the best is mean you are the no. 1.
16:The world is the same with "glad".
17:I like dog.
18:google is the best tools for search keyword.
Regular Expressions
• The . regular expression can be used to
match any character.
For me to poop on.
match 1 match 2
regular expression o .
[Ref]:https://www.slideshare.net/vtriqn/regular-expressions-grep-and-egrep
Repetition
• The * is used to define zero or more
occurrences of the single regular expression
preceding it.
[Ref]:https://www.slideshare.net/vtriqn/regular-expressions-grep-and-egrep
I got mail, yay!
match
regular expression y a * y
For me to poop on.
regular expression o a * o
match
.*
[Ref]:https://www.slideshare.net/vtriqn/regular-expressions-grep-and-egrep
Match length
Scrapple from the apple.
no
yes
regular expression a . * e
• A match will be the longest string that
satisfies the regular expression.
no
[Ref]:https://www.slideshare.net/vtriqn/regular-expressions-grep-and-egrep
Repetition Ranges
• Ranges can also be specified
– { } notation can specify a range of repetitions
for the immediately preceding regex
– {n} means exactly n occurrences
– {n,} means at least n occurrences
– {n,m} means at least n occurrences but no
more than m occurrences
• Example:
– .{0,} same as .*
– a{2,} same as aaa*
[Ref]:https://www.slideshare.net/vtriqn/regular-expressions-grep-and-egrep
Colab grex {} bug
[Ref]:https://www.slideshare.net/vtriqn/regular-expressions-grep-and-egrep
CLI in Colab: !grep ‐Eio '[a‐z]{{2,}}' regular_express.txt
• {} should be repeated as {{ }}
• Ranges can also be specified
– {{}}notation can specify a range of repetitions for the
immediately preceding regex
– {{n}}means exactly n occurrences
– {{n,}}means at least n occurrences
– {{n,m}}means at least n occurrences but no more than m
occurrences
CLI $ grep ‐Eio '[a‐z]{2,}' regular_express.txt
Subexpressions
• If you want to group part of an expression so that
* or { } applies to more than just the
previous character, use ( ) notation
• Subexpresssions are treated like a single character
– a* matches 0 or more occurrences of a
– abc* matches ab, abc, abcc, abccc, …
– (abc)* matches abc, abcabc,
abcabcabc, …
– (abc){2,3} matches abcabc or
abcabcabc
[Ref]:https://www.slideshare.net/vtriqn/regular-expressions-grep-and-egrep
找出 g 後面接 2 到 5 個 o
[root@test root]# grep -n 'go{2,5}g' regular_express.txt
18:google is the best tools for search keyword.
.* 是什麼
[root@test root]# grep -n 'g.*g' regular_express.txt
1:"Open Source" is a good mechanism to develop programs.
14:The gd software is a library for drafting programs.
18:google is the best tools for search keyword.
19:goooooogle yes!
Escaping Special Characters
• Even though we are single quoting our regexs so the shell won’t
interpret the special characters, some characters are special to grep (eg
* and .)
• To get literal characters, we escape the character with a  (backslash)
• Suppose we want to search for the character sequence
• a*b*
• –Unless we do something special, this will match zero or more ‘a’s followed by
zero or more ‘b’s, not what we want
• – a*b* will fix this - now the asterisks are treated as regular characters
[Ref]:https://www.slideshare.net/vtriqn/regular-expressions-grep-and-egrep
Egrep: Alternation
• Regex also provides an alternation character | for matching
one or another subexpression
– (T|Fl)an will match ‘Tan’ or ‘Flan’
– ^(From|Subject): will match the From and Subject lines
of a typical email message
• It matches a beginning of line followed by either the characters
‘From’ or ‘Subject’ followed by a ‘:’
• Subexpressions are used to limit the scope of the alternation
– At(ten|nine)tion then matches “Attention” or “Atninetion”,
not “Atten” or “ninetion” as would happen without the parenthesis -
Atten|ninetion
[Ref]:https://www.slideshare.net/vtriqn/regular-expressions-grep-and-egrep
| 字元
• 用或( or )的方式找出數個字串
• 範例:egrep -n 'gd|good' regular_express.txt
搜尋 gd 或 good 這兩個字串,注意,是『或』! 所以,
第 1,9,14 這三行都可以被列印出來喔!那如果還想要找出
dog 呢?就這樣
CLI $ egrep ‐n 'gd|good|dog' regular_express.txt
() 字元
• 找出『群組』字串
•
搜尋 (glad) 或 (good) 這兩個字串,因為 g 與 d 是重複
的,所以, 我就可以將 la 與 oo 列於 ( ) 當中,並以 | 來
分隔開來,就可以啦!
此外,這個功能還可以用來作為『多個重複群組』的判別
喔!舉例來說:
echo 'AxyzxyzxyzxyzC' | egrep 'A(xyz)+C'
上面的例子當中,意思是說,我要找開頭是 A 結尾是 C ,
中間有一個以上的 "xyz" 字串的意思~
CLI $ egrep ‐n 'g(la|oo)d' regular_express.txt
Egrep: Repetition
Shorthands
• The * (star) has already been seen to specify zero
or more occurrences of the immediately preceding
character
• + (plus) means “one or more”
 abc+d will match ‘abcd’, ‘abccd’, or ‘abccccccd’ but
will not match ‘abd’
 Equivalent to {1,}
[Ref]:https://www.slideshare.net/vtriqn/regular-expressions-grep-and-egrep
+ 字元
• 重複『一個或一個以上』的前一個 RE 字符
•
搜尋 (god) (good) (goood)... 等等的字串。 那個 o+ 代表『一個
以上的 o 』所以,上面的執行成果會將第 1, 9, 13 行列出來。
CLI $ egrep ‐n 'go+d' regular_express.txt
Egrep: Repetition
Shorthands cont
• The ‘?’ (question mark) specifies an optional character,
the single character that immediately precedes it
 July? will match ‘Jul’ or ‘July’


Equivalent to {0,1}
Also equivalent to (Jul|July)
•
•
The *, ?, and + are known as quantifiers because they
specify the quantity of a match
Quantifiers can also be used with subexpressions
– (a*c)+ will match ‘c’, ‘ac’, ‘aac’ or ‘aacaacac’ but will not
match ‘a’ or a blank line
[Ref]:https://www.slideshare.net/vtriqn/regular-expressions-grep-and-egrep
Prolog
PROGRAMMING IN LOGIC
Logic calculator
• https://www.umsu.de/trees/
• http://eval-b.stups.uni-duesseldorf.de/index.html
• https://www.erpelstolz.at/gateway/formular-uk-zentral.html
SWI-Prolog
• SWI-Prolog is a good, standard Prolog for Windows and Linux
• Can be installed on Macintosh with a little more effort
(requires X11 and Mac developer tools)
• It's licensed under GPL, therefore free
• Downloadable from:
http://www.swi‐prolog.org/
66
Syllogisms
• “Prolog” is all about programming in logic.
• Aristotle described syllogisms 2300 years ago
• Sample syllogism:
• Socrates is a man.
• All men are mortal.
• Therefore, Socrates is mortal.
• Syllogisms are a form of logic. Can Prolog do them?
• Note: If a word or term is in red, you should learn
and remember its meaning
67
Forward and backward
reasoning
• A syllogism gives two premises and a conclusion
• Forward reasoning: Given some premises, ask “What can we
conclude?”
• Forward reasoning is inefficient when you are trying to get a particular
conclusion
• Backward reasoning: Given some premises and a
conjectured conclusion, try to derive the conclusion from the
premises
• You start from the conclusion and try to work backward to prove it
• You use Prolog by asking it specific questions
• This is backward reasoning -- from (potential) conclusions to facts 68
Syllogisms in Prolog
69
Syllogism
Socrates is a man.
All men are mortal.
Is Socrates mortal?
man(socrates).
mortal(X) :‐ man(X).
?‐ mortal(socrates).
Prolog
Facts, rules, and queries
• Fact: Socrates is a man.
• man(socrates).
• Rule: All men are mortal.
• mortal(X) :‐ man(X).
• Query: Is Socrates mortal?
• mortal(socrates).
• Queries have the same form as facts
70
Variables and atoms
• Variables begin with a capital letter:
X, Socrates, _result
• A variable can have a value
• An atom is a value; it just stands for itself
• Atoms do not begin with a capital letter:
x, socrates
71
Running Prolog I
• Create your “database” (program) in any editor
• Save it as text only, with a .pl extension
• If you have Perl installed, you may have to use
the .pro extension instead
• Google swi prolog file extension for
instructions
• Here's the complete program:
72
man(socrates).
mortal(X) :‐ man(X).
Running Prolog II
• SWI-Prolog is interpreted and completely interactive
• You may be able to run your program by double-
clicking your .pl file
• Here are two ways you can run the interpreter:
• Double-click on the swipl file, or
• If your PATH is set correctly, enter swipl at the command line
• At the ?‐ prompt in the interpreter, enter:
• ?‐ consult('Complete path to your .pl file').
• Then, ask your question at the prompt:
• ?‐ mortal(socrates).
• Prolog responds:
• true. 73
Prolog is a theorem prover
• Prolog’s true. means “I can prove it”
• Prolog’s false. really means “I can’t prove it”
• It does not mean “I can prove it is untrue.”
• ?‐ mortal(plato).
false.
• This is the closed world assumption: the Prolog program knows
everything it needs to know
• Prolog supplies values for variables when it can
• ?‐ mortal(X).
X = socrates 74
Structures
• A structure consists of a name and zero or more arguments.
• Omit the parentheses if there are no arguments
• Example structures:
• sunshine
• man(socrates)
• path(garden, south, sundial)
75
Base Clauses
• A base clause is just a structure, terminated with a period.
• A base clause represents a simple fact.
• Example base clauses:
• debug_on.
• loves(john, mary).
• loves(mary, bill).
76
Nonbase Clauses
• A nonbase clause is a structure, a turnstile :- (meaning “if”),
and a list of structures.
• Example nonbase clauses:
• mortal(X) :‐ man(X).
• mortal(X) :‐ woman(X).
• happy(X) :‐ healthy(X), wealthy(X), wise(X).
• The comma between structures means “and”
• “X is happy if X is healthy, wealthy, and wise.”
77
Predicates
• A predicate is a collection of clauses with the same
functor (name) and arity (number of arguments).
• loves(john, mary).
loves(mary, bill).
loves(chuck, X) :‐ female(X), rich(X).
• The scope of a variable (such as X) is the single
clause in which it occurs.
78
Programs
• In Prolog, a program is just a collection of predicates.
• Predicates can be in any order.
• Clauses within a predicate are used in the order in
which they occur.
79
Atoms
• You can make an atom containing any characters at all by
enclosing it in single quotes:
• 'C:My Documentsexamples.pl'
• If you use double quotes, you will get a list of ASCII values
• ?‐ X = "Hello".
X = [72, 101, 108, 108, 111].
• You probably don’t want this!
• In a quoted atom, a single quote must be doubled or backslashed:
• 'Can''t, or won't?'
• Backslashes in file names must also be doubled:
• 'C:My Documentsexamples.pl'
• Better yet, use forward slashes in paths; every OS, including Windows,
understands this 80
Common problems
• Capitalization is meaningful!
• No space is allowed between a functor and its
argument list:
man(socrates), not man (socrates).
• Double quotes indicate a list of ASCII character
values, not a string
• Don’t forget the period! (But if you do, you can put it
on the next line.)
81
Backtracking
• loves(chuck, X) :‐ female(X), rich(X).
• female(jane).
• female(mary).
• rich(mary).
• ---------- Suppose we ask: loves(chuck, X).
• female(X) = female(jane), X = jane.
• rich(jane) fails.
• female(X) = female(mary), X = mary.
• rich(mary) succeeds. 82
Backtracking and Beads
• Each Prolog call is like a “bead” in a string of
beads:
• Each structure has four ports: call, exit, redo, fail
• Exit ports connect to call ports;
fail ports connect to redo ports
83
call
fail
exit
redo
Calls as nested beads
84
loves(chuck, X) :‐ female(X), rich(X).
loves(chuck, X)
female(X) rich(X)
call
fail
exit
redo
Additional answers
• female(jane).
female(mary).
female(susan).
• ?‐ female(X).
• X = jane ;
• X = mary
• Yes
85
female(jane)
female(mary)
female(susan)
female(X)
Readings
• A clause can be read declaratively (as a statement of fact)
or procedurally (as a list of things to try to do)
• loves(chuck, X) :‐ female(X), rich(X).
• Declarative reading: Chuck loves X if X is female and rich.
• Approximate procedural reading:
To find an X that Chuck loves:
• First try to find a female X (fail and backtrack if you can’t)
• Given a particular value for X, try to show that X is rich (fail
and backtrack if you can’t)
• Declarative readings are almost always preferred. 86
BIG DATA PROCESS
Traditional Web Service
• LAMP
• Linux + Apache + MySQL + PHP
Data to Intelligence
• IOT
• Open source
• Proprietary data
Lots of solution available
Data
Source
Data
Collectio
n/Ingesti
on
Stream
Data
Processing
Data
Storage
Data
Presentatio
n
/Analysis
Communicati
on
Protocol
Communication Data format:
JSON, CSV, BSON, YAML, XML
General Data flow
**Uber
• http://blog.itpub.net/31077337/viewspace-2212401/
Netflix at Spark+AI Summit 2018
• https://netflixtechblog.com/netflix-at-spark-ai-summit-2018-
5304749ed7fa
Twitter
System Considerations
• Client/server configuration:
• Real-time: 即時消費、即時新聞
• Data structure
• Data Volume
• Speed
Data Science
• https://data-flair.training/blogs/data-science-vs-artificial-
intelligence/
 Logic and Math
Where is the insight?
• https://www.jos.com/big-data-for-real
Human intelligence & AI
IOT Big data
Artificial
Intelligence
Managemen
t
Philosophy
耳聰目明
百納海川/
招兵買馬
化繁為簡
去蕪存精
趨吉避凶
臨機應變
琴瑟和鳴
Sensing/
Retrieve
Ingestion
/Collection
Storage/
Analysis
Optimization
Creation/
Balancing
https://www.erikgfesser.com/weblog/2016/09/end-to-end-streaming-ml-recommendation-
pipeline-spark-20-kafka-tensorflow-chicago-workshop-chris-fregly.html
Programing language
choice
Database
SQl vs NoSQL
Data base choice
• elasticsearch 和 hbase 比較
https://www.zhihu.com/question/41109030
DATA SCIENCE
Foundations of Computer
Science
• http://infolab.stanford.edu/~ullman/focs.html
• Chapter 1 Computer Science: The Mechanization of Abstraction
• Chapter 2 Iteration, Induction, and Recursion
• Chapter 3 The Running Time of Programs
• Chapter 4 Combinatorics and Probability
• Chapter 5 The Tree Data Model
• Chapter 6 The List Data Model
• Chapter 7 The Set Data Model
• Chapter 8 The Relational Data Model
• Chapter 9 The Graph Data Model
• Chapter 10 Patterns, Automata, and Regular Expressions
• Chapter 11 Recursive Description of Patterns
• Chapter 12 Propositional Logic
• Chapter 13 Using Logic to Design Computer Components
• Chapter 14 Predicate Logic
Download the materials on
20201202.zip
• Move to AIEMBA directory
• Move to user’s home directory
$ cd ~
• Download the materials
$ wget
"https://drive.google.com/uc?export=download&id=1izf2QN
xLIH-gx95h7ecQNgtlNiakW7Xw" -O AIEMBA_20201202.zip
• Extract the zip file
• unzip AIEMBA_20201202.zip
https://www.mdeditor.tw/pl/p9gR/zh-tw
Data Tools
Tutorials in Github
 [Book / github / Data /Beginner ]
 https://github.com/jakevdp/PythonDataScienceHandbo
ok
 [github / Data /Beginner ]
 https://github.com/Pierian-Data/Complete-Python-3-
Bootcamp
► [ Book / github / Data / Math ] Data science from scratch
► [ Book / github / Finance ] Python for finance
► [Collections] https://iter01.com/158569.html
Data science from scratch
► https://github.com/joelgrus/data-science-from-scratch
1. Introduction
2. A Crash Course in Python
3. Visualizing Data
4. Linear Algebra
5. Statistics
6. Probability
7. Hypothesis and Inference
8. Gradient Descent
9. Getting Data
10. Working With Data
11. Machine Learning
12. k-Nearest Neighbors
13. Naive Bayes
14. Simple Linear Regression
15. Multiple Regression
16. Logistic Regression
17. Decision Trees
18. Neural Networks
19. [Deep Learning]
20. Clustering
21. Natural Language Processing
22. Network Analysis
23. Recommender Systems
24. Databases and SQL
25. MapReduce
課程比重
Case 1 Introduction to python Python 速成 VVVVV
Case 2 Visualizing Data 數據視覺化 VVV
Case 3 Linear Algebra 線性代數 V
Case 4 Statistics 統計學 V
Case 5 Probability 機率 V
Case 6 Hypothesis and Inference 假設與推論 V
Case 7 Gradient Descent 梯度遞減 V
Case 8 Getting Data 取得數據資料 VVV
Case 9 Working With Data 處理數據資料 VVV
Case 10 Machine Learning 機器學習 VV
Case 11 k-Nearest Neighbors k最近鄰 V
Case 12 Naive Bayes 單純貝氏 V
Case 13 Simple Linear Regression 簡單線性迴歸 VVV
Case 14 Multiple Regression 多元迴歸 VVV
Case 15 Logistic Regression 邏輯迴歸 VVV
Case 16 Decision Trees 決策樹 VVV
Case 17 Neural Networks 神經網路 V
Case 18 [Deep Learning] 深度學習 V
Case 19 Clustering 集群
Case 20 Natural Language Processing 自然語言處理 VV
Case 21 Network Analysis 網路分析 V
Case 22 Recommender Systems 推薦系統 V
Case 23 Databases and SQL 資料庫與SQL VV
Case 24 MapReduce MapReduce
Case study :
Data science
Knowledge System of Data Science
• {Atom} Data type/set manipulation ; Data collection
• {Relation/Propositions; Predicate Logic/Rule/Calculation }
• Linear algebra [scikit-learn] [scipy-lectures]
• Statistics [scipy]
• Data processing ; [scipy]
• Data transformation [scipy]
• FFT; DFT[scipy]
• Image [scipy-lectures]
• { Modal ; Probabilistic logic }
• Data visualization
• Probability
• { Modeling }
• Decision tree
• PCA
• linear
• Clustering biclustering
Python for finance
► https://github.com/yhilpisch/py4fi2nd
1. Python And Finance
2. 1.0 WHY PYTHON FOR FINANCE
3. 2.0 PYTHON INFRASTRUCTURE
4. Mastering The Basics
5. 3.0 DATA TYPES AND STRUCTURES
6. 4.0 NUMERICAL COMPUTING WITH NUMPY
7. 5.0 DATA ANALYSIS WITH PANDAS
8. 6.0 OBJECT-ORIENTED PROGRAMMING
9. Financial Data Science
10. 7.0 DATA VISUALIZATION
11. 8.0 FINANCIAL TIME SERIES
12. 9.0 INPUT/OUTPUT OPERATIONS
13. 10.0 PERFORMANCE PYTHON
14. 11.0 MATHEMATICAL TOOLS
15. 12.0 STOCHASTICS
16. 13.0 STATISTICS
17. Algorithmic Trading
18. 14.0 THE FXCM TRADING PLATFORM
19. 15.0 TRADING STRATEGIES
20. 16.0 AUTOMATED TRADING
21. Derivative Analytics
22. 17.0 VALUATION FRAMEWORK
23. 18.0 SIMULATION OF FINANCIAL MODELS
24. 19.0 DERIVATIVES VALUATION
25. 20.0 PORTFOLIO VALUATION
26. 21.0 MARKET-BASED VALUATION
Materials
► numpy
► https://github.com/numpy/numpy
► https://numpy.org/learn/
► Pandas
► https://github.com/pandas-dev/pandas/
► Matplotlib
► https://github.com/matplotlib/matplotlib
► scipy
► https://scipy-cookbook.readthedocs.io/
► https://github.com/scipy/scipy-cookbook/tree/master/ipython
► scikit learn
► https://scikit-learn.org/stable/auto_examples/index.html#model-selection
► Online manual:
► https://www.tutorialspoint.com/python/python_variable_types.htm
Python for finance
► https://github.com/yhilpisch/py4fi2nd
1. 3.0 DATA TYPES AND STRUCTURES
from decimal import Decimal
a = 1.115
Decimal(a) # Decimal(a) 的值和想像中的不同
Decimal('1.1149999999999999911182158029987476766109466552734375')
b = 1.125
Decimal(b)
# Decimal(b) 的值則和想像中一樣
Decimal('1.125')
from decimal import Decimal
a = 1.115
Decimal(str(a)) # Decimal(a) 的值和想像中一樣了
Decimal('1.115')
b = 1.125
Decimal(str(b)
# Decimal(b) 的值則和想像中一樣
Decimal('1.125')
Sympy for symbolic
► Jypyther is easy to show Latex
► Ipython latex rendering needs markdown
► https://nbviewer.jupyter.org/github/ipython/ipython/blob
/2.x/examples/Notebook/Display%20System.ipynb#LaTeX
► https://blog.csdn.net/halazi100/article/details/79706172
► Latex(r"[ lim_{x to 0} frac{3x^2 +7x^3}{x^2 +5x^4} = 3.]")
► online Latex editor
► https://www.codecogs.com/latex/eqneditor.php
► https://www.mathcha.io/editor
Google Cloud Latex Rendering
import sympy as sym
from IPython.display import Latex
x = sym.symbols('x')
I = sym.integrate(1/(1+x**2), (x, 0, 1))
a = sym.latex(I)
Latex(r'[begin{eqnarray*}' + a + r'end{eqnarray*}]')
a = Integral(cos(x)*exp(x), x)
s= Eq(a, a.doit())
a2 = sym.latex(s)
Latex(r'[begin{eqnarray*}' + a2 + r'end{eqnarray*}]'
Run conda on Google Cloud Console
► If interactive python fails, do the following steps:
► remove ./.local
► /usr/bin/python3 -m pip install -U jupyter --user --ignore-
installed
► restart VS
► conda initiate
► source /home/hwchiu0810/miniconda3/bin/activate
► source /home/hwchiu0810/miniconda3/bin/deactivate
► Kernel Environment Selection for terminals and ipython
Financial Materials
► 證交所即時資訊API
► https://zys-notes.blogspot.com/2020/01/api.html
► Python tools for finance
► https://blog.xuite.net/metafun/life/566073276-
%E3%80%90%E8%BD%89%E3%80%91Best+Python+Libraries
%2FPackages+for+Finance+and+Financial+Data+Scientis
ts
• Tensorflow
• pytorch
ML
• scikitlearn
Modeling
• Math: sympy
• Data :Scipy
Computing
• matplotlib
Data Visualization
• Numpy
• Pandas
Data Management
• Python
• Ipython/Jupyter
• Anaconda/conda
Data tools
數
學
Math
數
據
Data
np / array / matrix
df
plt
number / string / list / dict
ML, Regression
Solve
Optimization
Neural Network,
CNN, RNN
List of basic Data types
List of basic Data types
Unity Number string
Combination Dict
Index by
key
List
Index by
number
Quotation marks
Basic datatype of python and
advanced datatype of numpy
Collections Data / Sequences Data
Numpy data type
Numpy Datatype
Quiz 20201210
• 隨機產生一個大/小寫英字母
Matrix Operation
• https://burweisnote.blogspot.com/2018/06/pythonlistnumpya
rraymatrix.html?m=1
[Ref] https://www.datacamp.com/community/data-science-cheatsheets
Gaming
人文科學 Vs 自然科學
人文科學 自然科學
最小單位 人 粒子
大單位 全球 宇宙
基本作用力 七情六欲
萬有引力、電磁力、強相互
作用、弱相互作用
基本量 比較值 絶對值
動能 最大舒適 最低能量
智能 有 弱 (演化/循環)
人文科學 Vs 自然科學
人文科學 自然科學
唯心論 唯物論
真相 真實、事實
動能 最大舒適 最低能量
What is meaning
邏輯與感覺
• Logic
• Machine Learning
• Fuzzy logic(模糊邏輯)
Difficult decision and simple results
• Who makes the decision?
• Human or Data?
• From very complicated to very simple:
• 1 or 0
• True or false
• Pass or Fail
• Yes or no.
• Do it or not to do it.
Optimization
• https://www.gurobi.com/resource/modeling-examples-using-
the-gurobi-python-api-in-jupyter-notebook/
• https://www.gurobi.com/resource/portfolio-selection-
optimization/
• https://www.gurobi.com/resource/marketing-campaign-
optimization-jupyter-notebook/
• https://github.com/burkesquires/tech-books-library
Logic calculator
• https://www.umsu.de/trees/
• http://eval-b.stups.uni-duesseldorf.de/index.html
• https://www.erpelstolz.at/gateway/formular-uk-zentral.html
Python for Math
Programming skill
Statistics materials
• http://home.ubalt.edu/ntsbarsh/opre640a/partVIII.htm
• https://scikit-learn.org/stable/auto_examples/index.html
Complete Example
• https://github.com/wesm/pydata-book
• https://github.com/yenlung/Python-3-Data-Analysis-
Basics/blob/master/2019%E4%BA%BA%E5%B7%A5%E6%99%BA%E6%85%A7
%E5%AD%B8%E6%A0%A1%E9%86%AB%E7%99%82%E5%B0%88%E7%8F%AD/
%E6%A9%9F%E5%99%A8%E5%AD%B8%E7%BF%92%E5%85%A5%E9%96%80.ip
ynb
• https://nbviewer.jupyter.org/github/pydata/pydata-book/blob/2nd-
edition/ch14.ipynb
• https://github.com/amueller/introduction_to_ml_with_python
• https://github.com/jakevdp/sklearn_scipy2013/tree/master/notebooks
• https://scipy-lectures.org/packages/scikit-learn/index.html
• https://scipy-lectures.org/
Matlab Python Julia
• https://cheatsheets.quantecon.org/
Double Pendulum
• https://www.myphysicslab.com/pendulum/double-
pendulum-en.html
• https://www.youtube.com/watch?v=hXOEoH5q3Hw
• https://www.youtube.com/watch?v=dDU2JsgLpm4
• Chaotic pendulum
Python modeling
• https://github.com/AllenDowney/ModSimPy/tree/master/not
ebooks
Computational Statistics in
Python from Duke
• https://people.duke.edu/~ccc14/sta-663-2018/
• https://github.com/cliburn/sta-663-
2019/tree/master/notebook
Statistical Data Modeling
• https://www.statsmodels.org/stable/examples/notebooks/ge
nerated/statespace_cycles.html
Probability-Statistics in
Python
• https://github.com/unpingco/Python-for-Probability-Statistics-
and-Machine-Learning/tree/master/
• https://github.com/unpingco/Python-for-Probability-Statistics-
and-Machine-Learning-2E/tree/master/chapter

Contenu connexe

Similaire à Labs_20210809.pdf

Web data from R
Web data from RWeb data from R
Web data from R
schamber
 
Tips on how to improve the performance of your custom modules for high volume...
Tips on how to improve the performance of your custom modules for high volume...Tips on how to improve the performance of your custom modules for high volume...
Tips on how to improve the performance of your custom modules for high volume...
Odoo
 
Masters bioinfo 2013-11-14-15
Masters bioinfo 2013-11-14-15Masters bioinfo 2013-11-14-15
Masters bioinfo 2013-11-14-15
Yannick Wurm
 
Gae icc fall2011
Gae icc fall2011Gae icc fall2011
Gae icc fall2011
Juan Gomez
 

Similaire à Labs_20210809.pdf (20)

PyCon AU 2012 - Debugging Live Python Web Applications
PyCon AU 2012 - Debugging Live Python Web ApplicationsPyCon AU 2012 - Debugging Live Python Web Applications
PyCon AU 2012 - Debugging Live Python Web Applications
 
Building Cloud Castles
Building Cloud CastlesBuilding Cloud Castles
Building Cloud Castles
 
Web data from R
Web data from RWeb data from R
Web data from R
 
C# 101: Intro to Programming with C#
C# 101: Intro to Programming with C#C# 101: Intro to Programming with C#
C# 101: Intro to Programming with C#
 
Kubernetes debug like a pro
Kubernetes debug like a proKubernetes debug like a pro
Kubernetes debug like a pro
 
Why you should be using structured logs
Why you should be using structured logsWhy you should be using structured logs
Why you should be using structured logs
 
Tips on how to improve the performance of your custom modules for high volume...
Tips on how to improve the performance of your custom modules for high volume...Tips on how to improve the performance of your custom modules for high volume...
Tips on how to improve the performance of your custom modules for high volume...
 
Revoke-Obfuscation
Revoke-ObfuscationRevoke-Obfuscation
Revoke-Obfuscation
 
Server Logs: After Excel Fails
Server Logs: After Excel FailsServer Logs: After Excel Fails
Server Logs: After Excel Fails
 
Masters bioinfo 2013-11-14-15
Masters bioinfo 2013-11-14-15Masters bioinfo 2013-11-14-15
Masters bioinfo 2013-11-14-15
 
Rails Tips and Best Practices
Rails Tips and Best PracticesRails Tips and Best Practices
Rails Tips and Best Practices
 
Apidays Paris 2023 - Forget TypeScript, Choose Rust to build Robust, Fast and...
Apidays Paris 2023 - Forget TypeScript, Choose Rust to build Robust, Fast and...Apidays Paris 2023 - Forget TypeScript, Choose Rust to build Robust, Fast and...
Apidays Paris 2023 - Forget TypeScript, Choose Rust to build Robust, Fast and...
 
DevOps with Serverless
DevOps with ServerlessDevOps with Serverless
DevOps with Serverless
 
Rooted 2010 ppp
Rooted 2010 pppRooted 2010 ppp
Rooted 2010 ppp
 
Gae icc fall2011
Gae icc fall2011Gae icc fall2011
Gae icc fall2011
 
The ARK Identifier Scheme at Ten Years Old
The ARK Identifier Scheme at Ten Years OldThe ARK Identifier Scheme at Ten Years Old
The ARK Identifier Scheme at Ten Years Old
 
Voxxed Days Vienna - The Why and How of Reactive Web-Applications on the JVM
Voxxed Days Vienna - The Why and How of Reactive Web-Applications on the JVMVoxxed Days Vienna - The Why and How of Reactive Web-Applications on the JVM
Voxxed Days Vienna - The Why and How of Reactive Web-Applications on the JVM
 
Learn c++ Programming Language
Learn c++ Programming LanguageLearn c++ Programming Language
Learn c++ Programming Language
 
An Experiment with Checking the glibc Library
An Experiment with Checking the glibc LibraryAn Experiment with Checking the glibc Library
An Experiment with Checking the glibc Library
 
Machine Learning on Code - SF meetup
Machine Learning on Code - SF meetupMachine Learning on Code - SF meetup
Machine Learning on Code - SF meetup
 

Plus de ssuserb4d806

1-Introduction and Crystal Structure of Solids-已解鎖.pdf
1-Introduction and Crystal Structure of Solids-已解鎖.pdf1-Introduction and Crystal Structure of Solids-已解鎖.pdf
1-Introduction and Crystal Structure of Solids-已解鎖.pdf
ssuserb4d806
 
台北科技大學電子所_可穿戴式系統設計_期末報告 1_賴紀廷_109368501_20230106_2.pptx
台北科技大學電子所_可穿戴式系統設計_期末報告 1_賴紀廷_109368501_20230106_2.pptx台北科技大學電子所_可穿戴式系統設計_期末報告 1_賴紀廷_109368501_20230106_2.pptx
台北科技大學電子所_可穿戴式系統設計_期末報告 1_賴紀廷_109368501_20230106_2.pptx
ssuserb4d806
 
台北科技大學電子所_可穿戴式系統設計_期末報告 1_賴紀廷_109368501_20230106_1.pptx
台北科技大學電子所_可穿戴式系統設計_期末報告 1_賴紀廷_109368501_20230106_1.pptx台北科技大學電子所_可穿戴式系統設計_期末報告 1_賴紀廷_109368501_20230106_1.pptx
台北科技大學電子所_可穿戴式系統設計_期末報告 1_賴紀廷_109368501_20230106_1.pptx
ssuserb4d806
 
Assessment_of_Fetal_and_Maternal_Well-Being_During_Pregnancy_Using_Passive_We...
Assessment_of_Fetal_and_Maternal_Well-Being_During_Pregnancy_Using_Passive_We...Assessment_of_Fetal_and_Maternal_Well-Being_During_Pregnancy_Using_Passive_We...
Assessment_of_Fetal_and_Maternal_Well-Being_During_Pregnancy_Using_Passive_We...
ssuserb4d806
 
台北科技大學電子所_可穿戴式系統設計_期末報告 1_賴紀廷_109368501_20230106_2.pptx
台北科技大學電子所_可穿戴式系統設計_期末報告 1_賴紀廷_109368501_20230106_2.pptx台北科技大學電子所_可穿戴式系統設計_期末報告 1_賴紀廷_109368501_20230106_2.pptx
台北科技大學電子所_可穿戴式系統設計_期末報告 1_賴紀廷_109368501_20230106_2.pptx
ssuserb4d806
 
台北科技大學電子所_可穿戴式系統設計_期末報告 1_賴紀廷_109368501_20230106_1.pptx
台北科技大學電子所_可穿戴式系統設計_期末報告 1_賴紀廷_109368501_20230106_1.pptx台北科技大學電子所_可穿戴式系統設計_期末報告 1_賴紀廷_109368501_20230106_1.pptx
台北科技大學電子所_可穿戴式系統設計_期末報告 1_賴紀廷_109368501_20230106_1.pptx
ssuserb4d806
 
RFIC_LNA_Simulation.ppt
RFIC_LNA_Simulation.pptRFIC_LNA_Simulation.ppt
RFIC_LNA_Simulation.ppt
ssuserb4d806
 
AIML4 CNN lab256 1hr (111-1).pdf
AIML4 CNN lab256 1hr (111-1).pdfAIML4 CNN lab256 1hr (111-1).pdf
AIML4 CNN lab256 1hr (111-1).pdf
ssuserb4d806
 
AIML4 CNN lab 5-1 BreastCancer ML course student report 2022 spring (111-1).pdf
AIML4 CNN lab 5-1 BreastCancer ML course student report 2022 spring (111-1).pdfAIML4 CNN lab 5-1 BreastCancer ML course student report 2022 spring (111-1).pdf
AIML4 CNN lab 5-1 BreastCancer ML course student report 2022 spring (111-1).pdf
ssuserb4d806
 
Lecture 1 System View.pptx - 已修復.pdf
Lecture 1 System View.pptx  -  已修復.pdfLecture 1 System View.pptx  -  已修復.pdf
Lecture 1 System View.pptx - 已修復.pdf
ssuserb4d806
 
Training L1 Thinking 2022702.pptx.pptx
Training L1 Thinking 2022702.pptx.pptxTraining L1 Thinking 2022702.pptx.pptx
Training L1 Thinking 2022702.pptx.pptx
ssuserb4d806
 

Plus de ssuserb4d806 (20)

5.pdf
5.pdf5.pdf
5.pdf
 
4.pdf
4.pdf4.pdf
4.pdf
 
Analog_chap_02.ppt
Analog_chap_02.pptAnalog_chap_02.ppt
Analog_chap_02.ppt
 
Analog_chap_01.ppt
Analog_chap_01.pptAnalog_chap_01.ppt
Analog_chap_01.ppt
 
1-Introduction and Crystal Structure of Solids-已解鎖.pdf
1-Introduction and Crystal Structure of Solids-已解鎖.pdf1-Introduction and Crystal Structure of Solids-已解鎖.pdf
1-Introduction and Crystal Structure of Solids-已解鎖.pdf
 
台北科技大學電子所_可穿戴式系統設計_期末報告 1_賴紀廷_109368501_20230106_2.pptx
台北科技大學電子所_可穿戴式系統設計_期末報告 1_賴紀廷_109368501_20230106_2.pptx台北科技大學電子所_可穿戴式系統設計_期末報告 1_賴紀廷_109368501_20230106_2.pptx
台北科技大學電子所_可穿戴式系統設計_期末報告 1_賴紀廷_109368501_20230106_2.pptx
 
台北科技大學電子所_可穿戴式系統設計_期末報告 1_賴紀廷_109368501_20230106_1.pptx
台北科技大學電子所_可穿戴式系統設計_期末報告 1_賴紀廷_109368501_20230106_1.pptx台北科技大學電子所_可穿戴式系統設計_期末報告 1_賴紀廷_109368501_20230106_1.pptx
台北科技大學電子所_可穿戴式系統設計_期末報告 1_賴紀廷_109368501_20230106_1.pptx
 
Assessment_of_Fetal_and_Maternal_Well-Being_During_Pregnancy_Using_Passive_We...
Assessment_of_Fetal_and_Maternal_Well-Being_During_Pregnancy_Using_Passive_We...Assessment_of_Fetal_and_Maternal_Well-Being_During_Pregnancy_Using_Passive_We...
Assessment_of_Fetal_and_Maternal_Well-Being_During_Pregnancy_Using_Passive_We...
 
台北科技大學電子所_可穿戴式系統設計_期末報告 1_賴紀廷_109368501_20230106_2.pptx
台北科技大學電子所_可穿戴式系統設計_期末報告 1_賴紀廷_109368501_20230106_2.pptx台北科技大學電子所_可穿戴式系統設計_期末報告 1_賴紀廷_109368501_20230106_2.pptx
台北科技大學電子所_可穿戴式系統設計_期末報告 1_賴紀廷_109368501_20230106_2.pptx
 
台北科技大學電子所_可穿戴式系統設計_期末報告 1_賴紀廷_109368501_20230106_1.pptx
台北科技大學電子所_可穿戴式系統設計_期末報告 1_賴紀廷_109368501_20230106_1.pptx台北科技大學電子所_可穿戴式系統設計_期末報告 1_賴紀廷_109368501_20230106_1.pptx
台北科技大學電子所_可穿戴式系統設計_期末報告 1_賴紀廷_109368501_20230106_1.pptx
 
RFIC_LNA_Simulation.ppt
RFIC_LNA_Simulation.pptRFIC_LNA_Simulation.ppt
RFIC_LNA_Simulation.ppt
 
AIML4 CNN lab256 1hr (111-1).pdf
AIML4 CNN lab256 1hr (111-1).pdfAIML4 CNN lab256 1hr (111-1).pdf
AIML4 CNN lab256 1hr (111-1).pdf
 
AIML4 CNN lab 5-1 BreastCancer ML course student report 2022 spring (111-1).pdf
AIML4 CNN lab 5-1 BreastCancer ML course student report 2022 spring (111-1).pdfAIML4 CNN lab 5-1 BreastCancer ML course student report 2022 spring (111-1).pdf
AIML4 CNN lab 5-1 BreastCancer ML course student report 2022 spring (111-1).pdf
 
virtuoso
virtuosovirtuoso
virtuoso
 
Lecture 1 System View.pptx - 已修復.pdf
Lecture 1 System View.pptx  -  已修復.pdfLecture 1 System View.pptx  -  已修復.pdf
Lecture 1 System View.pptx - 已修復.pdf
 
Training L1 Thinking 2022702.pptx.pptx
Training L1 Thinking 2022702.pptx.pptxTraining L1 Thinking 2022702.pptx.pptx
Training L1 Thinking 2022702.pptx.pptx
 
Lecture08-Arithmetic Code-4-Int Imp-P2.pdf
Lecture08-Arithmetic Code-4-Int Imp-P2.pdfLecture08-Arithmetic Code-4-Int Imp-P2.pdf
Lecture08-Arithmetic Code-4-Int Imp-P2.pdf
 
Lecture09-SQ-P2.pdf
Lecture09-SQ-P2.pdfLecture09-SQ-P2.pdf
Lecture09-SQ-P2.pdf
 
Lecture06-Arithmetic Code-2-Algorithm Implementation-P2.pdf
Lecture06-Arithmetic Code-2-Algorithm Implementation-P2.pdfLecture06-Arithmetic Code-2-Algorithm Implementation-P2.pdf
Lecture06-Arithmetic Code-2-Algorithm Implementation-P2.pdf
 
Lecture01-Modeling and Coding-P2.pdf
Lecture01-Modeling and Coding-P2.pdfLecture01-Modeling and Coding-P2.pdf
Lecture01-Modeling and Coding-P2.pdf
 

Dernier

Call Girls In Doddaballapur Road ☎ 7737669865 🥵 Book Your One night Stand
Call Girls In Doddaballapur Road ☎ 7737669865 🥵 Book Your One night StandCall Girls In Doddaballapur Road ☎ 7737669865 🥵 Book Your One night Stand
Call Girls In Doddaballapur Road ☎ 7737669865 🥵 Book Your One night Stand
amitlee9823
 
Call Girls In Shivaji Nagar ☎ 7737669865 🥵 Book Your One night Stand
Call Girls In Shivaji Nagar ☎ 7737669865 🥵 Book Your One night StandCall Girls In Shivaji Nagar ☎ 7737669865 🥵 Book Your One night Stand
Call Girls In Shivaji Nagar ☎ 7737669865 🥵 Book Your One night Stand
amitlee9823
 
Just Call Vip call girls kakinada Escorts ☎️9352988975 Two shot with one girl...
Just Call Vip call girls kakinada Escorts ☎️9352988975 Two shot with one girl...Just Call Vip call girls kakinada Escorts ☎️9352988975 Two shot with one girl...
Just Call Vip call girls kakinada Escorts ☎️9352988975 Two shot with one girl...
gajnagarg
 
CHEAP Call Girls in Rabindra Nagar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
CHEAP Call Girls in Rabindra Nagar  (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICECHEAP Call Girls in Rabindra Nagar  (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
CHEAP Call Girls in Rabindra Nagar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
9953056974 Low Rate Call Girls In Saket, Delhi NCR
 
➥🔝 7737669865 🔝▻ malwa Call-girls in Women Seeking Men 🔝malwa🔝 Escorts Ser...
➥🔝 7737669865 🔝▻ malwa Call-girls in Women Seeking Men  🔝malwa🔝   Escorts Ser...➥🔝 7737669865 🔝▻ malwa Call-girls in Women Seeking Men  🔝malwa🔝   Escorts Ser...
➥🔝 7737669865 🔝▻ malwa Call-girls in Women Seeking Men 🔝malwa🔝 Escorts Ser...
amitlee9823
 
➥🔝 7737669865 🔝▻ Bangalore Call-girls in Women Seeking Men 🔝Bangalore🔝 Esc...
➥🔝 7737669865 🔝▻ Bangalore Call-girls in Women Seeking Men  🔝Bangalore🔝   Esc...➥🔝 7737669865 🔝▻ Bangalore Call-girls in Women Seeking Men  🔝Bangalore🔝   Esc...
➥🔝 7737669865 🔝▻ Bangalore Call-girls in Women Seeking Men 🔝Bangalore🔝 Esc...
amitlee9823
 
Call Girls Hsr Layout Just Call 👗 7737669865 👗 Top Class Call Girl Service Ba...
Call Girls Hsr Layout Just Call 👗 7737669865 👗 Top Class Call Girl Service Ba...Call Girls Hsr Layout Just Call 👗 7737669865 👗 Top Class Call Girl Service Ba...
Call Girls Hsr Layout Just Call 👗 7737669865 👗 Top Class Call Girl Service Ba...
amitlee9823
 
Vip Mumbai Call Girls Thane West Call On 9920725232 With Body to body massage...
Vip Mumbai Call Girls Thane West Call On 9920725232 With Body to body massage...Vip Mumbai Call Girls Thane West Call On 9920725232 With Body to body massage...
Vip Mumbai Call Girls Thane West Call On 9920725232 With Body to body massage...
amitlee9823
 
➥🔝 7737669865 🔝▻ Ongole Call-girls in Women Seeking Men 🔝Ongole🔝 Escorts S...
➥🔝 7737669865 🔝▻ Ongole Call-girls in Women Seeking Men  🔝Ongole🔝   Escorts S...➥🔝 7737669865 🔝▻ Ongole Call-girls in Women Seeking Men  🔝Ongole🔝   Escorts S...
➥🔝 7737669865 🔝▻ Ongole Call-girls in Women Seeking Men 🔝Ongole🔝 Escorts S...
amitlee9823
 
Just Call Vip call girls Erode Escorts ☎️9352988975 Two shot with one girl (E...
Just Call Vip call girls Erode Escorts ☎️9352988975 Two shot with one girl (E...Just Call Vip call girls Erode Escorts ☎️9352988975 Two shot with one girl (E...
Just Call Vip call girls Erode Escorts ☎️9352988975 Two shot with one girl (E...
gajnagarg
 
Call Girls Indiranagar Just Call 👗 7737669865 👗 Top Class Call Girl Service B...
Call Girls Indiranagar Just Call 👗 7737669865 👗 Top Class Call Girl Service B...Call Girls Indiranagar Just Call 👗 7737669865 👗 Top Class Call Girl Service B...
Call Girls Indiranagar Just Call 👗 7737669865 👗 Top Class Call Girl Service B...
amitlee9823
 
Call Girls Bannerghatta Road Just Call 👗 7737669865 👗 Top Class Call Girl Ser...
Call Girls Bannerghatta Road Just Call 👗 7737669865 👗 Top Class Call Girl Ser...Call Girls Bannerghatta Road Just Call 👗 7737669865 👗 Top Class Call Girl Ser...
Call Girls Bannerghatta Road Just Call 👗 7737669865 👗 Top Class Call Girl Ser...
amitlee9823
 
Call Girls In Bellandur ☎ 7737669865 🥵 Book Your One night Stand
Call Girls In Bellandur ☎ 7737669865 🥵 Book Your One night StandCall Girls In Bellandur ☎ 7737669865 🥵 Book Your One night Stand
Call Girls In Bellandur ☎ 7737669865 🥵 Book Your One night Stand
amitlee9823
 
Call Girls Bommasandra Just Call 👗 7737669865 👗 Top Class Call Girl Service B...
Call Girls Bommasandra Just Call 👗 7737669865 👗 Top Class Call Girl Service B...Call Girls Bommasandra Just Call 👗 7737669865 👗 Top Class Call Girl Service B...
Call Girls Bommasandra Just Call 👗 7737669865 👗 Top Class Call Girl Service B...
amitlee9823
 
Escorts Service Kumaraswamy Layout ☎ 7737669865☎ Book Your One night Stand (B...
Escorts Service Kumaraswamy Layout ☎ 7737669865☎ Book Your One night Stand (B...Escorts Service Kumaraswamy Layout ☎ 7737669865☎ Book Your One night Stand (B...
Escorts Service Kumaraswamy Layout ☎ 7737669865☎ Book Your One night Stand (B...
amitlee9823
 

Dernier (20)

Call Girls In Doddaballapur Road ☎ 7737669865 🥵 Book Your One night Stand
Call Girls In Doddaballapur Road ☎ 7737669865 🥵 Book Your One night StandCall Girls In Doddaballapur Road ☎ 7737669865 🥵 Book Your One night Stand
Call Girls In Doddaballapur Road ☎ 7737669865 🥵 Book Your One night Stand
 
Call Girls In Shivaji Nagar ☎ 7737669865 🥵 Book Your One night Stand
Call Girls In Shivaji Nagar ☎ 7737669865 🥵 Book Your One night StandCall Girls In Shivaji Nagar ☎ 7737669865 🥵 Book Your One night Stand
Call Girls In Shivaji Nagar ☎ 7737669865 🥵 Book Your One night Stand
 
Anomaly detection and data imputation within time series
Anomaly detection and data imputation within time seriesAnomaly detection and data imputation within time series
Anomaly detection and data imputation within time series
 
Just Call Vip call girls kakinada Escorts ☎️9352988975 Two shot with one girl...
Just Call Vip call girls kakinada Escorts ☎️9352988975 Two shot with one girl...Just Call Vip call girls kakinada Escorts ☎️9352988975 Two shot with one girl...
Just Call Vip call girls kakinada Escorts ☎️9352988975 Two shot with one girl...
 
CHEAP Call Girls in Rabindra Nagar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
CHEAP Call Girls in Rabindra Nagar  (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICECHEAP Call Girls in Rabindra Nagar  (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
CHEAP Call Girls in Rabindra Nagar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
 
➥🔝 7737669865 🔝▻ malwa Call-girls in Women Seeking Men 🔝malwa🔝 Escorts Ser...
➥🔝 7737669865 🔝▻ malwa Call-girls in Women Seeking Men  🔝malwa🔝   Escorts Ser...➥🔝 7737669865 🔝▻ malwa Call-girls in Women Seeking Men  🔝malwa🔝   Escorts Ser...
➥🔝 7737669865 🔝▻ malwa Call-girls in Women Seeking Men 🔝malwa🔝 Escorts Ser...
 
➥🔝 7737669865 🔝▻ Bangalore Call-girls in Women Seeking Men 🔝Bangalore🔝 Esc...
➥🔝 7737669865 🔝▻ Bangalore Call-girls in Women Seeking Men  🔝Bangalore🔝   Esc...➥🔝 7737669865 🔝▻ Bangalore Call-girls in Women Seeking Men  🔝Bangalore🔝   Esc...
➥🔝 7737669865 🔝▻ Bangalore Call-girls in Women Seeking Men 🔝Bangalore🔝 Esc...
 
Call Girls Hsr Layout Just Call 👗 7737669865 👗 Top Class Call Girl Service Ba...
Call Girls Hsr Layout Just Call 👗 7737669865 👗 Top Class Call Girl Service Ba...Call Girls Hsr Layout Just Call 👗 7737669865 👗 Top Class Call Girl Service Ba...
Call Girls Hsr Layout Just Call 👗 7737669865 👗 Top Class Call Girl Service Ba...
 
Vip Mumbai Call Girls Thane West Call On 9920725232 With Body to body massage...
Vip Mumbai Call Girls Thane West Call On 9920725232 With Body to body massage...Vip Mumbai Call Girls Thane West Call On 9920725232 With Body to body massage...
Vip Mumbai Call Girls Thane West Call On 9920725232 With Body to body massage...
 
5CL-ADBA,5cladba, Chinese supplier, safety is guaranteed
5CL-ADBA,5cladba, Chinese supplier, safety is guaranteed5CL-ADBA,5cladba, Chinese supplier, safety is guaranteed
5CL-ADBA,5cladba, Chinese supplier, safety is guaranteed
 
➥🔝 7737669865 🔝▻ Ongole Call-girls in Women Seeking Men 🔝Ongole🔝 Escorts S...
➥🔝 7737669865 🔝▻ Ongole Call-girls in Women Seeking Men  🔝Ongole🔝   Escorts S...➥🔝 7737669865 🔝▻ Ongole Call-girls in Women Seeking Men  🔝Ongole🔝   Escorts S...
➥🔝 7737669865 🔝▻ Ongole Call-girls in Women Seeking Men 🔝Ongole🔝 Escorts S...
 
Just Call Vip call girls Erode Escorts ☎️9352988975 Two shot with one girl (E...
Just Call Vip call girls Erode Escorts ☎️9352988975 Two shot with one girl (E...Just Call Vip call girls Erode Escorts ☎️9352988975 Two shot with one girl (E...
Just Call Vip call girls Erode Escorts ☎️9352988975 Two shot with one girl (E...
 
Call Girls Indiranagar Just Call 👗 7737669865 👗 Top Class Call Girl Service B...
Call Girls Indiranagar Just Call 👗 7737669865 👗 Top Class Call Girl Service B...Call Girls Indiranagar Just Call 👗 7737669865 👗 Top Class Call Girl Service B...
Call Girls Indiranagar Just Call 👗 7737669865 👗 Top Class Call Girl Service B...
 
Call Girls Bannerghatta Road Just Call 👗 7737669865 👗 Top Class Call Girl Ser...
Call Girls Bannerghatta Road Just Call 👗 7737669865 👗 Top Class Call Girl Ser...Call Girls Bannerghatta Road Just Call 👗 7737669865 👗 Top Class Call Girl Ser...
Call Girls Bannerghatta Road Just Call 👗 7737669865 👗 Top Class Call Girl Ser...
 
Aspirational Block Program Block Syaldey District - Almora
Aspirational Block Program Block Syaldey District - AlmoraAspirational Block Program Block Syaldey District - Almora
Aspirational Block Program Block Syaldey District - Almora
 
Call Girls In Bellandur ☎ 7737669865 🥵 Book Your One night Stand
Call Girls In Bellandur ☎ 7737669865 🥵 Book Your One night StandCall Girls In Bellandur ☎ 7737669865 🥵 Book Your One night Stand
Call Girls In Bellandur ☎ 7737669865 🥵 Book Your One night Stand
 
Call Girls Bommasandra Just Call 👗 7737669865 👗 Top Class Call Girl Service B...
Call Girls Bommasandra Just Call 👗 7737669865 👗 Top Class Call Girl Service B...Call Girls Bommasandra Just Call 👗 7737669865 👗 Top Class Call Girl Service B...
Call Girls Bommasandra Just Call 👗 7737669865 👗 Top Class Call Girl Service B...
 
Predicting Loan Approval: A Data Science Project
Predicting Loan Approval: A Data Science ProjectPredicting Loan Approval: A Data Science Project
Predicting Loan Approval: A Data Science Project
 
(NEHA) Call Girls Katra Call Now 8617697112 Katra Escorts 24x7
(NEHA) Call Girls Katra Call Now 8617697112 Katra Escorts 24x7(NEHA) Call Girls Katra Call Now 8617697112 Katra Escorts 24x7
(NEHA) Call Girls Katra Call Now 8617697112 Katra Escorts 24x7
 
Escorts Service Kumaraswamy Layout ☎ 7737669865☎ Book Your One night Stand (B...
Escorts Service Kumaraswamy Layout ☎ 7737669865☎ Book Your One night Stand (B...Escorts Service Kumaraswamy Layout ☎ 7737669865☎ Book Your One night Stand (B...
Escorts Service Kumaraswamy Layout ☎ 7737669865☎ Book Your One night Stand (B...
 

Labs_20210809.pdf

  • 5. A bunch of softwares
  • 6. Use Ubuntu in NTUT Cloud • Console/ Terminal is the first step.
  • 8. Use Google Colab for python excise.
  • 11. Get Open Data Sources on the internet browser – Restful API • https://ci.taiwan.gov.tw/dsp/environmental.aspx • https://mis.twse.com.tw/stock/api/getStockInfo.jsp?ex_ch=tse_23 30.tw&json=1&delay=0 • https://api.dictionaryapi.dev/api/v2/entries/en/similar • https://sta.ci.taiwan.gov.tw/STA_AirQuality_v2/v1.0/Datastreams? $expand=Thing,Observations($orderby=phenomenonTime%20des c;$top=1)&$filter=name%20eq%20%27PM2.5%27%20and%20Thing/ properties/authority%20eq%20%27%E8%A1%8C%E6%94%BF%E9%99 %A2%E7%92%B0%E5%A2%83%E4%BF%9D%E8%AD%B7%E7%BD%B2% 27%20and%20substringof(%27%E7%A9%BA%E6%B0%A3%E5%93%81 %E8%B3%AA%E6%B8%AC%E7%AB%99%27,Thing/name)&$count=tr ue
  • 13. Get Open Data Sources on Advanced Rest Client • Advanced Rest Client run on chrome • https://chrome.google.com/webstore/detail/ad vanced-rest- client/hgmloofddffdnphfgcellkdfbfbjeloo?page= 1&hl=zh-tw&itemlang=sv
  • 14. Online Restful Client • https://restninja.io/
  • 15. Basic knowledge of CLI(commandline) • Install needed packages whenever login in the google colab • apt-get install jq • cd : Change directory • pwd : Show the current directory • cd .. : Leave the current directory • cd [Directory name] : Enter the [Directory name] • wget [URL] : Download the file from the URL • curl [URL] : Powerfully download the anything from the URL
  • 16. Basic knowledge of google colab CLI(commandline) • Install needed packages whenever login in the google colab • !apt-get install jq • % : Use % if the command needs to be run on the specific notebook • ! : Use ! if the command is run in a separate shell. • %cd : Change directory • !pwd : Show the current directory • !cd .. : Leave the current directory • !cd [Directory name] : Enter the [Directory name] • !wget [URL] : Download the file from the URL • !curl [URL] : Powerfully download the anything from the URL
  • 17. Retrieve Open data on Linux CLI • curl -s 'https://mis.twse.com.tw/stock/api/getStockInfo.jsp?ex_ch=tse_23 30.tw&json=1&delay=0' | jq '.["msgArray"][0]["h"] ' • curl -s 'https://api.dictionaryapi.dev/api/v2/entries/en/similar' • curl -s 'https://sta.ci.taiwan.gov.tw/STA_AirQuality_v2/v1.0/Datastreams? $expand=Thing,Observations($orderby=phenomenonTime%20des c;$top=1)&$filter=name%20eq%20%27PM2.5%27%20and%20Thing/ properties/authority%20eq%20%27%E8%A1%8C%E6%94%BF%E9%99 %A2%E7%92%B0%E5%A2%83%E4%BF%9D%E8%AD%B7%E7%BD%B2% 27%20and%20substringof(%27%E7%A9%BA%E6%B0%A3%E5%93%81 %E8%B3%AA%E6%B8%AC%E7%AB%99%27,Thing/name)&$count=tr ue' | jq '.["value"][0]["Observations"][0]["result"] '
  • 18. API Key • Proprietary Restful API needs to register a API Key • https://newsapi.org/ • Registered Newsapi API Key • 1ac7db45547b4a6d928a6dedb7296d4e • Get data from any browser : • https://newsapi.org/v2/top- headlines?country=us&apiKey=1ac7db45547b4a6d92 8a6dedb7296d4e • Get data from Colab CLI: • !curl -s 'https://newsapi.org/v2/top- headlines?country=us&apiKey=1ac7db45547b4a6d92 8a6dedb7296d4e' | jq '.["articles"][]["content"]?'
  • 19. Find the whole headlines with Trump in all media • Step 1 : Read the available news contents in the NewsApi • curl ‐s 'https://newsapi.org/v2/top‐ headlines?country=us&apiKey=1ac7db45547b4a6d928a6dedb7296d4e' • Step 2 : List every article of the whole media from the above JSON data • jq '.["articles"][]["content"]?' • Step 3 : Filter out the articles relevant to “Trump” • grep -i 'Trump' • Process in batch • curl ‐s 'https://newsapi.org/v2/top‐ headlines?country=us&apiKey=1ac7db45547b4a6d928a6dedb7296 d4e' | jq '.["articles"][]["content"]?' | grep ‐i 'Trump'
  • 20. Alternative google cloud for CLI • https://shell.cloud.google.com/
  • 21. Google cloud shell or jupyter-lab • https://shell.cloud.google.com/ • Jupyter-lab run on the conda • run -i “script.py”
  • 22. Control modeling with python • https://www.youtube.com/watch?v=fI9Q_haTnVI
  • 24. Regular Expression • What is regular expression? • An expression of a pattern in a string using special characters and words. • When and where we use it? • Regular expression is used to parse an output from a software , for example, BLAST, or used to extract information you need from a text file. When a string | line matches the pattern, it is extracted. Therefore, it is extremely useful. [Ref]:https://www.slideshare.net/vtriqn/regular-expressions-grep-and-egrep
  • 25. Download the materials • Move to AIEMBA directory • Move to user’s home directory $ cd ~ • Create the AIEMBA directory $ mkdir AIEMBA • Download the materials $ wget "https://drive.google.com/uc?export=download&id=1Rq3 h3rdRYLoEJsAei_0H7VnXI0XjfYI-" -O AIEMBA_20201111.zip • Extract the zip file • unzip AIEMBA_20201111.zip
  • 26. What Is a Regular Expression? • A regular expression (regex) describes a set of possible input strings. • Regular expressions descend from a fundamental concept in Computer Science called finite automata theory • Regular expressions are endemic to Unix – vi, ed, sed, and emacs – awk, tcl, perl and Python – grep, egrep, fgrep – compilers [Ref]:https://www.slideshare.net/vtriqn/regular-expressions-grep-and-egrep
  • 27. Regular Expressions • The simplest regular expressions are a string of literal characters to match. • The string matches the regular expression if it contains the substring. [Ref]:https://www.slideshare.net/vtriqn/regular-expressions-grep-and-egrep
  • 28. grep Family • Syntax grep [-ilnv] [-e expression] [filename] egrep [-ilnv] [-e expression] [-f filename] [expression] [filename] – -i Ignore case – -l List only filenames containing matching lines – -n Precede each matching line with its line number – -v Negate matches – -e expression – -f filename Specify expression as option Take the regular expression (egrep) or a list of strings (fgrep) from filename [Ref]:https://www.slideshare.net/vtriqn/regular-expressions-grep-and-egrep
  • 29. Test document "Open Source" is a good mechanism to develop programs. apple is my favorite food. Football game is not use feet only. this dress doesn't fit me. However, this dress is about $ 3183 dollars. GNU is free air not free beer. Her hair is very beauty. I can’t finish the test. Oh! The soup taste good. motorcycle is cheap than car. This window is clear. the symbol '*' is represented as start. Oh! My god! The gd software is a library for drafting programs. You are the best is mean you are the no. 1. The world is the same with "glad". I like dog. google is the best tools for search keyword. goooooogle yes! go! go! Let's go. # I am VBird CLI $ grep 'good' regular_express.txt Print out the line with “good” in the regular_express.txt
  • 30. UNIX Tools rocks. match UNIX Tools sucks. match UNIX Tools is ock. no match regular expression c k s [Ref]:https://www.slideshare.net/vtriqn/regular-expressions-grep-and-egrep
  • 31. Keyword matching Ex : Find the lines with 'the' in the file CLI $ grep ‐n 'the' regular_express.txt 8:I can't finish the test. 12:the symbol '*' is represented as start. 15:You are the best is mean you are the no. 1. 16:The world is the same with "glad". 18:google is the best tools for search keyword.
  • 32. Case insensitive Ex : Find the lines with case insensitive ‘the’ in the file CLI $ grep ‐in 'the' regular_express.txt 8:I can't finish the test. 9:Oh! The soup taste good. 12:the symbol '*' is represented as start. 14:The gd software is a library for drafting programs. 15:You are the best is mean you are the no. 1. 16:The world is the same with "glad". 18:google is the best tools for search keyword.
  • 33. Regular Expressions • A regular expression can match a string in more than one place. Scrapple from the apple. match 1 match 2 regular expression a p p l e [Ref]:https://www.slideshare.net/vtriqn/regular-expressions-grep-and-egrep
  • 34. Character Classes • Character classes [] can be used to match any specific set of characters. beat a brat on a boat match 1 match 2 regular expression b [eor] a t match 3 [Ref]:https://www.slideshare.net/vtriqn/regular-expressions-grep-and-egrep
  • 35. Character Classes • Ex: • t[ae]st == tast OR test ≠ taest CLI $ grep ‐n ‘t[ae]st’ regular_express.txt 8:I can't finish the test. 9:Oh! The soup taste good.
  • 36. Find the line with ‘oo’ • Ex: CLI $ grep ‐n 'oo' regular_express.txt 1:"Open Source" is a good mechanism to develop programs. 2:apple is my favorite food. 3:Football game is not use feet only. 9:Oh! The soup taste good. 18:google is the best tools for search keyword. 19:goooooogle yes!
  • 37. Negated Character Classes • Character classes can be negated with the [^] syntax. beat a brat on a boat match regular expression b [^eo] a t [Ref]:https://www.slideshare.net/vtriqn/regular-expressions-grep-and-egrep
  • 38. Negative lookahead •Find the lines without g in front of oo. •不想要 oo 前面有 g • Ex: CLI $ grep ‐n '[^g]oo' regular_express.txt 2:apple is my favorite food. 3:Football game is not use feet only. 18:google is the best tools for search keyword. 19:goooooogle
  • 39. More About Character Classes – [aeiou] will match any of the characters a, e, i, o, or u – [kK]orn will match korn or Korn • Ranges can also be specified in character classes – [1-9] is the same as [123456789] – [abcde] is equivalent to [a-e] – You can also combine multiple ranges • [abcde123456789] is equivalent to [a-e1-9] – Note that the - character has a special meaning in a character class but only if it is used within a range, [-123] would match the characters -, 1, 2, or 3 [Ref]:https://www.slideshare.net/vtriqn/regular-expressions-grep-and-egrep
  • 40. Named Character Classes • Commonly used character classes can be referred to by name (alpha, lower, upper, alnum, digit, punct, cntrl) • Syntax [:name:] – [a-zA-Z] – [a-zA-Z0-9] – [45a-z] [[:alpha:]] [[:alnum:]] [45[:lower:]] • Important for portability across languages [Ref]:https://www.slideshare.net/vtriqn/regular-expressions-grep-and-egrep
  • 41. Find a span •The digits inside the brackets can be any numbers or span of numbers from 0 to 9. • Ex: CLI $ grep ‐n '[0‐9]' regular_express.txt 5:However, this dress is about $ 3183 dollars. 15:You are the best is mean you are the no. 1.
  • 42. Negative matching •Find the ASCII characters which is not in the range from a to z • Ex: CLI $ grep ‐n '[^a‐z]oo' regular_express.txt 3:Football game is not use feet only.
  • 43. Anchors • Anchors are used to match at the beginning or end of a line (or both). • ^ means beginning of the line • $ means end of the line [Ref]:https://www.slideshare.net/vtriqn/regular-expressions-grep-and-egrep • Ex: CLI $ grep ‐n '^the' regular_express.txt 12:the symbol '*' is represented as start.
  • 44. beat a brat on a boat regular expression ^ b [eor] a t match regular expression b [eor] a t $ beat a brat on a boat match ^$ ^word$ [Ref]:https://www.slideshare.net/vtriqn/regular-expressions-grep-and-egrep
  • 45. Define the beginning • Ex: •Find the lowercase characters which exists in the beginning of the line CLI $ grep ‐n '^[a‐z]' regular_express.txt 2:apple is my favorite food. 4:this dress doesn't fit me. 10:motorcycle is cheap than car. 12:the symbol '*' is represented as start. 18:google is the best tools for search keyword. 19:goooooogle yes!
  • 46. Complex regex pattern CLI $ grep ‐n '^[^a‐zA‐Z]' regular_express.txt 1:"Open Source" is a good mechanism to develop programs. 20:# I am VBird
  • 47. Match the special characters • ! $ % ^ & * ( ) _ + | ~ - = ` { } [ ] : “ ; ‘ < > ? , . / • Slash symbol ‘’ can escape the function of the special characters CLI $ grep ‐n '.$' regular_express.txt 1:"Open Source" is a good mechanism to develop programs. 2:apple is my favorite food. 3:Football game is not use feet only. 4:this dress doesn't fit me. 10:motorcycle is cheap than car. 11:This window is clear. 12:the symbol '*' is represented as start. 15:You are the best is mean you are the no. 1. 16:The world is the same with "glad". 17:I like dog. 18:google is the best tools for search keyword.
  • 48. Regular Expressions • The . regular expression can be used to match any character. For me to poop on. match 1 match 2 regular expression o . [Ref]:https://www.slideshare.net/vtriqn/regular-expressions-grep-and-egrep
  • 49. Repetition • The * is used to define zero or more occurrences of the single regular expression preceding it. [Ref]:https://www.slideshare.net/vtriqn/regular-expressions-grep-and-egrep
  • 50. I got mail, yay! match regular expression y a * y For me to poop on. regular expression o a * o match .* [Ref]:https://www.slideshare.net/vtriqn/regular-expressions-grep-and-egrep
  • 51. Match length Scrapple from the apple. no yes regular expression a . * e • A match will be the longest string that satisfies the regular expression. no [Ref]:https://www.slideshare.net/vtriqn/regular-expressions-grep-and-egrep
  • 52. Repetition Ranges • Ranges can also be specified – { } notation can specify a range of repetitions for the immediately preceding regex – {n} means exactly n occurrences – {n,} means at least n occurrences – {n,m} means at least n occurrences but no more than m occurrences • Example: – .{0,} same as .* – a{2,} same as aaa* [Ref]:https://www.slideshare.net/vtriqn/regular-expressions-grep-and-egrep
  • 53. Colab grex {} bug [Ref]:https://www.slideshare.net/vtriqn/regular-expressions-grep-and-egrep CLI in Colab: !grep ‐Eio '[a‐z]{{2,}}' regular_express.txt • {} should be repeated as {{ }} • Ranges can also be specified – {{}}notation can specify a range of repetitions for the immediately preceding regex – {{n}}means exactly n occurrences – {{n,}}means at least n occurrences – {{n,m}}means at least n occurrences but no more than m occurrences CLI $ grep ‐Eio '[a‐z]{2,}' regular_express.txt
  • 54. Subexpressions • If you want to group part of an expression so that * or { } applies to more than just the previous character, use ( ) notation • Subexpresssions are treated like a single character – a* matches 0 or more occurrences of a – abc* matches ab, abc, abcc, abccc, … – (abc)* matches abc, abcabc, abcabcabc, … – (abc){2,3} matches abcabc or abcabcabc [Ref]:https://www.slideshare.net/vtriqn/regular-expressions-grep-and-egrep
  • 55. 找出 g 後面接 2 到 5 個 o [root@test root]# grep -n 'go{2,5}g' regular_express.txt 18:google is the best tools for search keyword.
  • 56. .* 是什麼 [root@test root]# grep -n 'g.*g' regular_express.txt 1:"Open Source" is a good mechanism to develop programs. 14:The gd software is a library for drafting programs. 18:google is the best tools for search keyword. 19:goooooogle yes!
  • 57. Escaping Special Characters • Even though we are single quoting our regexs so the shell won’t interpret the special characters, some characters are special to grep (eg * and .) • To get literal characters, we escape the character with a (backslash) • Suppose we want to search for the character sequence • a*b* • –Unless we do something special, this will match zero or more ‘a’s followed by zero or more ‘b’s, not what we want • – a*b* will fix this - now the asterisks are treated as regular characters [Ref]:https://www.slideshare.net/vtriqn/regular-expressions-grep-and-egrep
  • 58. Egrep: Alternation • Regex also provides an alternation character | for matching one or another subexpression – (T|Fl)an will match ‘Tan’ or ‘Flan’ – ^(From|Subject): will match the From and Subject lines of a typical email message • It matches a beginning of line followed by either the characters ‘From’ or ‘Subject’ followed by a ‘:’ • Subexpressions are used to limit the scope of the alternation – At(ten|nine)tion then matches “Attention” or “Atninetion”, not “Atten” or “ninetion” as would happen without the parenthesis - Atten|ninetion [Ref]:https://www.slideshare.net/vtriqn/regular-expressions-grep-and-egrep
  • 59. | 字元 • 用或( or )的方式找出數個字串 • 範例:egrep -n 'gd|good' regular_express.txt 搜尋 gd 或 good 這兩個字串,注意,是『或』! 所以, 第 1,9,14 這三行都可以被列印出來喔!那如果還想要找出 dog 呢?就這樣 CLI $ egrep ‐n 'gd|good|dog' regular_express.txt
  • 60. () 字元 • 找出『群組』字串 • 搜尋 (glad) 或 (good) 這兩個字串,因為 g 與 d 是重複 的,所以, 我就可以將 la 與 oo 列於 ( ) 當中,並以 | 來 分隔開來,就可以啦! 此外,這個功能還可以用來作為『多個重複群組』的判別 喔!舉例來說: echo 'AxyzxyzxyzxyzC' | egrep 'A(xyz)+C' 上面的例子當中,意思是說,我要找開頭是 A 結尾是 C , 中間有一個以上的 "xyz" 字串的意思~ CLI $ egrep ‐n 'g(la|oo)d' regular_express.txt
  • 61. Egrep: Repetition Shorthands • The * (star) has already been seen to specify zero or more occurrences of the immediately preceding character • + (plus) means “one or more”  abc+d will match ‘abcd’, ‘abccd’, or ‘abccccccd’ but will not match ‘abd’  Equivalent to {1,} [Ref]:https://www.slideshare.net/vtriqn/regular-expressions-grep-and-egrep
  • 62. + 字元 • 重複『一個或一個以上』的前一個 RE 字符 • 搜尋 (god) (good) (goood)... 等等的字串。 那個 o+ 代表『一個 以上的 o 』所以,上面的執行成果會將第 1, 9, 13 行列出來。 CLI $ egrep ‐n 'go+d' regular_express.txt
  • 63. Egrep: Repetition Shorthands cont • The ‘?’ (question mark) specifies an optional character, the single character that immediately precedes it  July? will match ‘Jul’ or ‘July’   Equivalent to {0,1} Also equivalent to (Jul|July) • • The *, ?, and + are known as quantifiers because they specify the quantity of a match Quantifiers can also be used with subexpressions – (a*c)+ will match ‘c’, ‘ac’, ‘aac’ or ‘aacaacac’ but will not match ‘a’ or a blank line [Ref]:https://www.slideshare.net/vtriqn/regular-expressions-grep-and-egrep
  • 65. Logic calculator • https://www.umsu.de/trees/ • http://eval-b.stups.uni-duesseldorf.de/index.html • https://www.erpelstolz.at/gateway/formular-uk-zentral.html
  • 66. SWI-Prolog • SWI-Prolog is a good, standard Prolog for Windows and Linux • Can be installed on Macintosh with a little more effort (requires X11 and Mac developer tools) • It's licensed under GPL, therefore free • Downloadable from: http://www.swi‐prolog.org/ 66
  • 67. Syllogisms • “Prolog” is all about programming in logic. • Aristotle described syllogisms 2300 years ago • Sample syllogism: • Socrates is a man. • All men are mortal. • Therefore, Socrates is mortal. • Syllogisms are a form of logic. Can Prolog do them? • Note: If a word or term is in red, you should learn and remember its meaning 67
  • 68. Forward and backward reasoning • A syllogism gives two premises and a conclusion • Forward reasoning: Given some premises, ask “What can we conclude?” • Forward reasoning is inefficient when you are trying to get a particular conclusion • Backward reasoning: Given some premises and a conjectured conclusion, try to derive the conclusion from the premises • You start from the conclusion and try to work backward to prove it • You use Prolog by asking it specific questions • This is backward reasoning -- from (potential) conclusions to facts 68
  • 69. Syllogisms in Prolog 69 Syllogism Socrates is a man. All men are mortal. Is Socrates mortal? man(socrates). mortal(X) :‐ man(X). ?‐ mortal(socrates). Prolog
  • 70. Facts, rules, and queries • Fact: Socrates is a man. • man(socrates). • Rule: All men are mortal. • mortal(X) :‐ man(X). • Query: Is Socrates mortal? • mortal(socrates). • Queries have the same form as facts 70
  • 71. Variables and atoms • Variables begin with a capital letter: X, Socrates, _result • A variable can have a value • An atom is a value; it just stands for itself • Atoms do not begin with a capital letter: x, socrates 71
  • 72. Running Prolog I • Create your “database” (program) in any editor • Save it as text only, with a .pl extension • If you have Perl installed, you may have to use the .pro extension instead • Google swi prolog file extension for instructions • Here's the complete program: 72 man(socrates). mortal(X) :‐ man(X).
  • 73. Running Prolog II • SWI-Prolog is interpreted and completely interactive • You may be able to run your program by double- clicking your .pl file • Here are two ways you can run the interpreter: • Double-click on the swipl file, or • If your PATH is set correctly, enter swipl at the command line • At the ?‐ prompt in the interpreter, enter: • ?‐ consult('Complete path to your .pl file'). • Then, ask your question at the prompt: • ?‐ mortal(socrates). • Prolog responds: • true. 73
  • 74. Prolog is a theorem prover • Prolog’s true. means “I can prove it” • Prolog’s false. really means “I can’t prove it” • It does not mean “I can prove it is untrue.” • ?‐ mortal(plato). false. • This is the closed world assumption: the Prolog program knows everything it needs to know • Prolog supplies values for variables when it can • ?‐ mortal(X). X = socrates 74
  • 75. Structures • A structure consists of a name and zero or more arguments. • Omit the parentheses if there are no arguments • Example structures: • sunshine • man(socrates) • path(garden, south, sundial) 75
  • 76. Base Clauses • A base clause is just a structure, terminated with a period. • A base clause represents a simple fact. • Example base clauses: • debug_on. • loves(john, mary). • loves(mary, bill). 76
  • 77. Nonbase Clauses • A nonbase clause is a structure, a turnstile :- (meaning “if”), and a list of structures. • Example nonbase clauses: • mortal(X) :‐ man(X). • mortal(X) :‐ woman(X). • happy(X) :‐ healthy(X), wealthy(X), wise(X). • The comma between structures means “and” • “X is happy if X is healthy, wealthy, and wise.” 77
  • 78. Predicates • A predicate is a collection of clauses with the same functor (name) and arity (number of arguments). • loves(john, mary). loves(mary, bill). loves(chuck, X) :‐ female(X), rich(X). • The scope of a variable (such as X) is the single clause in which it occurs. 78
  • 79. Programs • In Prolog, a program is just a collection of predicates. • Predicates can be in any order. • Clauses within a predicate are used in the order in which they occur. 79
  • 80. Atoms • You can make an atom containing any characters at all by enclosing it in single quotes: • 'C:My Documentsexamples.pl' • If you use double quotes, you will get a list of ASCII values • ?‐ X = "Hello". X = [72, 101, 108, 108, 111]. • You probably don’t want this! • In a quoted atom, a single quote must be doubled or backslashed: • 'Can''t, or won't?' • Backslashes in file names must also be doubled: • 'C:My Documentsexamples.pl' • Better yet, use forward slashes in paths; every OS, including Windows, understands this 80
  • 81. Common problems • Capitalization is meaningful! • No space is allowed between a functor and its argument list: man(socrates), not man (socrates). • Double quotes indicate a list of ASCII character values, not a string • Don’t forget the period! (But if you do, you can put it on the next line.) 81
  • 82. Backtracking • loves(chuck, X) :‐ female(X), rich(X). • female(jane). • female(mary). • rich(mary). • ---------- Suppose we ask: loves(chuck, X). • female(X) = female(jane), X = jane. • rich(jane) fails. • female(X) = female(mary), X = mary. • rich(mary) succeeds. 82
  • 83. Backtracking and Beads • Each Prolog call is like a “bead” in a string of beads: • Each structure has four ports: call, exit, redo, fail • Exit ports connect to call ports; fail ports connect to redo ports 83 call fail exit redo
  • 84. Calls as nested beads 84 loves(chuck, X) :‐ female(X), rich(X). loves(chuck, X) female(X) rich(X) call fail exit redo
  • 85. Additional answers • female(jane). female(mary). female(susan). • ?‐ female(X). • X = jane ; • X = mary • Yes 85 female(jane) female(mary) female(susan) female(X)
  • 86. Readings • A clause can be read declaratively (as a statement of fact) or procedurally (as a list of things to try to do) • loves(chuck, X) :‐ female(X), rich(X). • Declarative reading: Chuck loves X if X is female and rich. • Approximate procedural reading: To find an X that Chuck loves: • First try to find a female X (fail and backtrack if you can’t) • Given a particular value for X, try to show that X is rich (fail and backtrack if you can’t) • Declarative readings are almost always preferred. 86
  • 88. Traditional Web Service • LAMP • Linux + Apache + MySQL + PHP
  • 89. Data to Intelligence • IOT • Open source • Proprietary data
  • 90. Lots of solution available Data Source Data Collectio n/Ingesti on Stream Data Processing Data Storage Data Presentatio n /Analysis Communicati on Protocol Communication Data format: JSON, CSV, BSON, YAML, XML
  • 93. Netflix at Spark+AI Summit 2018 • https://netflixtechblog.com/netflix-at-spark-ai-summit-2018- 5304749ed7fa
  • 95. System Considerations • Client/server configuration: • Real-time: 即時消費、即時新聞 • Data structure • Data Volume • Speed
  • 97. Where is the insight? • https://www.jos.com/big-data-for-real
  • 98. Human intelligence & AI IOT Big data Artificial Intelligence Managemen t Philosophy 耳聰目明 百納海川/ 招兵買馬 化繁為簡 去蕪存精 趨吉避凶 臨機應變 琴瑟和鳴 Sensing/ Retrieve Ingestion /Collection Storage/ Analysis Optimization Creation/ Balancing
  • 103.
  • 104. Data base choice • elasticsearch 和 hbase 比較 https://www.zhihu.com/question/41109030
  • 105.
  • 107. Foundations of Computer Science • http://infolab.stanford.edu/~ullman/focs.html • Chapter 1 Computer Science: The Mechanization of Abstraction • Chapter 2 Iteration, Induction, and Recursion • Chapter 3 The Running Time of Programs • Chapter 4 Combinatorics and Probability • Chapter 5 The Tree Data Model • Chapter 6 The List Data Model • Chapter 7 The Set Data Model • Chapter 8 The Relational Data Model • Chapter 9 The Graph Data Model • Chapter 10 Patterns, Automata, and Regular Expressions • Chapter 11 Recursive Description of Patterns • Chapter 12 Propositional Logic • Chapter 13 Using Logic to Design Computer Components • Chapter 14 Predicate Logic
  • 108. Download the materials on 20201202.zip • Move to AIEMBA directory • Move to user’s home directory $ cd ~ • Download the materials $ wget "https://drive.google.com/uc?export=download&id=1izf2QN xLIH-gx95h7ecQNgtlNiakW7Xw" -O AIEMBA_20201202.zip • Extract the zip file • unzip AIEMBA_20201202.zip
  • 111. Tutorials in Github  [Book / github / Data /Beginner ]  https://github.com/jakevdp/PythonDataScienceHandbo ok  [github / Data /Beginner ]  https://github.com/Pierian-Data/Complete-Python-3- Bootcamp ► [ Book / github / Data / Math ] Data science from scratch ► [ Book / github / Finance ] Python for finance ► [Collections] https://iter01.com/158569.html
  • 112. Data science from scratch ► https://github.com/joelgrus/data-science-from-scratch 1. Introduction 2. A Crash Course in Python 3. Visualizing Data 4. Linear Algebra 5. Statistics 6. Probability 7. Hypothesis and Inference 8. Gradient Descent 9. Getting Data 10. Working With Data 11. Machine Learning 12. k-Nearest Neighbors 13. Naive Bayes 14. Simple Linear Regression 15. Multiple Regression 16. Logistic Regression 17. Decision Trees 18. Neural Networks 19. [Deep Learning] 20. Clustering 21. Natural Language Processing 22. Network Analysis 23. Recommender Systems 24. Databases and SQL 25. MapReduce
  • 113. 課程比重 Case 1 Introduction to python Python 速成 VVVVV Case 2 Visualizing Data 數據視覺化 VVV Case 3 Linear Algebra 線性代數 V Case 4 Statistics 統計學 V Case 5 Probability 機率 V Case 6 Hypothesis and Inference 假設與推論 V Case 7 Gradient Descent 梯度遞減 V Case 8 Getting Data 取得數據資料 VVV Case 9 Working With Data 處理數據資料 VVV Case 10 Machine Learning 機器學習 VV Case 11 k-Nearest Neighbors k最近鄰 V Case 12 Naive Bayes 單純貝氏 V Case 13 Simple Linear Regression 簡單線性迴歸 VVV Case 14 Multiple Regression 多元迴歸 VVV Case 15 Logistic Regression 邏輯迴歸 VVV Case 16 Decision Trees 決策樹 VVV Case 17 Neural Networks 神經網路 V Case 18 [Deep Learning] 深度學習 V Case 19 Clustering 集群 Case 20 Natural Language Processing 自然語言處理 VV Case 21 Network Analysis 網路分析 V Case 22 Recommender Systems 推薦系統 V Case 23 Databases and SQL 資料庫與SQL VV Case 24 MapReduce MapReduce Case study : Data science
  • 114. Knowledge System of Data Science • {Atom} Data type/set manipulation ; Data collection • {Relation/Propositions; Predicate Logic/Rule/Calculation } • Linear algebra [scikit-learn] [scipy-lectures] • Statistics [scipy] • Data processing ; [scipy] • Data transformation [scipy] • FFT; DFT[scipy] • Image [scipy-lectures] • { Modal ; Probabilistic logic } • Data visualization • Probability • { Modeling } • Decision tree • PCA • linear • Clustering biclustering
  • 115. Python for finance ► https://github.com/yhilpisch/py4fi2nd 1. Python And Finance 2. 1.0 WHY PYTHON FOR FINANCE 3. 2.0 PYTHON INFRASTRUCTURE 4. Mastering The Basics 5. 3.0 DATA TYPES AND STRUCTURES 6. 4.0 NUMERICAL COMPUTING WITH NUMPY 7. 5.0 DATA ANALYSIS WITH PANDAS 8. 6.0 OBJECT-ORIENTED PROGRAMMING 9. Financial Data Science 10. 7.0 DATA VISUALIZATION 11. 8.0 FINANCIAL TIME SERIES 12. 9.0 INPUT/OUTPUT OPERATIONS 13. 10.0 PERFORMANCE PYTHON 14. 11.0 MATHEMATICAL TOOLS 15. 12.0 STOCHASTICS 16. 13.0 STATISTICS 17. Algorithmic Trading 18. 14.0 THE FXCM TRADING PLATFORM 19. 15.0 TRADING STRATEGIES 20. 16.0 AUTOMATED TRADING 21. Derivative Analytics 22. 17.0 VALUATION FRAMEWORK 23. 18.0 SIMULATION OF FINANCIAL MODELS 24. 19.0 DERIVATIVES VALUATION 25. 20.0 PORTFOLIO VALUATION 26. 21.0 MARKET-BASED VALUATION
  • 116. Materials ► numpy ► https://github.com/numpy/numpy ► https://numpy.org/learn/ ► Pandas ► https://github.com/pandas-dev/pandas/ ► Matplotlib ► https://github.com/matplotlib/matplotlib ► scipy ► https://scipy-cookbook.readthedocs.io/ ► https://github.com/scipy/scipy-cookbook/tree/master/ipython ► scikit learn ► https://scikit-learn.org/stable/auto_examples/index.html#model-selection ► Online manual: ► https://www.tutorialspoint.com/python/python_variable_types.htm
  • 117. Python for finance ► https://github.com/yhilpisch/py4fi2nd 1. 3.0 DATA TYPES AND STRUCTURES from decimal import Decimal a = 1.115 Decimal(a) # Decimal(a) 的值和想像中的不同 Decimal('1.1149999999999999911182158029987476766109466552734375') b = 1.125 Decimal(b) # Decimal(b) 的值則和想像中一樣 Decimal('1.125') from decimal import Decimal a = 1.115 Decimal(str(a)) # Decimal(a) 的值和想像中一樣了 Decimal('1.115') b = 1.125 Decimal(str(b) # Decimal(b) 的值則和想像中一樣 Decimal('1.125')
  • 118. Sympy for symbolic ► Jypyther is easy to show Latex ► Ipython latex rendering needs markdown ► https://nbviewer.jupyter.org/github/ipython/ipython/blob /2.x/examples/Notebook/Display%20System.ipynb#LaTeX ► https://blog.csdn.net/halazi100/article/details/79706172 ► Latex(r"[ lim_{x to 0} frac{3x^2 +7x^3}{x^2 +5x^4} = 3.]") ► online Latex editor ► https://www.codecogs.com/latex/eqneditor.php ► https://www.mathcha.io/editor
  • 119. Google Cloud Latex Rendering import sympy as sym from IPython.display import Latex x = sym.symbols('x') I = sym.integrate(1/(1+x**2), (x, 0, 1)) a = sym.latex(I) Latex(r'[begin{eqnarray*}' + a + r'end{eqnarray*}]') a = Integral(cos(x)*exp(x), x) s= Eq(a, a.doit()) a2 = sym.latex(s) Latex(r'[begin{eqnarray*}' + a2 + r'end{eqnarray*}]'
  • 120. Run conda on Google Cloud Console ► If interactive python fails, do the following steps: ► remove ./.local ► /usr/bin/python3 -m pip install -U jupyter --user --ignore- installed ► restart VS ► conda initiate ► source /home/hwchiu0810/miniconda3/bin/activate ► source /home/hwchiu0810/miniconda3/bin/deactivate ► Kernel Environment Selection for terminals and ipython
  • 121. Financial Materials ► 證交所即時資訊API ► https://zys-notes.blogspot.com/2020/01/api.html ► Python tools for finance ► https://blog.xuite.net/metafun/life/566073276- %E3%80%90%E8%BD%89%E3%80%91Best+Python+Libraries %2FPackages+for+Finance+and+Financial+Data+Scientis ts
  • 122. • Tensorflow • pytorch ML • scikitlearn Modeling • Math: sympy • Data :Scipy Computing • matplotlib Data Visualization • Numpy • Pandas Data Management • Python • Ipython/Jupyter • Anaconda/conda Data tools 數 學 Math 數 據 Data np / array / matrix df plt number / string / list / dict ML, Regression Solve Optimization Neural Network, CNN, RNN
  • 123. List of basic Data types
  • 124. List of basic Data types Unity Number string Combination Dict Index by key List Index by number
  • 126. Basic datatype of python and advanced datatype of numpy
  • 127. Collections Data / Sequences Data
  • 131.
  • 132.
  • 135.
  • 136.
  • 137.
  • 138.
  • 139. Gaming
  • 140. 人文科學 Vs 自然科學 人文科學 自然科學 最小單位 人 粒子 大單位 全球 宇宙 基本作用力 七情六欲 萬有引力、電磁力、強相互 作用、弱相互作用 基本量 比較值 絶對值 動能 最大舒適 最低能量 智能 有 弱 (演化/循環)
  • 141. 人文科學 Vs 自然科學 人文科學 自然科學 唯心論 唯物論 真相 真實、事實 動能 最大舒適 最低能量
  • 143. 邏輯與感覺 • Logic • Machine Learning • Fuzzy logic(模糊邏輯)
  • 144. Difficult decision and simple results • Who makes the decision? • Human or Data? • From very complicated to very simple: • 1 or 0 • True or false • Pass or Fail • Yes or no. • Do it or not to do it.
  • 147. Logic calculator • https://www.umsu.de/trees/ • http://eval-b.stups.uni-duesseldorf.de/index.html • https://www.erpelstolz.at/gateway/formular-uk-zentral.html
  • 152. Complete Example • https://github.com/wesm/pydata-book • https://github.com/yenlung/Python-3-Data-Analysis- Basics/blob/master/2019%E4%BA%BA%E5%B7%A5%E6%99%BA%E6%85%A7 %E5%AD%B8%E6%A0%A1%E9%86%AB%E7%99%82%E5%B0%88%E7%8F%AD/ %E6%A9%9F%E5%99%A8%E5%AD%B8%E7%BF%92%E5%85%A5%E9%96%80.ip ynb • https://nbviewer.jupyter.org/github/pydata/pydata-book/blob/2nd- edition/ch14.ipynb • https://github.com/amueller/introduction_to_ml_with_python • https://github.com/jakevdp/sklearn_scipy2013/tree/master/notebooks • https://scipy-lectures.org/packages/scikit-learn/index.html • https://scipy-lectures.org/
  • 153. Matlab Python Julia • https://cheatsheets.quantecon.org/
  • 154. Double Pendulum • https://www.myphysicslab.com/pendulum/double- pendulum-en.html • https://www.youtube.com/watch?v=hXOEoH5q3Hw • https://www.youtube.com/watch?v=dDU2JsgLpm4 • Chaotic pendulum
  • 155.
  • 157. Computational Statistics in Python from Duke • https://people.duke.edu/~ccc14/sta-663-2018/ • https://github.com/cliburn/sta-663- 2019/tree/master/notebook
  • 158. Statistical Data Modeling • https://www.statsmodels.org/stable/examples/notebooks/ge nerated/statespace_cycles.html
  • 159. Probability-Statistics in Python • https://github.com/unpingco/Python-for-Probability-Statistics- and-Machine-Learning/tree/master/ • https://github.com/unpingco/Python-for-Probability-Statistics- and-Machine-Learning-2E/tree/master/chapter