TEST : jupyter notebook css on wordpress


TEST : jupyter notebook css on wordpress



test0

In [3]:
# -*- coding: utf-8 -*-

"""
2020-06-04 V0.1 
- 코드 초안 작성 : 이전 코드 리마인드

2020-06-09 V0.2
- 코딩 순서 재구성 : 좌표 수정 -> 필요한 부분 선택
"""

#%% 모듈 불러오기


import pandas as pd

import os

import copy

import Dacharo_Data_Analysis_Module_V1 as DA
In [5]:
# 데이터 저장 폴더 설정
dataset_folder = 'dataset_sample\데이터셋 10Hz'

# 데이터 파일 이름 리스트
dataset_filename_list = os.listdir(dataset_folder)
In [6]:
""" 테스트 파일 샘플 """
dataset_filename = dataset_filename_list[0]
    
print(dataset_filename)
    
dataset_0 = pd.read_csv(os.path.join(dataset_folder, dataset_filename), sep = '\t', lineterminator='\r')
02-01_상행_첨두_다차로-01_06_2020-16h03m51s.txt
In [7]:
dataset_0
Out[7]:
time [00].VehicleUpdate-pos.001 [00].VehicleUpdate-pos.002 [00].VehicleUpdate-pos.003 [00].VehicleUpdate-pos.004 [00].VehicleUpdate-pos.005 [00].VehicleUpdate-pos.006 [01].VehicleUpdate-pos.001 [01].VehicleUpdate-pos.002 [01].VehicleUpdate-pos.003 ... [98].VehicleUpdate-accel.004 [98].VehicleUpdate-accel.005 [98].VehicleUpdate-accel.006 [99].VehicleUpdate-accel.001 [99].VehicleUpdate-accel.002 [99].VehicleUpdate-accel.003 [99].VehicleUpdate-accel.004 [99].VehicleUpdate-accel.005 [99].VehicleUpdate-accel.006 Last_TimeMarker
0 0.0 NaN NaN NaN NaN NaN NaN NaN NaN NaN ... NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN
1 0.1 -119.665077 -1813.449045 27.726005 2.150107 0.028032 0.003614 NaN NaN NaN ... NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN
2 0.2 -119.665608 -1813.447346 27.717433 2.150179 0.027869 0.005777 NaN NaN NaN ... NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN
3 0.3 -119.665722 -1813.447005 27.711008 2.150127 0.027244 0.006046 NaN NaN NaN ... NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN
4 0.4 -119.665911 -1813.446941 27.706748 2.150061 0.025732 0.005581 -104.450622 -1847.578739 28.828890 ... NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN
... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ...
2127 212.7 499.188907 629.733687 58.142079 1.206845 -0.003607 -0.001067 176.303515 -212.714938 43.594716 ... 0.0 0.0 0.0 -0.000123 0.000483 0.0 0.0 0.0 0.0 NaN
2128 212.8 499.188907 629.733687 58.142079 1.206846 -0.003607 -0.001067 177.022332 -210.844270 43.645535 ... 0.0 0.0 0.0 0.001018 0.000000 0.0 0.0 0.0 0.0 NaN
2129 212.9 499.188907 629.733687 58.142079 1.206846 -0.003607 -0.001067 177.724858 -209.016014 43.693337 ... 0.0 0.0 0.0 0.000093 0.000361 0.0 0.0 0.0 0.0 NaN
2130 213.0 499.188907 629.733687 58.142079 1.206846 -0.003607 -0.001067 178.425548 -207.192563 43.739379 ... 0.0 0.0 0.0 0.001154 0.000503 0.0 0.0 0.0 0.0 NaN
2131 213.1 499.188907 629.733687 58.142079 1.206846 -0.003607 -0.001067 179.115835 -205.396214 43.783368 ... 0.0 0.0 0.0 0.000286 0.000000 0.0 0.0 0.0 0.0 NaN

2132 rows × 3080 columns

In [8]:
from matplotlib import pyplot as plt
 
plt.plot([1,2,3], [110,130,120])
plt.show()
In [ ]:
 

 

test1

Updating pages in confluence

Neccessary imports

In [ ]:
import os
from confluenceapi import Confluence

Setting up our credentials

In [ ]:
conf_server = os.environ['CONFLUENCE_IP'] + ':8090'
credentials = ('admin', 'Password123')

Create a confluence object ready to submit requests

In [ ]:
lc = Confluence(conf_server, credentials)

Add a page

In [ ]:
lc.add_page('Page about DS', 'Data Science')

Update a page with raw HTML

In [ ]:
lc.update_page('Page about DS', 'Data Science', '<h1 style="color:red;">This is a new title</h1>')

Delete a page

In [ ]:
lc.delete_page('Page about DS', 'Data Science')

 

test2

Hierarchical Clustering

Example code for heirarchical clustering

In [4]:
import numpy as np
import pandas as pd
import matplotlib as mpl
import matplotlib.pyplot as plt
import seaborn as sns; sns.set()  # for plot styling
from scipy.spatial.distance import pdist, squareform
from scipy.cluster.hierarchy import linkage,fcluster,dendrogram, cophenet
from sklearn.cluster import AgglomerativeClustering
from sklearn.metrics.cluster import adjusted_rand_score, \
                                    homogeneity_completeness_v_measure, contingency_matrix
In [5]:
from sklearn.datasets.samples_generator import make_blobs
X, y_true = make_blobs(n_samples=60, centers=5,
                              cluster_std=(0.3,0.4,0.5,0.7,0.7),
                              center_box=(0, 8), random_state=1234)

y_true = pd.Categorical([["A","B","C","D","E"][x] for x in y_true])
df = pd.DataFrame(data={"x" : X[:,0],
                        "y" : X[:,1],
                        "target": y_true })
X = df.iloc[:,0:2]
y_true = df.iloc[:,2]
In [6]:
sns.scatterplot(x="x",y="y",hue="target",data=df )
plt.show()

Let's make our first hierarchical clustering. We'll do it piecewise, using some functions in the scipy.cluster.hierarchy package.

We start by computing a distance matrix over all of our data:

In [8]:
d = pdist(X,metric="euclidean")

Now, let's perform the hierarchical clustering using single linkage:

In [9]:
lnk = linkage(d,method="single")

Finally, let's plot a basic dendrogram using the dendrogram function. Notice some of the options we'll use to get some more informative results:

In [10]:
# Plot the dendrogram, but label the leafs using the actual labels in the data
plt.figure(figsize=(11,6))
plt.title("Hierarchical Clustering: Single Linkage")
plt.xlabel("sample index")
plt.ylabel("distance")
dnd = dendrogram(lnk,labels=list(y_true),leaf_rotation=0,leaf_font_size=9,
                 color_threshold=2)
plt.show()

 

댓글 남기기

Previous

네이버 서치어드바이저 수집 불가 & 네이버 블로그 검색 등록 불가 (해결방안 찾는 중…)

광풍실타프 (1) 구매결정 및 개봉기(Feat. 살 수 있을때 사세요.)

Next