我可以通过Python使用不同的数据点来评估pi的值。但对于每一次重复,我想要像这样绘制散点图: ? 我使用蒙特卡洛方法查找pi的python代码是: from random import *
from math import sqrt
inside=0
n=10**6
for i in range(0,n):
x=random()
y=random()
if sqrt(x*x+y*y)<=1:
inside+=1
pi=4*inside/n
print (pi)
所有人。
因此,我是Python的新手,我正在尝试根据10个不同的数值输入来预测一个数值变量。特别是,我正在尝试应用多元线性回归,但希望在训练-测试-验证阶段添加蒙特卡洛交叉验证。所以,我写了一段代码,看起来像这样:
#I have imported libraries
#imported the dataset
#then created X and Y df.
#then split the data into training and testing, with validation parameters as follows:
from sklearn.model_selectio