当前位置:网站首页>Experiment 2: mathematical basis in Data Science
Experiment 2: mathematical basis in Data Science
2022-04-22 08:23:00 【Learn the Mediterranean】
Introduction to data science —— Optimization of mathematical basis
The first 1 Turn off : Basis of model optimization

The first 2 Turn off : gradient descent
Our mission : Use gradient descent to fit the input data x,y .
def student(x, y):
epsilon = 0.00001 # Iterative threshold , Stop the iteration when the difference between the two iterative loss functions is less than the threshold
alpha = 0.01 # Learning rate
a = 0
b = 0
m = len(x)
error0 = 0
error1 = 0
# ********* Begin *********#
while True
# ********* End *********#
Introduction to data science —— Probability of mathematical basis
The first 1 Turn off : Bayes of probability basis

The first 2 Turn off : Probability based data distribution

Introduction to data science —— Statistics of fundamentals of Mathematics
The first 1 Turn off : Data description of statistical basis
Our mission : Calculate relevant indicators for the input data .
def student(data):
#********* Begin *********#
n = len(data)
sorted_v = sorted(data)
midpoint = n // 2
if n % 2 == 1:
print( sorted_v[midpoint])
else:
lo = midpoint - 1
hi = midpoint
print( (sorted_v[lo] + sorted_v[hi]) / 2)
#********* End *********#
The first 2 Turn off : Correlation of statistical basis
Our mission : Write a program that can calculate covariance .
def de_mean(x):
x_bar = sum(x) / len(x)
return [x_i - x_bar for x_i in x]
def dot(v, w):
return sum(v_i * w_i for v_i, w_i in zip(v, w))
def student(x, y):
# ********* Begin *********#
n= len(x)
d=round(dot(de_mean(x), de_mean(y)) / (n - 1),2)
print(d)
# ********* End *********#
Introduction to data science —— Matrix of mathematical basis
The first 1 Turn off : What is a matrix ?
Our mission : Use the list to create a 20 That's ok 20 Columns of the matrix .
# ********** Begin ********** #
# The created matrix is assigned to matrix
matrix = [[0]*20 for x in range(20)]
for x in range(len(matrix)):
matrix[x][x] = 1
# ********** End ********** #
print(matrix)
The first 2 Turn off : Matrix operation based on line substitution
Our mission : Design a function to realize the multiplication between matrices .
def matxMultiply(A, B):
# ********** Begin ********** #
multiply = []
if len(A[0]) != len(B):
raise ValueError
result = [list(row) for row in zip(*B)]
for Al in range(len(A)):
row =[]
for Bl in range(len(result)):
num = 0
for Br in range(len(result[0])):
num += A[Al][Br] * result[Bl][Br]
row.append(num)
multiply.append(row)
return multiply
# ********** Begin ********** #
a = [[2,5,8,0],[1,9,5,8],[3,9,4,8]]
b = [[3,5],[6,8],[11,30],[1,1]]
print(matxMultiply(a,b))
Introduction to data science —— Vector of mathematical basis
The first 1 Turn off : Mathematics in Data Science

The first 2 Turn off : What is a vector ?
Our mission : Create a three-dimensional vector and a four-dimensional vector .
# Please write complete code according to the programming requirements on the left
# ********** Begin ********** #
list1 = [70, 170, 40]
list2 = [95, 80, 75, 62]
print (list1)
print (list2)
# ********** End ********** #
The first 3 Turn off : Vector operations
Our mission : Supplement the code on the right to realize the following vector operation :
- First calculate the sum of two vectors ;
- Multiply by a scalar .
a = eval(input())
b = eval(input())
c = 0.5
#********** Begin **********#
def scalar_multiply(c, v):
return [c * v_i for v_i in v]
def vector_add(v, w):
return [v_i + w_i for v_i, w_i in zip(v, w)]
add_result = vector_add(a,b)
result = scalar_multiply(c, add_result)
#********** End **********#
print(result)
版权声明
本文为[Learn the Mediterranean]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/04/202204220701238031.html
边栏推荐
- OneNET连接流程
- tf.keras.layers.Dense函数
- 牛客白月赛6【题解】
- Cr doped strontium titanate Cr: SrTiO3 crystal substrate | NaCl < 111 > 10x10x2 0mm1sp crystal substrate | Al2O3 sapphire crystal substrate | Qiyue biology
- 综合业务PDH光端机4路千兆隔离以太网络+4路E1专网业务2M综合业务光端机
- HLS / Chisel 实践CORDIC高性能计算复数平方根
- Welcoming the era of stable currency 3.0, usdd brings financial innovation
- Tita performance treasure: eight mistakes made by managers in performance appraisal
- 2-15 求组合数
- 力扣(LeetCode)111. 平衡二叉树(2022.04.21)
猜你喜欢

PDH optical transceiver optical fiber transmission 32-way E1 + 4-way 100m 100m network optical transceiver 2m multi service optical transceiver

荧光标记的透明质酸|FITC-Hyaluronate|荧光素透明质酸|Fluorescent hyaluronic acid

无水葡萄糖 cas:50-99-7 D(+)-Glucose 分子量:180.156 分子式:C6H12O6 密度及沸点值

分布式事物详解

nacos基础(3):OPEN API配置管理测试与关闭nacos服务
![FileNotFoundError: [Errno 2] No such file or directory](/img/ea/0c3f2768d14c1f4bb42bd1309ab996.png)
FileNotFoundError: [Errno 2] No such file or directory

LeetCode_118. 杨辉三角_动态规划_int**的学习

tf.keras.layers.Conv?D函数

实验四、数据预处理

Differences between routing modes
随机推荐
RSYNC及inotify远程同步
PDH光端机4路E1+4路百兆以太网 4路2M光端机 FC单纤20公里 机架式
3D 沙盒游戏之人物的点击行走移动
Layer1 capacity expansion: fragmentation and composability
Tensorflow usage notes
58技术沙龙第二十八期|安居客质量保障体系沙龙
Leprechaun green elf magic strikes
氧化镁MgO晶体基片|钛酸锶SrTiO3晶体基片|铌酸锂LiNbO3晶体基片;直径10mm
OpenCV对矩形填充透明颜色
Unity 透视投影矩阵变换的可视化
Dual channel optical network with 16 channels of E1 + 2m multi-channel optical transmission equipment
OneNET连接流程
LabVIEW 2012中的收藏选板导入到LabVIEW 2013
MySQL深入学习(三一):PowerDesigner的使用
tf.keras.layers.Embedding函数
Fluorescently labeled hyaluronic acid
实验四、数据预处理
Informatics Aosai yibentong 1317: [example 5.2] combined output
Tita 绩效宝:管理者在绩效考核中犯的8个错误
GoWeb基础