最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

python?Copula?實(shí)現(xiàn)繪制散點(diǎn)模型

 更新時間:2022年07月08日 14:32:53   作者:北冰洋的喵  
這篇文章主要介紹了python?Copula實(shí)現(xiàn)繪制散點(diǎn)模型,文章圍繞主題展開詳細(xì)的內(nèi)容介紹,具有一定的參考價值,需要的朋友可以參考一下

 一、使用copula生成合成數(shù)據(jù)集(synthetic dataset)

1. 三維數(shù)據(jù)描述

建立一個三維數(shù)據(jù)表,查看三維數(shù)據(jù)的散點(diǎn)圖:

from copulas.datasets import sample_trivariate_xyz
data = sample_trivariate_xyz()
from copulas.visualization import scatter_3d
scatter_3d(data)

2. 使用高斯copula對數(shù)據(jù)集建模

使用GaussianMultivariate(自動)估計(jì)x、y、z的邊緣分布和聯(lián)合分布,從而能夠?qū)?shù)據(jù)集建模。

from copulas.multivariate import GaussianMultivariate
copula = GaussianMultivariate()
copula.fit(data)

3. 使用擬合后的模型生成新的數(shù)據(jù)集

使用sample按擬合好的邊際分布生成1000個新的樣本點(diǎn)(每個編輯分布都生成1000個樣本點(diǎn),3個邊際分布生成3000個樣本點(diǎn))

num_samples = 1000
synthetic_data = copula.sample(num_samples)
synthetic_data.head()

4. 觀察三維散點(diǎn)圖,比較擬合數(shù)據(jù)與真實(shí)數(shù)據(jù)的差異

from copulas.visualization import compare_3d
compare_3d(data, synthetic_data)

5. 保存與加載模型擬合路徑

對于需要較長時間進(jìn)行擬合copula模型的數(shù)據(jù),可以擬合一個比較合適的模型后,用save保存這個模型,在每次想采樣新數(shù)據(jù)時用load加載存儲在磁盤上已經(jīng)擬合好的模型。

model_path = 'mymodel.pkl'
copula.save(model_path)
new_copula = GaussianMultivariate.load(model_path)
new_samples = new_copula.sample(num_samples)

6. 提取和設(shè)置參數(shù)

在某些情況下,從擬合的連接中獲取參數(shù)比從磁盤中保存和加載參數(shù)更有用??梢允褂?code>to_dict方法提取copula模型的參數(shù):

copula_params = copula.to_dict()

一旦有了所有的參數(shù),就可以使用from_dict創(chuàng)建一個新的相同的Copula模型:

new_copula = GaussianMultivariate.from_dict(copula_params)
# 用新模型生成新的參數(shù):
new_samples = new_copula.sample(num_samples)

到此這篇關(guān)于python Copula 實(shí)現(xiàn)繪制散點(diǎn)模型的文章就介紹到這了,更多相關(guān)python Copula 內(nèi)容請搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持腳本之家!

相關(guān)文章

最新評論

象山县| 广汉市| 方山县| 紫阳县| 体育| 伊金霍洛旗| 山阴县| 封丘县| 夏津县| 靖宇县| 松潘县| 大石桥市| 疏附县| 定陶县| 乌拉特前旗| 大丰市| 德阳市| 阿克苏市| 防城港市| 宁海县| 阳东县| 会泽县| 泰州市| 泗洪县| 丹阳市| 汪清县| 乡宁县| 景洪市| 北京市| 芷江| 福建省| 图片| 天峨县| 马山县| 突泉县| 湘西| 叶城县| 嘉黎县| 木兰县| 丹凤县| 望江县|