반응형
반응형
본문 바로가기

Data Science44

Data Science Week 10 Data Science Week 10 Using continuous variable as input variable - Now we take a continuous variable "age" as predictor (input variable) to make prediction - To use 'age' variable for prediction, we convert it into range variable 'age_group', which contains under 20, 20s, 30s, 40s, 50s, over60 summary(adult$age) adult.train$age_group 2021. 5. 3.
Data Science Week 09 Data Science Week 09 Memorization Method Classification and Regression Classification is a task that predicts discrete event (class) - is a e-mail spam or not (binary) - does a patient have breast cancer or not (binary) - predict letter grade a student expected to get for this class (multi-class, A, B, C, D, F) Regressoin is a task that predicts continuous value (score) - expected housing price .. 2021. 5. 3.
[Week 04] Lectures [Week 04] Lectures # Useful functions sample(X, #sample, replace = FALSE, ...) [41 sample split] sample - random-sampling with and without (default) replacement set.seed(2018) x 25) mtcars[mtcars$mpg > 25, ] [42 merge which] Merge Merge(df1, df2, ...) - Join two data frames into one with common variables x 2021. 3. 28.
Week 01: Basics of R Week 01: Basics of R print("hello") [1] "hello" a = 10 b = 20 a+b [1] 30 ?print install.package("randomForest") library("package name") or require("package name") Variable is a container to hold data (or information) that we want to work with. Variable can hold - a single value: 10, 10.5, "abc", factor, NA, NULL - multiple values: vector, matrix, list - specially formatted data (values): data.fr.. 2021. 3. 2.
R기초; R 기초 - ggplot2 그래픽6 - 그래프 배치 및 저장 R기초; R 기초 - ggplot2 그래픽6 - 그래프 배치 및 저장 library(ggplot2) libray(car) str(Salaries) ggplot(Salaries, aes(x=rank)) + geom_bar(fill="steelblue") ggplot(Salaries, aes(x=salary)) + geom_histogram(fill="maroon") ggplot(Salaries, aes(x=yrs.since.phd, y=salary)) + geom_point(color="orange") ggplot(Salaries, aes(x=rank, y=salary)) + geom_boxplot(fill="mistyrose") install.packages("gridExtra") library(grid.. 2021. 1. 24.
R기초; R 기초 - ggplot2 그래픽5 - 테마 R기초; R 기초 - ggplot2 그래픽5 - 테마 library(ggplot2) library(car) str(Salaries) ggplot(Salaries, aes(x=yrs.since.phd, y=salary, color=rank, shape=rank)) + geom_point() + facet_grid(. ~ sex) + theme_gray() ?theme_gray theme() ggplot(Salaries, aes(x=rank, y=salary, fill=sex)) + geom_boxplot() + labs(title="Salary by Rank and Sex", x="Rank", y="Salary") + theme(plot.title=element_text(face="bold.italic",.. 2021. 1. 24.
R 기초 - ggplot2 그래픽4 - 그래프 옵션 R 기초 - ggplot2 그래픽4 - 그래프 옵션 library(ggplot2) library(car) str(Salaries) ggplot(Salaries, aes(x=rank, y=salary, fill=sex)) + geom_boxplot() + scale_x_discrete(breaks=c("AsstProf", "AssocProf", "Prof"), labels=c("Assistant Professor", "Associate Professor", "Professor")) + scale_y_continuous(breaks=c(50000, 100000, 150000, 200000), labels=c("$50k", "$100k", "$150k", "$200k") scale_x_discrete() sc.. 2021. 1. 24.
R 기초 - ggplot2 그래픽3 - 집단별 그래프 R 기초 - ggplot2 그래픽3 - 집단별 그래프 library(ggplot2) library(car) str(Salaries) # 투명도 50% 분포도 ggplot(Salaries, aes(x=salary)) + geom_density(alpha=0.5) # 산점도 ggplot(Salaries, aes(x=yrs.since.phd, y=salary, color=rank, shape=sex)) + geom_point() # 막대그래프 ggplot(Salaries, aes(x=rank, fill=sex)) + geom_bar(position="stack") ggplot(Salaries, aes(x=rank, fill=sex)) + geom_bar(position="dodge") ggplot(Salari.. 2021. 1. 24.
R 기초; ggplot2 그래픽2 - geom 함수 옵션 R 기초; ggplot2 그래픽2 - geom 함수 옵션 library(ggplot2) head(mtcars) ggplot(data=mtcars, aes(x=wt, y=mpg)) + geom_point() + geom_smooth() + labs(title="Fuel consumption vs weight", x="Weight (1000 lbs)", y="Fuel consumption (miles per gallon)") ?geom_point ?par ?colors() ?geom_smooth ?geom_text( library(car) str(Salaries) ggplot(Salaries, aes(x=rank, y=salary)) + geom_boxplot(fill="salmon", color="dimg.. 2021. 1. 24.

반응형