This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
library(readr) | |
library(ggplot2) | |
path <- "/foo/bar/baz" | |
df <- read_csv(path, col_types = cols(Count = col_integer())) | |
cbPalette <- c("#E69F00", "#009E73", "#000000", "#0072B2", "#D55E00", "#CC79A7") | |
plot <- ggplot(data = df, aes(x = Date, y = Count, group = Tag, colour = Tag)) + | |
theme(plot.title = element_text(size = 24, face = "bold"), |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <cstdio> | |
#include <cstdlib> | |
#include <vector> | |
#include <cstdint> | |
#include <string> | |
typedef std::vector<std::vector<int>> Table; | |
typedef std::vector<int> Path; | |
struct NodesInShortestPath { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
test_matrix = randi(10, 10, 10) # 10 by 10 matrix | |
check_numeric = 3 | |
equality_check_matrix = (test_matrix == check_numeric) | |
result = test_matrix .* equality_check_matrix |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
na_expression <- c(1, 5, 10) | |
# data.frame | |
data_frame <- data.frame(x = 1:10, y = 5:14, z = 10:19) | |
for (element in na_expression) { | |
data_frame[data_frame == element] <- NA | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 하나의 값을 NA로 변환할 때 | |
element <- 0 | |
dt[dt == element] <- NA | |
# 여러 개의 값을 NA로 변환할 때 | |
na_expression <- c(0, 1, 2) | |
for (element in na_expression) { | |
dt[dt == element] <- NA | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Multilayer Perceptron (MLP) 생성 | |
model = Sequential() | |
# Dense(256)의 의미는 256개의 hidden unit을 가지는 fully connected layer | |
# keras에서는 첫 번째 Layer, 즉 input layer의 input dimension만 지정하면 | |
# 뒤의 연결되는 Layer의 dimension은 간단하게 작성 가능하다. | |
# width * height = 784인 dimension | |
# glorot_uniform == Xavier Initialization, keras에서는 내부적으로 이미 제공 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 데이터 Load 및 전처리 과정 | |
# Train, Test 데이터 Load | |
(X_train, y_train), (X_test, y_test) = mnist.load_data() | |
# Train 데이터 포맷 변환 | |
# 60000(Train Sample 수) * 28(가로) * 28(세로) 포맷을 | |
# 60000(Train Sample 수) * 784(= 28 * 28) 포맷으로 수정 | |
num_of_train_samples = X_train.shape[0] # Train Sample 수 | |
width = X_train.shape[1] # 가로 길이 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# MNIST 데이터 관련 import | |
from keras.datasets import mnist # MNIST 데이터 Loader | |
from keras.utils.np_utils import to_categorical # One-hot 포맷 변환 | |
import numpy as np # float type casting | |
# Feature scaling 관련 import | |
from sklearn.preprocessing import minmax_scale # [0-1] Scaling | |
# Model 구축 관련 import | |
from keras.models import Sequential |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include "my_array.h" | |
MyArray::MyArray() { | |
size_ = 0; | |
last_element_index_ = -1; | |
ptr_ = NULL; | |
} | |
MyArray::MyArray(int initial_size) { | |
size_ = initial_size; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#ifndef MY_ARRAY_H_ | |
#define MY_ARRAY_H_ | |
#include <cstring> | |
#include <iostream> | |
class MyArray { | |
public: | |
MyArray(); | |
MyArray(int initial_size); |
NewerOlder