r

insurance = read.csv('mlwr/insurance.csv') # 데이터 확인str(insurance)'data.frame': 1338 obs. of 7 variables:$ age : int 19 18 28 33 32 31 46 37 37 60 ...$ sex : Factor w/ 2 levels "female","male": 1 2 2 2 2 1 1 1 2 1 ...$ bmi : num 27.9 33.8 33 22.7 28.9 25.7 33.4 27.7 29.8 25.8 ...$ children: int 0 1 3 0 0 0 1 3 2 0 ...$ smoker : Factor w/ 2 levels "no","yes": 2 1 1 1 1 1 1 1 1 1 ...$ region : Fact..
# 버섯 분류 - 나이브 베이즈 방법 # 1. 데이터 준비mushroom 버섯 분류할 때 사용되지 않는 변수 -> 데이터 프레임에서 제거mushroom$veil_type
# csv 파일을 읽어서 데이터 프레임 생성> credit str(credit)'data.frame': 1000 obs. of 17 variables:$ checking_balance : Factor w/ 4 levels " 200 DM",..: 1 3 4 1 1 4 4 3 4 3 ...$ months_loan_duration: int 6 48 12 42 24 36 24 36 12 30 ...$ credit_history : Factor w/ 5 levels "critical","good",..: 1 2 1 2 4 2 2 2 2 1 ...$ purpose : Factor w/ 6 levels "business","car",..: 5 5 4 5 2 4 5 2 5 2 ...$ amount ..
# k-NN 알고리즘을 이용한 Iris 품종 분류# k-NN 알고리즘을 구현한 패키지를 설치install.packages("class")# 패키지를 검색경로(메모리)에 로드 library(class)rm(list=ls())# class::knn(학습데이터, 테스트데이터, 학습데이터의정답, k값) # csv 파일에서 데이터프레임 생성iris
Codezoy
'r' 태그의 글 목록