data analysis & visualization

파티션(Partition)이란 하드디스크의 영역을 설정하는 것을 말한다.

 

파티션 장치명은 /dev/sda1 처럼 구성되는데 

여기서 sd는 S-ATA 및 SCSI 방식 디스크, SSID, USB 등을 의미

hd는 IDE방식의 디스크를 의미

 

a는 디스크의 우선순위를 의미한다.

1은 파티션 번호를 의미한다.

 

swap : RAM이 부족할 경우 사용되는 영역으로 

 

파티션 분할을 하기 위해서 여러가지 툴을 쓸 수 있는데 fdisk, parted, cfdisk, sfdisk, kpartx 등이 가능하다.

 

fdisk -l

 

 

 

 

저는 /dev/sdb를 포맷하고 싶기 때문에

fdisk /dev/sdb 명령어를 사용하겠습니다.

파티션을 지욱고 싶어서

fdisk /dev/sdb

1, 2, 3을 지웠습니다.

d>1>w

p>w

 

mkfs.ext4 /dev/sdb1

blkid

vi /etc/fstab

sudo mount -a 

'ubuntu' 카테고리의 다른 글

리눅스 계정 비밀번호 초기화  (0) 2020.12.06
ssh 등록하기  (0) 2020.11.12
ubuntu 20.04 세팅하기[gpu 분석 세팅, jupyter notebook]  (0) 2020.11.12
ubuntu LightGBM install  (0) 2020.04.14
라즈베리파이 selenium 사용법  (0) 2020.03.23

ssh 등록하기

ubuntu2020. 11. 12. 02:29


sudo apt-get install openssh-server

sudo apt-get install ssh

sudo vi /etc/ssh/sshd_config

sudo ufw enable

sudo ufw allow 22

 

우분투에 tensorflow 와 pytorch를 설치해보자. 

 

아래 명령어를 통해 nvidia의 잔여 찌꺼기를 모두 제거하자. 

 

sudo apt-get --purge remove nvidia*

 

아래 명령어를 통해 내게 맞는 드라이버 목록을 확인하자.

 

ubuntu-drivers devices

위에서 처럼 recommended 로 추천이라고 적혀있다.

 

명령어로 다운받기 위해 다운받을 리퍼지토리를 등록하자.

 

sudo add-apt-repository ppa:graphics-drivers/ppa 

sudo apt update

 

아래 명령어를 통해 설치 가능한 드라이버 목록을 확인 할 수 있다.

 

apt-cache search nvidia | grep nvidia-driver-450

 

sudo apt-get install nvidia-driver-450

 

설치가 완료되면 재부팅하자. 

 

sudo reboot

 

만약 설치 중 문제가 발생하면 아래 명령어를 사용합시다.

sudo apt --purge autoremove nvidia*

 

아래 명령어로 자동 인스톨 또한 가능합니다. 

ubuntu-drivers autoinstall

 

아나콘다를 설치하자.

www.anaconda.com/distribution/

 

"cd /설치된 경로"  명령어로 경로를 이동한 뒤 다음 명령어를 실행하자.

 

sudo bash Anaconda3-2020.07-Linux-x86_64.sh

엔터 치라고 하니 Enter

라이센스에 동의합니까는 yes가 국룰

 

아나콘다 경로는 디폴트로 하겠습니다.

 

아나콘다 명령어가 터미널 아무데서나 실행되게 하겠느냐 라는 명령어 입니다. yes

 

conda create --name kerasGPU keras-gpu python=3.6

 

conda create -n tf1_14 tensorflow-gpu=1.14 keras-gpu python=3.6

 

 

conda create --name [새로운 가상환경이름] --clone [복제하려는 가상환경이름]

 

conda install pytorch torchvision torchaudio cudatoolkit=10.1 -c pytorch 

 

 

pytorch.org/홈페이지에서 맞는 환경의 명령어를 받으세요.!

 

PyTorch

An open source deep learning platform that provides a seamless path from research prototyping to production deployment.

pytorch.org

 

tensorflow gpu check

 

import tensorflow as tf

tf.test.is_gpu_available()

 

import torch

torch.cuda.is_available()

torch.cuda.current_device()

torch.cuda.get_device_name(0)

 

conda install catboost

conda install -c conda-forge lightgbm

 

ligth GBM gpu 버전 설치 

 

github.com/microsoft/LightGBM/blob/master/docs/Installation-Guide.rst#build-gpu-version

 

microsoft/LightGBM

A fast, distributed, high performance gradient boosting (GBT, GBDT, GBRT, GBM or MART) framework based on decision tree algorithms, used for ranking, classification and many other machine learning ...

github.com

 

병렬처리를 하려면 cmake 가 필요한거 같다. 

아래명령어는 cmake설치 명령어인데 아래로 설치하면 애러가 뜨는 것 같다.

sudo apt install cmake 

 

https://cmake.org/downlaod홈페이지에서 다운로드를 받고 압축 풀기 및 설치를 해보자.

 

tar -xvzf 해당파일.tar.gz

cd 해당파일

./bootstrap --prefix=/usr/local

에러뜨면 아래 명령어

apt-get install libssl-dev

make

make install

 

vi ~/.bashrc

 

PATH=$PATH:/usr/local/bin/

 

source ~/.bashrc

cmake --version

 

사이트를 보면 이외에도 필요한 것들이 있는데

OpenCL, libboost를 설치해 달라고 나온다. 

 

sudo apt-get install ocl-icd-libopencl1 ocl-icd-opencl-dev libboost-dev libboost-system-dev libbost-filesystem-dev

 

를 설치해준다. 

 

설치가 끝났다면

 

git clone --recursive https://github.com/microsoft/LightGBM

cd LightGBM

mkdir build; cd build

cmake -DUSE_GPU=1 ..

make -j4

 

git clone --recursive https://github.com/microsoft/LightGBM.git

cd LightGBM/python-package

python setup.py install

 

해당명령어로 설치해주면 된다. 

 

conda install -c anaconda mxnet-gpu

conda install scikits.cuda

 

xgboost gpu 설치

 

git clone --recursive https://github.com/dmlc/xgboost

cd xgboost

git submodule init

git submodule update

make -j4

 

eagle705.github.io/articles/2018-06/XGBoost-%EC%A0%95%EB%A6%AC

 

XGBoost 정리 | eagle705's Note

요즘 Kaggle에서 가장 핫하다는

eagle705.github.io

 

conda install jupyter notebook

conda install -c conda-forge jupyterlab

 

python

from notebook.auth import passwd

passwd()

'sha1:...............'을 출력할 텐데 저장 해두고 조금있다 입력.

 

 jupyter notebook --generate-config

 

내부ip 확인하기

sudo apt install net-tools

 

ifconfig

2번째 줄 inet 옆에 값

 

주피터 노트북 설정하기

 

 vi ~/.jupyter/jupyter_notebook_config.py

 

 c.NotebookApp.ip = '내부ip'

 

c.NotebookApp.open_browser = False

 

c.NotebookApp.password = u'sha1:...............'

 

c.NotebookApp.port=8888

 

c.NotebookApp.notebook_dir=u'/home/ducj/data'

 

c=get_config()

 

 

주피터 노트북 서버 항상 켜진상태로 두기

 

sudo jupyter notebook --allow-root 

ctrl+z

 

bg

 

disown -h

 

sudo ufw allow 8686

 

주피터 노트북 목록보기

sudo jupyter notebook list

주피터노트북 끄기

sudo jupyter notebook stop 8686

 

gpu 상태 체크

 watch -n 5 nvidia-smi -a --display=utilization



 

 

codechacha.com/ko/install-nvidia-driver-ubuntu/

'ubuntu' 카테고리의 다른 글

우분투 파티션하고 마운트하기  (0) 2020.11.14
ssh 등록하기  (0) 2020.11.12
ubuntu LightGBM install  (0) 2020.04.14
라즈베리파이 selenium 사용법  (0) 2020.03.23
nas 마운트하기  (0) 2020.03.23

 

 

 

In [1]:
import matplotlib
import matplotlib.pyplot as plt
import pandas as pd
import numpy as np
In [2]:
import os,re
files=[i for i in os.listdir(os.getcwd()) if re.compile('csv').findall(i)]
print(files)
 
['OBS_AWS_TIM_20201103160221.csv']
In [3]:
df=pd.read_csv(os.getcwd()+'/'+files[0],encoding='cp949')
u=np.sin(np.deg2rad(270-df['풍향(deg)']))*df['풍속(m/s)']
v=np.cos(np.deg2rad(270-df['풍향(deg)']))*df['풍속(m/s)']
In [4]:
df['일시']=pd.to_datetime(df['일시'])
df=df.set_index(['일시'])
In [5]:
df.head(1)
Out[5]:
  지점 지점명 기온(°C) 풍향(deg) 풍속(m/s) 강수량(mm) 현지기압(hPa) 해면기압(hPa) 습도(%)
일시                  
2020-10-20 966 풍도 17.3 330.5 2.1 0 1021.4 1025.9 77.7
In [6]:
df.columns
Out[6]:
Index(['지점', '지점명', '기온(°C)', '풍향(deg)', '풍속(m/s)', '강수량(mm)', '현지기압(hPa)',
       '해면기압(hPa)', '습도(%)'],
      dtype='object')
 

폰트 설정

In [7]:
import matplotlib.font_manager as fm
font=fm.get_fontconfig_fonts()[11]
font
Out[7]:
'/usr/share/fonts/truetype/nanum/NanumGothicLight.ttf'
In [8]:
font_name = fm.FontProperties(fname=font).get_name()
#matplotlib.rc('font', family=font_name)
matplotlib.rc('font',family='NanumBarunGothic.ttf')
#'C:/Windows/Fonts/malgun.TTF'
 

마이너스 부호

In [9]:
matplotlib.rcParams['axes.unicode_minus']=False
 

figure 기본옵션

In [10]:
plt.figure(num=None, figsize=[6.4,4.8], dpi=100, facecolor='white', edgecolor='w', frameon=True)
plt.plot([1,2,3])
Out[10]:
[<matplotlib.lines.Line2D at 0x7ff568f5e438>]
 
 
 
 

여러개로 된 그래프 한번에 그릴 때 옵션 조절하기

In [11]:
matplotlib.gridspec.GridSpec(nrows=3, ncols=3,left=0.1, bottom=0.15, right=0.94, top=0.94, wspace=0.3, hspace=0.3\
                             ,width_ratios=None,height_ratios =None)
Out[11]:
<matplotlib.gridspec.GridSpec at 0x7ff56c34b320>
In [12]:
# equivalent but more general
ax1=plt.subplot(2, 2, 1)
# add a subplot with no frame
ax2=plt.subplot(222, frameon=False)
# add a polar subplot
plt.subplot(223, projection='polar')
# add a red subplot that shares the x-axis with ax1
plt.subplot(224, sharex=ax1, facecolor='red')
# delete ax2 from the figure
plt.delaxes(ax2)
# add ax2 to the figure again
plt.subplot(ax2)
Out[12]:
<matplotlib.axes._subplots.AxesSubplot at 0x7ff568ec0e48>
 
 
 
In [13]:
fig, ax = plt.subplots(2,3)
plt.show()
 
 
 
In [14]:
fig = plt.figure()
#fig를 shape으로 나눴을 때 rowspan, colspan만큼 차지하며 위치는 loc로 찾음
ax1 = plt.subplot2grid(shape=(3,3),loc=(0,0),rowspan=1,colspan=1)
ax2 = plt.subplot2grid(shape=(2,2),loc=(1,1))
plt.show()
 
 
 
In [15]:
df.columns
Out[15]:
Index(['지점', '지점명', '기온(°C)', '풍향(deg)', '풍속(m/s)', '강수량(mm)', '현지기압(hPa)',
       '해면기압(hPa)', '습도(%)'],
      dtype='object')
In [16]:
defaultColor=['#1f77b4', '#ff7f0e', '#2ca02c', '#d62728', '#9467bd', '#8c564b', '#e377c2', '#7f7f7f', '#bcbd22', '#17becf']
In [17]:
plt.scatter(df.index,df['기온(°C)'],s=20,c=defaultColor[0],marker='o',label='기온(°C)',edgecolors='black')
plt.grid()
plt.tight_layout() 
plt.ylim((0,20))
plt.yticks(range(0, 20, 5),fontsize=15)
plt.gca().yaxis.set_major_formatter(plt.matplotlib.ticker.StrMethodFormatter('{x:,.0f} °C'))
plt.ylabel('시정(m)',fontsize=20,rotation=30)
plt.gca().axhline(12, linestyle='--', color='gray',alpha=.3) 
plt.axvspan(pd.to_datetime('2020-10-20 01'), pd.to_datetime('2020-10-22 15'), color='red', alpha=0.2,label='dd')
plt.legend(loc='lower right', prop={'size': 15},scatterpoints=300,bbox_to_anchor=(1, 1))
import matplotlib.dates as md
xfmt = md.DateFormatter('%m/%d %H')
plt.gca().xaxis.set_major_formatter(xfmt)
plt.legend(loc=4,bbox_to_anchor=(0.45,-0.28),framealpha=0.0,fontsize=15,ncol=2)
 
 
Out[17]:
<matplotlib.legend.Legend at 0x7ff568c77710>
 
In [18]:
fig=plt.figure()
host= plt.subplot()
ax1 = host.twinx()
host.yaxis.set_label_coords(0.06,1.03)
host.set_ylabel(host.get_ylabel(), rotation=0, labelpad=20,fontsize=20)
ax1.spines['right'].set_position(('axes',1.11))
plt.tight_layout()
p0,=plt.plot([1,2,3])
ax1.plot([4,7,8])
host.tick_params(axis='y', colors=p0.get_color(), direction='in')
ax1.tick_params(axis='y',  direction='in')
host.spines["left"].set_visible(False)
ax1.spines["left"].set_edgecolor(p0.get_color())
 
 
 
In [19]:
x=df.index
k=1
plt.quiver(x[::k],np.zeros(len(x))[::k],u.values.tolist()[::k],v.values.tolist()[::k],scale_units='y',angles='uv',scale=1,width=.0008)
plt.ylim(-10,10)
plt.axis('off')
Out[19]:
(737717.7520833333, 737723.20625, -10.0, 10.0)
 
 
 

'python' 카테고리의 다른 글

아나콘다 오프라인 가상환경 생성 , 가상환경 추출 및 설치  (0) 2020.11.20
pyinstaller  (0) 2020.11.20
pypy  (0) 2020.08.31
python package 생성  (0) 2020.08.17
python gridSearch, RandomSearch  (0) 2020.07.30

먼저 관리자 권한으로 명령프롬프트를 행합니다.

 

netsh wlan show driver

 

netsh 은 윈도우에서 인터넷 관련 쉘을 의미하며 무선네트워크 드라이버를 보여달라는 명령어를 의미합니다.

 

호스트된 네트워크 지원이 예라고 표기 되었으면 노트북으로 와이파이가 가능합니다.

 

그럼 이제 설정을 해보겠습니다.

 

netsh wlan set hostednetwork mode=allow ssid=<와이파이명> key=<비밀번호>

 

비밀번호는 8자리 이상이여야합니다.

 

설정이 끝나면 실행해보겠습니다. 

 

netsh wlan start hostednetwork

 

시작이라고 했지만 서비스가 진행되지 않습니다.

 

제어판에 네트워크 및 인터넷을 통해 로컬 영역(이더넷)의 <속성>에 들어갑니다.

 

<공유>의 <인터넷 연결 공유>에서 <다른 네트워크 사용자가 이 컴퓨터의 ... 허용>을 체크합니다.

 

홈 네트워킹 연결을 통해 방금 만든 무선연결을 설정해주시면 됩니다.

SQL에서 개인적으로 자주 쓰는 문법

개인적으로 DB를 자유롭게 저장할 수 있다는 장점 때문에 sqlite를 많이 사용하고 있다.

 

오늘은 이 중에서 상위 자료 n개 보는법, 원하는 시간의 자료 뽑아내는법, fstring 쓰는법을 묶어 기입해보았다.

 

먼저  table리스트를 보기위해 qurey로 sqlite_master의 type이 table인 것만을 출력한다.

table list에 <table name>이  있다면 limit <n>을 통해 상위 n개의 자료를 출력할 수 있다.

 

또한 record_time이라는 column이 분단위 자료를 가지고 있는 시간 자료라고 하면 시간 자료만을 추출하기 위해 

아래와 같은 문법을 쓸 수 있다.

 

fstring은 예제로 남겨두겠다.  

import sqlite3

import pandas as pd

conn=sqlite3.connect('<filename.db>')

cur=conn.cursor()

cur.execute("select name from sqlite_master where type='table';")

print(cur.fetchall())

pd.read_sql('select * from <table name> limit 5;',conn)



pd.read_sql(f"select * from <table name> where (
            strftime('%M',record_time)='00'
            )&(obscode='{obscode}');",conn)

conn.close()

'SQL' 카테고리의 다른 글

1. 데이터 모델링의 이해(2)  (0) 2020.01.31
1. 데이터모델링의 이해(1)  (0) 2020.01.31
SQL개념 정리  (0) 2020.01.22