목록2020/10 (33)
우노
MovieLens 데이터 영화 평점 데이터셋 크기별로 다양하게 존재 : 100K, 1M, 10M, 20M 실습에서 사용할 데이터셋 : 100K https://grouplens.org/datasets/movielens/ 데이터 준비 ml-100k.zip 파일을 받아서 적절한 위치에 압축풀기 Pytorch 사용하기 필요한 모듈 import 하기 import torch import pandas as pd import torch.nn.functional as F import matplotlib.pyplot as plt 파일 불러오기 Pandas를 이용하여 파일 불러오기 train = pd.read_csv("../ds_data/ml-100k/ua.base", sep="\t", names=['user'..
별점 예측 부분에서 Collaborative filtering보다 동작을 잘하는게 Latent Factor Model이다. 하지만 단점이 존재한다. Collaborative filtering은 근거를 댈 수 있지만 Latent Factor Model은 근거를 댈 수 없다. Latent Factor Model Latent Factor Model은 사용자와 아이템을, 잠재적인 차원(Factor)들을 사용해 나타낼 수 있다고 보는 모델이다. 여기서 차원은 축과 같은 의미로 사용될 수 있다. 예를 들어, 위 그림처럼 x 축을 남성향, 여성향의 정도로 표현하고 y 축을 웃기고, 심각함의 정도로 표현할 수 있다면 사용자와 아이템은 적절한 x, y축 값에 매핑 된다는 것이다. 길동 = ( -3.1, -4.2 ) 테넷..
에러 DenseMatrix를 생성하는 경우 import org.apache.spark.mllib.linalg.DenseMatrix val a = DenseMatrix.ones(46341,46341) java.lang.IllegalArgumentException: requirement failed: 46341 x 46341 dense matrix is too large to allocate at scala.Predef$.require(Predef.scala:224) at org.apache.spark.mllib.linalg.DenseMatrix$.ones(Matrices.scala:473) SparseMatrix를 생성한 후 toDense를 하는 경우 import org.apache.spark.mllib...
Map Scala의 Map은 Python의 Dictionary와 유사하게 사용된다. 특성 Map 은 변경 가능한 것 (mutable.Map) 과 변경 불가능한 것 (immutable.Map) 모두를 제공합니다. 예를들어 put 이라든지 remove 메소드는 immutable.Map 에서는 사용 불가. import scala.collection.mutable.Map 생성 val m = Map[Int,String]() val m2 = Map(1 -> "one" , 2-> "two") // 이렇게 초기화 할 수 있고 val m3 = Map((1,"one") , (2,"two")) // 이렇게도 할 수 있다. 추가 val m = mutable.Map[Int,String]() // 아래 처럼 가능 ( mutabl..
String Interpolation이란? String Interpolation은 스칼라 2.10에 추가된, 데이터를 기반으로 문자열을 더 쉽게 만들수 있는 새로운 기능이다. 즉, 문자열을 출력하거나 선언할 때 중간중간 다른 변수를 끼워넣는 구문이다. String Interpolation은 s, f, raw 세가지의 방식을 제공한다. s String Interpolator 문자열 앞에 s를 붙혀서 사용하고, ${변수명}으로 변수의 내용을 참조할 수 있다. val a = "Hello" val b = s"${a} 1" println(a) // Hello println(b) // Hello 1 println(s"${a} World") // Hello World
우선 YARN Resource의 개념에 대해 간단하게 알고 넘어가자 YARN Resource 개념 클러스터에 있는 노드 하나의 물리적 자원이 다음과 같다고 가정했을 때 CPU : 24 Memory : 128GB 다음 그림과 같이 YARN 리소스를 할당할 수 있다. yarn.nodemanager.resource.memory-mb nodemanager의 메모리 크기 한 노드의 물리 메모리가 128GB이므로, OS를 위한 8GB 정도를 제외해 120GB로 설정 yarn.scheduler.maximum-allocation-mb ResourceManager가 하나의 컨테이너 할당에 필요한 최대 메모리 크기 따라서, "yarn.scheduler.maximum-allocation-mb" 값은 "yarn.nodeman..
Amazon EMR에서 yarn-site.xml(Yarn 설정 파일)의 위치는 아래와 같다. /etc/hadoop/conf/yarn-site.xml
yarn resource 재시작 sudo systemctl stop hadoop-yarn-resourcemanager sudo systemctl status hadoop-yarn-resourcemanager sudo systemctl start hadoop-yarn-resourcemanager
다음 명령을 통해, yarn 환경에서 각 Worker 노드에 할당된 Executor 수를 확인할 수 있다. yarn node -list
break 스칼라에서는 기본 break 구문이 없어서 Breaks 객체를 만들어서 루프를 break 해야한다. 예제코드 // a가 6이 되면 루프중단 import scala.util.control._ var a = 1 var loop = new Breaks loop.breakable{ while(a