上午:Python程序设计
def guess():
while True:
a = int(input('猜数字'))
if a > 10:
print('小一点')
continue
elif a <= 9:
print('大一点')
continue
elif a == 10:
print('恭喜答对')
break
else:
print('再猜一次')
# f2c= 0 --> degree为华氏
def convert_C_F(degree, f2c = 0):
if f2c== 0:
f_degree = degree*(9/5) + 32
print(f'摄氏{degree}度 = 华氏{f_degree}度')
else:
c_degree = (degree-32)*9/5
print(f'华氏{degree}度 = 摄氏{c_degree}度' )
# 从任一个数的数列取出最大值
def find_max(*args):
print(max(args))
find_max(1,8,4,9)
# 任一数列求相邻数字的差、和、乘积、及每个数的平方
def caluate(*num):
diff = []
summ = []
mult = []
square = []
for i in range(len(num)):
if i<len(num)-1:
diff.append(num[i+1]-num[i])
summ.append(num[i+1]+num[i])
mult.append(num[i+1]*num[i])
square.append(num[i]*num[i])
print(diff)
print(summ)
print(mult)
print(square)
caluate(1,2,3,4)
# 全域变数 & 区域变数
a=b=c=1
def test(b):
a=2
print(a,b,c)
test(2)
print(a,b,c)
**下午:人工智慧与机器学系概论
练习使用Spyder,利用excel建立csv档,再将model套用csv预测数值
# -*- coding: utf-8 -*-
"""
Spyder Editor
This is a temporary script file.
"""
# step1 load data
import numpy as np
import matplotlib.pyplot as plt
import pandas as pd
from sklearn.linear_model import LogisticRegression as LR
data = pd.read_csv('training.csv')
test = pd.read_csv('testing.csv')
print(data.head())
# step 2: prepare X,Y
X = data['x'].values.reshape(-1,1)
Y = data['y'].values.reshape(-1,1)
testX = test['x'].values.reshape(-1,1)
# step 3: Build model
model = LR()
model.fit(X, Y)
a = model.coef_
b = model.intercept_
#储存模型
import pickle
import gzip
with gzip.GzipFile('myModle.pgz', 'w') as f:
pickle.dump(model,f)
# step 4: Evaluate
from sklearn.metrics import classification_report
preY = model.predict(X)
target_names = ['red', 'green']
print(classification_report(Y, preY, target_names=target_names))
# step 5: Deploy
testY = model.predict(testX)
test['y'] = testY
test.to_csv('result.csv', index = False, mode = 'w')
# step1 load data ******************
import numpy as np
import matplotlib.pyplot as plt
import pandas as pd
from sklearn.linear_model import LogisticRegression as LR
#data = pd.read_csv('training.csv')
test = pd.read_csv('testing.csv')
# step 2: prepare X,Y ****************
testX = test['x'].values.reshape(-1,1)
# step 3: Load model *****************
import pickle
import gzip
with gzip.open('myModle.pgz', 'r') as f:
model=pickle.load(f)
# step 4: Evaluate *********************
# step 5: Deploy **********************
testY = model.predict(testX)
test['y'] = testY
test.to_csv('result.csv', index = False, mode = 'w')
>>: 一个看起来是O(n)的function但实际上是O(n^2)
本篇介绍现行登入密码栏位,旁边都有一个小眼睛,是如何点一下就秀出密码的呢? ▼ 完成图如下 首先先...
在前面Day.3中我们把安装MYSQL Server的机器架在云端GCP上,所以在这边也以在GCP...
渲染(render)元件 我们知道了JSX的语法写出元件的结构,也知道如何宣告元件了, 现在来学如何...
那麽前几天都在摸索的主要区块,也只剩下"属性检视区" 如同字面的意思,这边会显示...
前情提要 上回偷拿远距离初阶魔法攻击艾草。 艾草:「我看你拿魔法丢我丢得挺顺的了(╬•᷅д•᷄╬),...