Base Line/python 기초 코드
-
리스트 딥카피Base Line/python 기초 코드 2023. 8. 24. 17:13
이썬 리스트에서 a=[] 이고 tmp=[1,2,3] 라고 할때 그냥 a.append(tmp)랑 a.append(tmp[:]) 라고 한다면 a.append(tmp): 이 경우에는 리스트 a에 tmp 리스트 객체를 추가하는 것입니다. 즉, a 리스트 안에는 하나의 요소로서 tmp 리스트 전체가 들어가게 됩니다. 이후 tmp 리스트가 변경되면 a 리스트에 추가된 요소도 함께 변경될 수 있습니다. 이는 a 리스트가 tmp 리스트를 참조하고 있는 것입니다. 따라서 a[0] is tmp가 True일 것입니다. a.append(tmp[:]): 이 경우에는 tmp 리스트의 내용을 슬라이싱하여 새로운 리스트 객체를 생성한 후, 이를 a 리스트에 추가합니다. 이렇게 하면 a 리스트와 tmp 리스트는 완전히 별개의 객체가 ..
-
sobel, canny, laplacian filterBase Line/python 기초 코드 2022. 12. 3. 12:16
import cv2 src = cv2.imread("normal.jpg", cv2.IMREAD_COLOR) gray = cv2.cvtColor(src, cv2.COLOR_BGR2GRAY) sobel = cv2.Sobel(gray, cv2.CV_8U, 1, 0, 3) laplacian = cv2.Laplacian(gray, cv2.CV_8U, ksize=3) canny = cv2.Canny(src, 100, 255) cv2.imwrite('normal_canny.jpg', canny) #cv2.save #cv2.imshow("sobel", sobel) #cv2.imshow("laplacian", laplacian) #cv2.imshow("canny", canny) cv2.waitKey() cv2.destr..
-
Genetic Algorithm(feature selection) + LightGBMBase Line/python 기초 코드 2022. 8. 25. 17:45
from __future__ import print_function import numpy as num from sklearn import datasets, linear_model from catboost import CatBoostRegressor, Pool from genetic_selection import GeneticSelectionCV import numpy as np import pandas as pd import os import math import random from tqdm import tqdm from scipy.stats import skew,kurtosis import matplotlib.pyplot as plt import seaborn as sns import warning..
-
Auto encoderBase Line/python 기초 코드 2022. 8. 23. 21:32
DDPM Autoencoder Diffusion Autoencoders: Toward a Meaningful and Decodable Representation cvpr2022 논문을 보기전에 auto encoder랑 VAE를 정리하고 가면 좋을 것 같아서 auto encoder 구현에 대해 짧게 정리했다. import torch import torchvision import torch.nn.functional as F from torch import nn, optim from torchvision import transforms, datasets import matplotlib.pyplot as plt from mpl_toolkits.mplot3d import Axes3D from matplotlib ..
-
sklearn 회귀관련 모델 정리Base Line/python 기초 코드 2022. 8. 16. 21:07
sklearn 회귀관련 모델 정리 GradientBoostingRegressor ElasticNet SGDRegressor SVR BatesianRidge CatBoostRegressor KernelRidge LinearRegression XGBRegressor LGBMRegressor RandeomForestRegressor DNN?? #sklearn 회귀 모델 불러오기 from sklearn.ensemble import GradientBoostingRegressor, RandomForestRegressor from sklearn.linear_model import ElasticNet, SGDRegressor, BayesianRidge, LinearRegression from sklearn.linear..
-
pandas - 2Base Line/python 기초 코드 2022. 7. 12. 00:06
dataframe.iloc Access group of rows and columns by integer position(s). iloc는 integer location의 약어임 데이터 프레임의 행이나 칼럼의 순서를 나타내는 정수 즉, iloc은 index의 위치를 가리키는 것이라고 생각하면됨. dataframe.loc Access a group of rows and columns by labels(s) or a boolean array. label을 부르면 됨
-
pandas - 1Base Line/python 기초 코드 2022. 7. 1. 22:04
from pandas import Series, DataFrame import pandas as pd list_data = [1,2,3,4,5] example_obj = Series(data = list_data) example_obj list_data = [1,2,3,4,5] list_name = ["a","b","c","d","e"] example_obj = Series(data = list_data, index = list_name) example_obj import numpy as np dict_data = {"a":1,"b":2,"c":3,"d":4,"e":5} example_obj = Series(dict_data,dtype=np.float32,name="example_data") exampl..