秋天好 | Autumn is good

Do you like fall?  We talked about autumn (qiū)(tiān) in this weekend’s Chinese lesson.

(qiū)(tiān)(dào)(qiū)(tiān)(hǎo)
(lán)(lán)(tiān)(kōng)白(bái)(yún)飘(piāo)
(bǎo)(bǎo)(tái)(tóu)(hā)(hā)(xiào)
magic math mandarin

Fall is here.  Fall is good.
Blue sky and white clouds.
The baby looks up and laughs.

Besides 中文, we are also working with other organizations to help children with computer programming 编程.

极客星晨少儿编程

Find if something is also somewhere else | 找一找那里是不是也有

In today’s class we played a game: finding the numbers in a group that are also in another group. As usual, we started simple using numpy (np).   Here is the summary:

score1 = np.array([0, 1, 3, 5, 10,3])

score2 = np.array([2,3])

We use the inld function from numpy to do the matching and counting:
np.in1d(score1,score2)

score1[np.in1d(score1,score2)]

Our result is:

array([3, 3])

There is another way to do this:

np.array([item in score2 for item in score1])

array([False, False,  True, False, False,  True])

score1[np.array([item in score2 for item in score1])]

will give you exactly the same answer.   Try it.

For very large groups of numbers or words, what we’ve just learned will work just as well.

Please practice and turn in the homework.

Count non-zeros using numpy.count_nonzero | 数非零数

Today our class practiced making the computer count number of non-zero numbers using the numpy library from Python.  This can be useful if you have a ton of numbers.

import numpy as np; import pandas as pd

some_array = np.array([[0,1,7,0,0],[3,0,0,2,19]])

array([[ 0,  1,  7,  0,  0],
[ 3,  0,  0,  2, 19]])

np.count_nonzero(some_array)

5

np.count_nonzero(some_array,  axis=0)  Count across the rows, i.e. count along the column

array([1, 1, 1, 1, 1], dtype=int64)

np.count_nonzero(some_array,  axis=1)  Count across the columns, i.e. count along the row

array([2, 3], dtype=int64)

We talked about this example:

d = {'Basket1': [3, 0], 'Basket2': [3, 4]}
df = pd.DataFrame(data=d, index=['Apple','Chips'])

# Count the number of non-zeros across the rows
pd.Series(np.count_nonzero(df, axis=0), index=df.columns.tolist())

This was the result we got.

Basket1    1
Basket2    2
dtype: int64

That was a very tiny data. If we have a dataset with a million rows and columns, we should definitely do this!

python numpy basics | 基础 python numpy 1

Tonight our class played together numpy basics and math.  We put together a numpy basics notebook:
https://nbviewer.jupyter.org/github/magicmathmandarin/PythonBasics/blob/master/numpy_basics1.ipynb#back-to-top

Programming by trial and error is a great way for kids to learn not only programming but also math. — this should play a bigger and bigger role in children’s day to day learning.  玩编程也帮助学习算术。

Somehow I have a feeling that learning long division in this day and age is wrong.  在这个时代还学长除法那就不对了。

Go ahead and tinker with the code in the notebook. Nothing will break, we promise 🙂

Chinese style education & empty basketball courts |中国式教育和空荡荡的蓝球场

I was in China this November to conduct surveys on education.  I had a few chances of sitting in some after school education programs and cram school classes, including XDF新东方, and was shocked by the amount of work Chinese kids have to do and was saddened by the way they are learning.

Let’s talk about the amount of work first.   I saw very few kids out and about any time of day except commuting hours.   Basketball courts are empty, even on weekends.   Where are all the kids?  They are in endless cram school 补习班 classes.

A middle school child routinely gets up before 7 am and does not go to sleep until midnight or after.   Middle school students stay in school until 8 pm, and work on additional homework from 8 pm till midnight.   Younger students are often working similar hours.
More

Do more for real intelligence | 为真人智慧加油

The word AI (artificial intelligence) is everywhere these days. Some of the best young minds are pouring into the field, and industry need is so dire that graduate schools can hardly keep PhD students until graduation.

In the craze of the artificial, real intelligence seems to have been forgotten. Here, the word “real intelligence” means intelligence from real human being.
American k-12 education continues to go downhill regardless of funding, more and more homeless people in New York City are begging in the streets (many are young and able), and millions of prime age citizens are not looking for work where many jobs are left unfilled.
More

小蛇 | Little snake

(cǎo)(zhōng)(yì)(gēn)(shéng)
(wān)(wān)(qū)(qū)(háng)
(hóu)(zi)(kàn)(jiàn)(máng)(duǒ)(kāi)
(qīng)(wā)(kàn)(jiàn)(máng)(táo)(mìng)

A snake can look like a rope.  Don’t get bitten by a snake!!!  It might be poisonous!!!!!!!

帆(fān)船(chuán) | Sailing Ship

(lán)(hǎi)(wān)(piāo)(fān)(chuán)
(fān)(chuán)(guà)(zhe)(bái)(chuán)(fān)
(fēng)(chuī)(chuán)(fān)(fān)(chuán)(zǒu)
(chuán)(fān)(dài)(zhe)(chuán)(xiàng)(qián)  

Be careful don’t fall into the water!!!!!!

小(xiǎo)蜻(qīng)蜓 (tíng) | Dragonfly

(xiǎo)(qīng)蜓 (tíng)大(dà)(yǎn)(jīng)
(liǎng)(duì)(chì)(bǎng)(dà)(yòu)(qīng)
(dà)(yǔ)(lái)(le)(fēi)(bú)(dòng)
(wá)(wá)(shàng)(xià)(tíng)(yì)(tíng)

If I were a dragonfly I would stay away from water because I might fall and die.

长(cháng)颈(jǐng)鹿(lù) | Giraffe

(cháng)(jǐng)鹿(lù)(zhēn)(piào)(liang)
(zhuān)(bǎ)(gāo)(chù)(nèn)(yè)(cháng)
(niǎo)(ér)(ài)(tā)(huā)(yī)(shang)
(sōng)(shǔ)(tàn)(tā)(bó)(zi)(cháng)