<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
    <channel>
        <title>Record</title>
        <link>https://velog.io/</link>
        <description>시작</description>
        <lastBuildDate>Sun, 14 Nov 2021 02:25:12 GMT</lastBuildDate>
        <docs>https://validator.w3.org/feed/docs/rss2.html</docs>
        <generator>https://github.com/jpmonette/feed</generator>
        <image>
            <title>Record</title>
            <url>https://images.velog.io/images/jess_j/profile/ee9b6bae-8644-4630-aa6d-526a9c69f843/e129212cc2c25ee1fbb98d5f967568de.jpg</url>
            <link>https://velog.io/</link>
        </image>
        <copyright>Copyright (C) 2019. Record. All rights reserved.</copyright>
        <atom:link href="https://v2.velog.io/rss/jess_j" rel="self" type="application/rss+xml"/>
        <item>
            <title><![CDATA[Javascript]]></title>
            <link>https://velog.io/@jess_j/Javascript</link>
            <guid>https://velog.io/@jess_j/Javascript</guid>
            <pubDate>Sun, 14 Nov 2021 02:25:12 GMT</pubDate>
            <description><![CDATA[<h2 id="javascript">JAVASCRIPT</h2>
<h3 id="자바스크립트">자바스크립트</h3>
<ul>
<li>객체 기반의 스크립트 언어</li>
<li>사용자와 다양한 상호작용!</li>
<li>(초기)웹 브라우저뿐만 아니라 Node.js(서버, 백엔드 프로그램)를 통해 다양한 프로그래밍에 응용</li>
<li><blockquote>
<pre><code>언어의 범위가 시대가 지날수록 커짐</code></pre></blockquote>
</li>
<li>자바애플릿, Mocha 등  Javascript 로</li>
<li>표준안으로 채택되면서 표준화됨(ECMAScript)</li>
<li>Ajax(화면을 깜빡이지 않고 새로운 데이터로 이동하거나 나타내는 효과)의 출현으로 웹 개발에 필수적인 프로그래밍 언어로 사용하게 됨</li>
</ul>
<h3 id="자바스크립트-원리">자바스크립트 원리</h3>
<ol>
<li>웹브라우저에서 사이트 접속</li>
<li>지정 서버로 요청</li>
<li>서버에서 알맞은 적절한 HTML CSS(데이터를 나타내는 표현 언어) JS(로직을 나타내는 언어, 프로그래밍 언어)등을 보냄</li>
<li>웹브라우저는 이를 해석해서 화면에 그림(해석하는 인터프리터가 JS에 내장됨)</li>
</ol>
<h3 id="자바스크립트-자료형data-type">자바스크립트 자료형(Data Type)</h3>
<ul>
<li>자료형 : 프로그래밍 언어가 다룰 수 있는 데이터의 형태 의미</li>
<li>원시형태(Primitive) : 숫자, 문자열, 불리언, undefined(정의되지 않음), null</li>
<li>객체형태(Object) : 시간(Date), 배열(Array), 객체(Object) 등  자바스크립트는 객체 기반의 언어. 복잡한 구조, 함수의 구조 등은 객체로 이루어져 있어서 중요함</li>
</ul>
<h3 id="리티럴literal-선언">리티럴(Literal) 선언</h3>
<p>코드 상에서 값을 직접 명시에서 선언하거나 할당하는 것으로 자료형에 따라 리터럴 선언 문법이 다름</p>
<ul>
<li>“” : 문자열 선언</li>
<li>일반 숫자 : 숫자열 선언</li>
</ul>
<h3 id="원시-자료형">원시 자료형</h3>
<ul>
<li>Number : 정수, 실수 등</li>
<li>String : “” 문자들의 나열(문자의 series)</li>
<li>Boolean : 참/거짓 true, false  논리를 나타내는 자료형</li>
<li>Undefined : 값이 정해지지 않았다는 것을 표현</li>
<li>Null : 아무것도 없음을 표현하는 자료형(0도 아닌 void한 개념)</li>
</ul>
<h3 id="변수">변수</h3>
<ul>
<li>프로그램은 다양한 조건과 환경에 따라 달라지는 값을 입력 받아 정해진 동작을 수행</li>
<li>약어인 ‘var’ 키워드와 변수의 이름을 선언<ul>
<li>Var x;</li>
</ul>
</li>
<li>변수의 값을 할당/대입 : 선언된 변수명에 대입 연산자 =를 사용해 값을 대입<ul>
<li>X = 40; or x = ‘철수’; </li>
<li>Var x = 40; -&gt; 선언과 동시에 대입 가능</li>
<li>Undefined? -&gt; var x; (아무것도 선언되지 않고 결정되지 않은 상태)</li>
</ul>
</li>
<li>변수 이름 규칙<ul>
<li>하이픈(-) 사용 불가</li>
<li>첫 글자로 숫자 사용 불가</li>
<li>띄어쓰기 사용 불가</li>
<li>자바스크립트 예약어 사용 불가(if, while, var.. 등)</li>
</ul>
</li>
<li>산술 연산자<ul>
<li>덧셈 : +, ++(단항연산)</li>
<li>뺄셈 : -, --(단항연산)</li>
<li>곱셈 : *</li>
<li>나눗셈 : /</li>
<li>나머지 : %</li>
<li>복합 연산 형태 : +=, -=, *=, /=</li>
</ul>
</li>
</ul>
<h3 id="실습--사칙연산과-변수-다루기-3-4">실습 : 사칙연산과 변수 다루기 (3-4)</h3>
<ul>
<li>주요 명령어</li>
<li>console.log(출력할 데이터 변수나 값) ; 자주 쓰이므로 기억할 것 - 개발자용</li>
<li>alert(내용) ; 사용자에게 안내장을 띄우는 용도</li>
<li>prompt(내용) ; 안내장에 값을 입력할 수 있는 대화창을 띄움</li>
</ul>
<pre><code class="language-html">&lt;script&gt;

    console.log(&#39;안녕하세요&#39;); // 개발자용 
    //alert(&#39;안녕하십니까?&#39;); // 사용자에게 안내장을 보여주는 용도
    //prompt(&#39;입력하는 용도!&#39;); // 입력값을 받는 안내장

    var printMessage = &#39;계산 결과는?&#39;;
    var number = 10;
    var number2 = 5;
    var numberFloat = 0.45;

    var result; // undefined 변수

    // 각 변수 값을 출력
    console.log(&#39;각 변수 안의 값들 출력&#39;);
    console.log(number);
    console.log(number2);
    console.log(numberFloat);

    console.log(result);

    /* 주석(여러
    줄 가능) */
    // 주석(한줄 가능)

    // 사칙 연산
    console.log(&#39;사칙연산,&#39; + printMessage);
    result = number + numberFloat;
    console.log(result);
    console.log(number + numberFloat);
    console.log(printMessage);
    console.log(number - numberFloat);
    console.log(number * number2);
    console.log(number / number2);

    // 사칙 연산의 단순한 연산으로는 변수 값이 바뀌지 않음
    console.log(&#39;변수 값 변화 확인,&#39; + printMessage);
    console.log(number);
    console.log(number2);
    console.log(numberFloat);

    // 변환 되었음
    console.log(printMessage);
    console.log(result);

    // 복합연산 : 사칙 연산 가능
    console.log(&#39;복합연산,&#39; + printMessage);
    numberFloat += number;
    console.log(numberFloat);

    // 단항연산 : 덧셈과 뺄셈만 가능
    number ++; // number = number + 1 과 같음
    console.log(number);
    number --;
    console.log(number);

    console.log(&quot;나머지 연산, &quot; + printMessage);
    console.log(number2 % number);
    console.log(number % number2);
&lt;/script&gt;
</code></pre>
<ul>
<li>콘솔 캡쳐
<img src="https://images.velog.io/images/jess_j/post/72bec5f2-580c-47ee-9b49-6f597d6355e9/image.png" alt=""></li>
</ul>
<h3 id="값을-비교하기3-5">값을 비교하기(3-5)</h3>
<p><strong>비교 연산자 : 참 또는 거짓이 결과 값으로 나옴</strong></p>
<ul>
<li>동등 == (값이 같은 것)</li>
<li>부등 !=</li>
<li>일치 === (데이터타입까지 같은 것)</li>
<li>&gt;, &gt;=, &lt;, &lt;=</li>
</ul>
<p><strong>논리 연산자 : 참 또는 거짓(Boolean)을 연산함. 비교문을 조합해 복잡한 조건문을 만듦</strong></p>
<ul>
<li>AND : &amp;&amp;</li>
<li>OR : ||</li>
<li>NOT : !</li>
</ul>
<p><strong>이항 연산자</strong></p>
<ul>
<li>좌변 / 우변 으로 나뉨</li>
</ul>
<p><strong>기타 연산자</strong></p>
<ul>
<li><code>삼항 연산자</code> : 세개의 항을 씀 (명제) ? 참일경우 리턴값; 거짓일 경우 리턴값;</li>
<li>단항 연산자(delete, typeof)</li>
<li>비트 연산자(&amp;, |, ^, ~, &lt;&lt;, &gt;&gt;, &gt;&gt;&gt;) : 이진수 연산할 때 사용</li>
</ul>
<h3 id="조건문-사용하기3-6">조건문 사용하기(3-6)</h3>
<ul>
<li>조건의 참/거짓 여부에 따라 원하는 코드를 실행</li>
<li>비교연산자나 논리연산자의 조합으로 작성할 수 있음</li>
</ul>
<ol>
<li>if문</li>
<li>switch문</li>
<li>삼항 연산자</li>
</ol>
<ol>
<li>if문<pre><code class="language-javascript">if (조건식) {
 실행코드
}else if (조건식) {
 실행코드
}else{
 실행코드
}</code></pre>
</li>
</ol>
<ul>
<li>조건식 : 비교식 논리식 함수(리턴값이 boolean인)</li>
<li>{} : codeblcok</li>
<li>조건 내의 실행 구문(블록)이 한줄 코드라면 중괄호 생략이 가능</li>
</ul>
<ol start="2">
<li>switch문<pre><code class="language-javascript">switch(표현식){
case 값1:
 표현식 ==값1 일때 실행코드
 break;
case 값2:
 표현식 ==값2 일때 실행코드
 break;
default:
 모든 조건에 속하지 않을 때의 실행 코드</code></pre>
</li>
</ol>
<h3 id="실습--퀴즈게임-만들기-3-7">실습 : 퀴즈게임 만들기 (3-7)</h3>
<pre><code class="language-javascript">&lt;script&gt;
    var solution = 10;
    var input = prompt(&#39;수를 맞춰주세요&#39;);


    // 중첩문

    if (input &gt; solution + 2) {
        alert(&#39;해답이 당신이 입력한 값보다 더 작습니다.&#39;)
    }else if (input &lt; solution - 2){
        alert(&#39;해답이 당신이 입력한 값보다 더 큽니다&#39;)
    }else {
        // 8~12 사이의 값
        if(input == solution){
            alert(&#39;정답입니다!&#39;)
        }  else{
            // 8 9 11 12
            alert(&#39;정답과 가깝습니다!&#39;)
        }
    }


    // switch의 경우

    var gender = prompt(&#39;성별을 입력해주세요.&#39;);
    switch(gender){
        case &#39;여자&#39;:
            alert(&#39;Female&#39;);
            break;
        case &#39;남자&#39;:
            alert(&#39;male&#39;);
            break;
        case &#39;기타&#39;:
            alert(&#39;Other&#39;);
            break;
        default:
            alert(&#39;남자, 여자, 기타 중 하나를 입력해주세요.&#39;);
    }
&lt;/script&gt;
</code></pre>
<h3 id="반복문-사용하기3-8">반복문 사용하기(3-8)</h3>
<ol>
<li>for 문</li>
</ol>
<ul>
<li>조건식을 만족하는 한 계속해서 코드 반복. </li>
<li>매 반복 실행(iteration)마다 마지막에 증감식을 실행</li>
</ul>
<p>for(초기식;중간식;증감식){
    반복 실행될 코드
}</p>
<ol start="2">
<li>while 문</li>
</ol>
<ul>
<li>조건식을 만족하는 한 계속해서 코드를 반복 실행함(무한 루프 주의)</li>
</ul>
<h3 id="실습--피보나치-수열-출력하기-3-9">실습 : 피보나치 수열 출력하기 (3-9)</h3>
<ul>
<li><p>for문 활용</p>
<pre><code class="language-javascript">&lt;script&gt;
  /// 1 1 2 3 5 8 13 21
  // 수열 n = 수열n-2번째 + 수열 n-1 번째

  var n_2 = 1;
  var n_1 = 1;

  console.log(n_2);
  console.log(n_1);

  for (var i = 0; i &lt; 100 ; i ++){
      var n = n_2 + n_1;
      console.log(n);
      n_2 = n_1;
      n_1 = n;
  }
&lt;/script&gt;</code></pre>
</li>
<li><p>결과 (console창)
<img src="https://images.velog.io/images/jess_j/post/25b399ca-727a-48df-8de2-5aeb04fcda52/image.png" alt=""></p>
</li>
</ul>
<ul>
<li><p>while문 활용</p>
<pre><code class="language-html">&lt;script&gt;
  /// 1 1 2 3 5 8 13 21
  // 수열 n = 수열n-2번째 + 수열 n-1 번째

  // 100회차 까지만 출력
  var n_2 = 1;
  var n_1 = 1;

  console.log(n_2);
  console.log(n_1);

  var i = 0;
  while (n_1 &lt; 10000) {
      var n = n_2 + n_1;
      console.log(n);
      n_2 = n_1;
      n_1 = n;
  }
&lt;/script&gt;</code></pre>
</li>
<li><p>결과(console창)
<img src="https://images.velog.io/images/jess_j/post/6b8a7ff4-854d-41f0-9b47-e509747d28d5/image.png" alt=""></p>
</li>
</ul>
<p>-&gt; for문과 달리 n_1이 10000을 넘는 순간 반복이 정지됨</p>
<h3 id="배열-사용하기">배열 사용하기</h3>
<h3 id="객체-사용하기">객체 사용하기</h3>
<h3 id="실습--설문조사-만들기">실습 : 설문조사 만들기</h3>
<h3 id="함수-선언하기">함수 선언하기</h3>
]]></description>
        </item>
        <item>
            <title><![CDATA[Tensorflow.js]]></title>
            <link>https://velog.io/@jess_j/Tensorflow-JavaScript</link>
            <guid>https://velog.io/@jess_j/Tensorflow-JavaScript</guid>
            <pubDate>Mon, 01 Nov 2021 12:57:50 GMT</pubDate>
            <description><![CDATA[<h1 id="tensorflowjavascript">Tensorflow(JavaScript)</h1>
<ul>
<li><p>머신러닝 지도학습의 회귀(regression) </p>
</li>
<li><p>Neural Network 사용 </p>
</li>
<li><p>라이브러리 &#39;텐서플로우&#39; 의 종류</p>
<ul>
<li>TensorFlow Python</li>
<li><strong>TensorFlow JavaScript</strong></li>
<li><blockquote>
<p>Web browser</p>
</blockquote>
</li>
<li><blockquote>
<p>Node.js 에서 사용할 수 있음</p>
</blockquote>
</li>
</ul>
</li>
</ul>
<h2 id="1-지도학습의-작업순서">1. 지도학습의 작업순서</h2>
<ol>
<li>과거의 데이터를 준비한다.</li>
<li><code>모델</code>의 모양을 만든다.</li>
<li>데이터로 모델을 학습(FIT)한다.</li>
<li>모델을 이용한다.</li>
</ol>
<h2 id="2-모델">2. 모델</h2>
<ol>
<li>남이 만든 모델 이용하기</li>
<li>기존 모델 다시 학습시키기</li>
<li>자바스크립트로 직접 ML 개발하기</li>
</ol>
<h3 id="a-남이-만든-모델-이용하기">a. 남이 만든 모델 이용하기</h3>
<p><a href="https://www.tensorflow.org/js?hl=ko">https://www.tensorflow.org/js?hl=ko</a></p>
<pre><code class="language-html">&lt;!DOCTYPE html&gt;
&lt;html&gt;
    &lt;body&gt;
        &lt;!-- Load TensorFlow.js. This is required to use MobileNet. --&gt;
        /* 텐서플로우 라이브러리를 로딩하는 코드 */
&lt;script src=&quot;https://cdn.jsdelivr.net/npm/@tensorflow/tfjs@1.0.1&quot;&gt; &lt;/script&gt;
&lt;!-- Load the MobileNet model. --&gt;
&lt;script src=&quot;https://cdn.jsdelivr.net/npm/@tensorflow-models/mobilenet@1.0.0&quot;&gt; &lt;/script&gt;

&lt;!-- Replace this with your image. Make sure CORS settings allow reading the image! --&gt;
&lt;img id=&quot;img&quot; src=&quot;cat.jpg&quot;&gt;&lt;/img&gt;

&lt;!-- Place your code in the script tag below. You can also use an external .js file --&gt;
&lt;script&gt;
  // Notice there is no &#39;import&#39; statement. &#39;mobilenet&#39; and &#39;tf&#39; is
  // available on the index-page because of the script tag above.

  // 이미지 태그를 img 태그 담기
  const img = document.getElementById(&#39;img&#39;);

  // Load the model. Load 함수 호출
  mobilenet.load().then(model =&gt; {
    // Classify the image. img 태그를 classify 함수로 학습
    model.classify(img).then(predictions =&gt; {
      console.log(&#39;Predictions: &#39;);
      console.log(predictions);
    });
  });
&lt;/script&gt;
    &lt;/body&gt;
&lt;/html&gt;</code></pre>
<h3 id="b-내가-만든-모델-이용하기">b. 내가 만든 모델 이용하기</h3>
<ol>
<li><p>Tensorflow.js 웹 브라우저 스크립트 태그 복사
<a href="https://www.tensorflow.org/js/tutorials/setup?hl=ko#%EC%8A%A4%ED%81%AC%EB%A6%BD%ED%8A%B8_%ED%83%9C%EA%B7%B8%EB%A5%BC_%ED%86%B5%ED%95%9C_%EC%82%AC%EC%9A%A9%EB%B2%95">https://www.tensorflow.org/js/tutorials/setup?hl=ko#%EC%8A%A4%ED%81%AC%EB%A6%BD%ED%8A%B8_%ED%83%9C%EA%B7%B8%EB%A5%BC_%ED%86%B5%ED%95%9C_%EC%82%AC%EC%9A%A9%EB%B2%95</a> 
<code>&lt;script src=&quot;https://cdn.jsdelivr.net/npm/@tensorflow/tfjs@2.0.0/dist/tf.min.js&quot;&gt;&lt;/script&gt;</code> </p>
</li>
<li><p>에디터에 html 파일 생성</p>
</li>
<li><head></head> 태그 안에 복사-붙여넣기</li>
<li><p>5.3.html</p>
<pre><code class="language-html">&lt;!DOCTYPE html&gt;
&lt;html&gt;
</code></pre>
</li>
</ol>
<head>
    <title>TensorFlow.js Tutorial - lemon</title>

<pre><code>&lt;!-- Import TensorFlow.js --&gt;
&lt;script src=&quot;https://cdn.jsdelivr.net/npm/@tensorflow/tfjs@1.0.0/dist/tf.min.js&quot;&gt;&lt;/script&gt;</code></pre></head>

<body>
    <script>
        // 1. 과거의 데이터를 준비 
        var 온도 = [20,21,22,23]; // 독립변수
        var 판매량 = [40,42,44,46]; // 종속변수
        var 원인 = tf.tensor(온도); // tensor라는 형태로 변환해주는 과정 필요
        var 결과 = tf.tensor(판매량);

<pre><code>    // 2. 모델의 모양 만들기 : 데이터의 형식에 따라서 들어가는 숫자를 조정
    var X = tf.input({ shape: [1] }); // 입력 값 속성이 몇개인지
    var Y = tf.layers.dense({ units: 1 }).apply(X); // 결과 값 속성이 몇개인지
    var model = tf.model({ inputs: X, outputs: Y }); // 모델을 정의
    var compileParam = { optimizer: tf.train.adam(), loss: tf.losses.meanSquaredError }  // 입력값 ; optimizer(좀 더 효율적으로 모델을 만드는 것), loss(얼마나 모델이 잘 만들어졌는지 측정하기 위해 사용하는 것)
    model.compile(compileParam);

    // 3. 데이터로 모델을 학습(fit, trainning, running..)
    var fitParam = { epochs: 100}  // epoch : 학습 횟수 지정
    // var fitParam = { epochs: 100, callbacks:{onEpochEnd:function(epoch, logs){console.log(&#39;epoch&#39;, epoch, logs);}}} // loss 추가 예제
    model.fit(원인, 결과, fitParam).then(function (result) {

        //4. 모델을 이용(학습이 끝났을 때 시행할 동작 정의)
        // 4.1 기존의 데이터를 이용
        var 예측한결과 = model.predict(원인); // 중요!!
        예측한결과.print();

     });  

    // 4.2 새로운 데이터를 이용
    var 다음주온도 = [15,16,17, 18, 19]
    var 다음주원인 = tf.tensor(다음주온도);
    var 다음주결과 = model.predict(다음주원인);
    다음주결과.print();
&lt;/script&gt;</code></pre></body>

</html>
```

<h2 id="3-정확도-측정">3. 정확도 측정</h2>
<ul>
<li>모델이 얼마나 잘 예측하는가를 의미하는 정확도 확인하기<ul>
<li>loss</li>
<li>Mean Square Error</li>
<li>Root Mean Square Error</li>
</ul>
</li>
</ul>
<pre><code class="language-html">// 데이터로 모델 학습하는 부분 
var fitParam = { 
    epochs: 100,
    callbacks:{
        onEpochEnd: # Epoch가 끝날 때 마다 콘솔창에 결과 출력
            function(epoch, logs){
                console.log(&#39;epoch&#39;, epoch, logs, &#39;RMSE=&gt;&#39;, logs.sqrt(logs.loss));
                }
            }
    } // loss 추가 예제
    model.fit(원인, 결과, fitParam).then(function (result) {

            //4. 모델을 이용(학습이 끝났을 때 시행할 동작 정의)
            // 4.1 기존의 데이터를 이용
            var 예측한결과 = model.predict(원인); // 중요!!
            예측한결과.print();

         });  
</code></pre>
<ul>
<li><p>오차값 : 0에 가까울 수록 모델 학습이 뛰어남을 나타냄 </p>
</li>
<li><p>*<em>loss *</em></p>
</li>
<li><p><strong>Mean Squared Error(MSE)</strong> : 평균 제곱 오차 (양수화)
각 오차를 제곱하여 합한 후 평균을 구함</p>
</li>
<li><p><strong>Root Mean Squared Error(RMSE)</strong> : 평균 제곱근 오차 (양수화, 실제로 얼마나 오차나는지 체감 가능)
평균 제곱 오차에 제곱근을 취한 값</p>
</li>
</ul>
<pre><code class="language-html"> var compileParam = {
    optimizer: tf.train.adam(),
    loss: tf.losses.meanSquaredError  // MSE로 설정
} </code></pre>
<h2 id="4-모델의-정체">4. 모델의 정체</h2>
<ul>
<li><p>y = a*x + b
a : 가중치(weight)
b : 편향(bias)</p>
</li>
<li><p>텐서에서 값 가져오기</p>
<pre><code class="language-html">const a = tf.tensor([[1, 2], [3, 4]]);
// Returns the multi dimensional array of values.
console.log(a.arraySync());
// Returns the flattened data that backs the tensor.
console.log(a.dataSync());</code></pre>
</li>
</ul>
<h2 id="5-모델의-저장과-불러오기">5. 모델의 저장과 불러오기</h2>
<p><a href="https://www.tensorflow.org/js/guide/save_load?hl=ko">https://www.tensorflow.org/js/guide/save_load?hl=ko</a> </p>
<h2 id="6-여러개의-변수">6. 여러개의 변수</h2>
<ul>
<li><p>y = a*x + b
a : 가중치(weight) ex) x1 x2 x3 ... xn
b : 편향(bias) </p>
</li>
<li><p>Boston Housing Price 예제</p>
<pre><code class="language-javascript">&lt;!DOCTYPE html&gt;
&lt;html&gt;
</code></pre>
</li>
</ul>
<head>
    <title>TensorFlow.js Tutorial - boston housing </title>

<pre><code>&lt;!-- Import TensorFlow.js --&gt;
&lt;script src=&quot;https://cdn.jsdelivr.net/npm/@tensorflow/tfjs@1.0.0/dist/tf.min.js&quot;&gt;&lt;/script&gt;
&lt;script src=&quot;10.3.js&quot;&gt;&lt;/script&gt;</code></pre></head>

<body>
    <script>

<pre><code>    var 보스톤_원인 = [
        [0.00632,18,2.31,0,0.538,6.575,65.2,4.09,1,296,15.3,396.9,4.98],
        [0.02731,0,7.07,0,0.469,6.421,78.9,4.9671,2,242,17.8,396.9,9.14]
    ];
    var 보스톤_결과 = [
        [24], 
        [21.6]
    ];


    // 1. 과거의 데이터를 준비합니다. 
    var 원인 = tf.tensor(보스톤_원인);
    var 결과 = tf.tensor(보스톤_결과);

    // 2. 모델의 모양을 만듭니다. 
    var X = tf.input({ shape: [13] });
    var Y = tf.layers.dense({ units: 1 }).apply(X);
    var model = tf.model({ inputs: X, outputs: Y });
    var compileParam = { optimizer: tf.train.adam(), loss: tf.losses.meanSquaredError }
    model.compile(compileParam);

    // 3. 데이터로 모델을 학습시킵니다. </code></pre><p>//      var fitParam = {epochs: 100}
        var fitParam = { 
          epochs: 100, 
          callbacks:{
            onEpochEnd:
              function(epoch, logs){
                console.log(&#39;epoch&#39;, epoch, logs, &#39;RMSE=&gt;&#39;, Math.sqrt(logs.loss));
              }
          }
        } // loss 추가 예제
        model.fit(원인, 결과, fitParam).then(function (result) {</p>
<pre><code>        // 4. 모델을 이용합니다. 
        // 4.1 기존의 데이터를 이용
        var 예측한결과 = model.predict(원인);
        예측한결과.print();

    });  

    // 4.2 새로운 데이터를 이용
    var 다음주온도 = [15,16,17,18,19]
    var 다음주원인 = tf.tensor(다음주온도);
    var 다음주결과 = model.predict(다음주원인);
    다음주결과.print();
&lt;/script&gt;</code></pre></body>

</html>
```

<ul>
<li>복수개의 독립변수가 <strong>복수개의 종속변수</strong>에 영향을 미치는 경우<pre><code class="language-javascript">&lt;!DOCTYPE html&gt;
&lt;html&gt;
</code></pre>
</li>
</ul>
<head>
    <title>TensorFlow.js Tutorial - boston housing</title>

<pre><code>&lt;!-- Import TensorFlow.js --&gt;
&lt;script src=&quot;https://cdn.jsdelivr.net/npm/@tensorflow/tfjs@1.0.0/dist/tf.min.js&quot;&gt;&lt;/script&gt;
&lt;script src=&quot;10.4.js&quot;&gt;&lt;/script&gt;</code></pre></head>

<body>
    <script>

<pre><code>    // 1. 과거의 데이터를 준비합니다. 
    var 원인 = tf.tensor(보스톤_원인);
    var 결과 = tf.tensor(보스톤_결과);

    // 2. 모델의 모양을 만듭니다. ** 변경된 부분 ** 
    var X = tf.input({ shape: [12] });
    var Y = tf.layers.dense({ units: 2 }).apply(X);
    var model = tf.model({ inputs: X, outputs: Y });
    var compileParam = { optimizer: tf.train.adam(), loss: tf.losses.meanSquaredError }
    model.compile(compileParam);

    // 3. 데이터로 모델을 학습시킵니다. </code></pre><p>//         var fitParam = {epochs: 100}
        var fitParam = { 
          epochs: 100, 
          callbacks:{
            onEpochEnd:
              function(epoch, logs){
                console.log(&#39;epoch&#39;, epoch, logs, &#39;RMSE=&gt;&#39;, Math.sqrt(logs.loss));
              }
          }
        } // loss 추가 예제
        model.fit(원인, 결과, fitParam).then(function (result) {</p>
<pre><code>        // 4. 모델을 이용합니다. 
        // 4.1 기존의 데이터를 이용
        var 예측한결과 = model.predict(원인);
        예측한결과.print();

    });  

    // 4.2 새로운 데이터를 이용
    // var 다음주온도 = [15,16,17,18,19]
    // var 다음주원인 = tf.tensor(다음주온도);
    // var 다음주결과 = model.predict(다음주원인);
    // 다음주결과.print();
&lt;/script&gt;</code></pre></body>

</html>
```

<h2 id="7-tensorflowjs-vis">7. tensorflowjs-vis</h2>
<ul>
<li>tfjs github 주소 :<a href="https://github.com/tensorflow/tfjs"> https://github.com/tensorflow/tfjs </a></li>
<li>vis : visualize 해줌</li>
</ul>
<pre><code class="language-javascript">&lt;!DOCTYPE html&gt;
&lt;html&gt;

&lt;head&gt;
    &lt;title&gt;TensorFlow.js Tutorial - boston housing &lt;/title&gt;

    &lt;!-- Import TensorFlow.js --&gt;
    &lt;script src=&quot;https://cdn.jsdelivr.net/npm/@tensorflow/tfjs@1.0.0/dist/tf.min.js&quot;&gt;&lt;/script&gt;
    &lt;script src=&quot;https://cdn.jsdelivr.net/npm/@tensorflow/tfjs-vis&quot;&gt;&lt;/script&gt;
    &lt;script src=&quot;10.3.js&quot;&gt;&lt;/script&gt;
&lt;/head&gt;

&lt;body&gt;
    &lt;script&gt;
        /*
        var 보스톤_원인 = [
            [0.00632,18,2.31,0,0.538,6.575,65.2,4.09,1,296,15.3,396.9,4.98],
            [0.02731,0,7.07,0,0.469,6.421,78.9,4.9671,2,242,17.8,396.9,9.14]
        ];
        var 보스톤_결과 = [
            [24], 
            [21.6]
        ];
        */

        // 1. 과거의 데이터를 준비합니다. 
        var 원인 = tf.tensor(보스톤_원인);
        var 결과 = tf.tensor(보스톤_결과);

        // 2. 모델의 모양을 만듭니다. 
        var X = tf.input({ shape: [13] });
        var Y = tf.layers.dense({ units: 1 }).apply(X);
        var model = tf.model({ inputs: X, outputs: Y });
        var compileParam = { optimizer: tf.train.adam(), loss: tf.losses.meanSquaredError }
        model.compile(compileParam);
        tfvis.show.modelSummary({name:&#39;요약&#39;, tab:&#39;모델&#39;}, model);

        // 3. 데이터로 모델을 학습시킵니다. 
//         var fitParam = {epochs: 100}
        var _history = [];
        var fitParam = { 
          epochs: 100, 
          callbacks:{
            onEpochEnd:
              function(epoch, logs){
                console.log(&#39;epoch&#39;, epoch, logs, &#39;RMSE=&gt;&#39;, Math.sqrt(logs.loss));
                _history.push(logs);
                tfvis.show.history({name:&#39;loss&#39;, tab:&#39;역사&#39;}, _history, [&#39;loss&#39;]);
              }
          }
        } // loss 추가 예제
        model.fit(원인, 결과, fitParam).then(function (result) {

            // 4. 모델을 이용합니다. 
            // 4.1 기존의 데이터를 이용
            var 예측한결과 = model.predict(원인);
            예측한결과.print();

        });  

        // 4.2 새로운 데이터를 이용
        // var 다음주온도 = [15,16,17,18,19]
        // var 다음주원인 = tf.tensor(다음주온도);
        // var 다음주결과 = model.predict(다음주원인);
        // 다음주결과.print();
    &lt;/script&gt;
&lt;/body&gt;

&lt;/html&gt;</code></pre>
<h2 id="8-딥러닝">8. 딥러닝</h2>
<ul>
<li>최적의 가중치를 찾음
<img src="https://images.velog.io/images/jess_j/post/cd352b67-fdcd-4ad9-9a31-617ca2bd24a5/image.png" alt=""> </li>
<li>적당한 규모의 hidden layer를 찾는 것이 중요 : 보통 1개로 충분하고 경과를 확인후 추가</li>
<li>히든 레이어를 추가하는 예제<pre><code class="language-javascript">&lt;!DOCTYPE html&gt;
&lt;html&gt;
</code></pre>
</li>
</ul>
<head>
    <title>TensorFlow.js Tutorial - boston housing </title>

<pre><code>&lt;!-- Import TensorFlow.js --&gt;
&lt;script src=&quot;https://cdn.jsdelivr.net/npm/@tensorflow/tfjs@1.0.0/dist/tf.min.js&quot;&gt;&lt;/script&gt;
&lt;script src=&quot;https://cdn.jsdelivr.net/npm/@tensorflow/tfjs-vis&quot;&gt;&lt;/script&gt;
&lt;script src=&quot;10.3.js&quot;&gt;&lt;/script&gt;</code></pre></head>

<body>
    <script>
        /*
        var 보스톤_원인 = [
            [0.00632,18,2.31,0,0.538,6.575,65.2,4.09,1,296,15.3,396.9,4.98],
            [0.02731,0,7.07,0,0.469,6.421,78.9,4.9671,2,242,17.8,396.9,9.14]
        ];
        var 보스톤_결과 = [
            [24], 
            [21.6]
        ];
        */

<pre><code>    // 1. 과거의 데이터를 준비합니다. 
    var 원인 = tf.tensor(보스톤_원인);
    var 결과 = tf.tensor(보스톤_결과);

    // 2. &lt;&lt;&lt;&lt;&lt;&lt;&lt;히든 레이어 추가 part&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt; + activation function 지정
    var X = tf.input({ shape: [13] });
    var H1 = tf.layers.dense({ units: 13, activation:&#39;relu&#39; }).apply(X);
    var H2 = tf.layers.dense({ units: 13, activation:&#39;relu&#39; }).apply(H1);
    var Y = tf.layers.dense({ units: 1 }).apply(H2);
    var model = tf.model({ inputs: X, outputs: Y });
    var compileParam = { optimizer: tf.train.adam(), loss: tf.losses.meanSquaredError }
    model.compile(compileParam);
    tfvis.show.modelSummary({name:&#39;요약&#39;, tab:&#39;모델&#39;}, model);

    // 3. 데이터로 모델을 학습시킵니다. </code></pre><p>//         var fitParam = {epochs: 100}
        var _history = [];
        var fitParam = { 
          epochs: 100, 
          callbacks:{
            onEpochEnd:
              function(epoch, logs){
                console.log(&#39;epoch&#39;, epoch, logs, &#39;RMSE=&gt;&#39;, Math.sqrt(logs.loss));
                _history.push(logs);
                tfvis.show.history({name:&#39;loss&#39;, tab:&#39;역사&#39;}, _history, [&#39;loss&#39;]);
              }
          }
        } // loss 추가 예제
        model.fit(원인, 결과, fitParam).then(function (result) {</p>
<pre><code>        // 4. 모델을 이용합니다. 
        // 4.1 기존의 데이터를 이용
        var 예측한결과 = model.predict(원인);
        예측한결과.print();

    });  

    // 4.2 새로운 데이터를 이용
    // var 다음주온도 = [15,16,17,18,19]
    // var 다음주원인 = tf.tensor(다음주온도);
    // var 다음주결과 = model.predict(다음주원인);
    // 다음주결과.print();
&lt;/script&gt;</code></pre></body>

</html>
```

<hr>
<h1 id="tensorflowjs-classification-분류-작업-시키기">TensorFlow.js Classification (분류 작업 시키기)</h1>
<h2 id="1-classification">1. Classification</h2>
<ul>
<li>TensorFlor.js와 데이터를 쉽게 다룰 수 있도록 돕는 &#39;Danfo.js&#39;를 사용</li>
<li>前에 배운 것 - Regression : 회귀</li>
<li>종속변수가 숫자가 아니라 라벨이 되어 있을 때 -&gt; Classification(분류)를 사용</li>
<li>과정
1) 과거의 데이터 필요
2) 모델 모양 만들고
3) 모델 학습을 시키는 것
차이점은 ? 숫자가 아니라 문자가 결과라는 것! </li>
<li>-&gt; How ? 문자를 : 숫자에 대응시키면 됨.
주의 : 숫자의 크기는 의미가 없음. just 라벨임.</li>
</ul>
<h2 id="2-데이터-준비하기-학습하기">2. 데이터 준비하기, 학습하기</h2>
<ul>
<li>인터넷에 있는 raw 데이터에서 결과 값을 하나하나 라벨 -&gt; 숫자로 매칭하는 과정은 매우 번거로움</li>
<li>이럴 때 쓸 수 있는 도구가 바로 &#39;Danfo.js&#39;임!</li>
<li><script src="https://cdn.jsdelivr.net/npm/danfojs@0.1.2/dist/index.min.js"></script> <- 이 코드를 head에 넣어 사용함


</li>
</ul>
<pre><code class="language-javascript">&lt;html&gt;
&lt;head&gt;
    &lt;!-- 버전에 따라서 예제가 동작하지 않는 경우가 있습니다. 아래 버전을 권장합니다. --&gt;
    &lt;script src=&quot;https://cdn.jsdelivr.net/npm/danfojs@0.1.2/dist/index.min.js&quot;&gt;&lt;/script&gt;
    &lt;script src=&quot;https://cdn.jsdelivr.net/npm/@tensorflow/tfjs@2.4.0/dist/tf.min.js&quot;&gt;&lt;/script&gt;
    &lt;script src=&quot;https://cdn.jsdelivr.net/npm/@tensorflow/tfjs-vis&quot;&gt;&lt;/script&gt;
&lt;/head&gt;
&lt;body&gt;
&lt;script&gt;

// 여기서 dfd는 danfo.js의 모듈의 이름  
dfd.read_csv(&#39;https://raw.githubusercontent.com/blackdew/tensorflow1/master/csv/iris.csv&#39;).then(function(data){
        console.log(data); // 데이터에 무엇이 들어있는지 확인
        data.print(); // 표로 출력할 수 있는 기능 
        독립변수 = data.loc({columns:[&#39;꽃잎길이&#39;,&#39;꽃잎폭&#39;,&#39;꽃받침길이&#39;,&#39;꽃받침폭&#39;]});

        독립변수.print();
        var encoder = new dfd.OneHotEncoder(); // 원핫인코딩 제공!!!!
        종속변수 = encoder.fit(data[&#39;품종&#39;]); // 품종 column의 정보를 원핫인코딩함
        data[&#39;품종&#39;].print();
        종속변수.print(); // 원핫인코딩한 결과 표로 출력

        var X = tf.input({ shape: [4]}); // 4개의 입력
        var H = tf.layers.dense({ units: 4, activation:&#39;relu&#39;}).apply(X);

        var Y = tf.layers.dense({ units: 3}).apply(H); // 출력층, 원핫인코딩으로 컬럼이 3개가 되었으므로 &#39;3&#39;
        var Y = tf.layers.dense({ units: 3, activation:&#39;softmax&#39;}).apply(H);

        model = tf.model({ inputs: X, outputs: Y }); // 모델 제작

        var compileParam = { optimizer: tf.train.adam(), loss: tf.losses.meanSquaredError, metrics:[&#39;accuracy&#39;] } // 회귀
        var compileParam = { optimizer: tf.train.adam(), loss: &#39;categoricalCrossentropy&#39;} // 분류

        model.compile(compileParam);

        tfvis.show.modelSummary({name:&#39;요약&#39;, tab:&#39;모델&#39;}, model);

    //     // 3. 데이터로 모델을 학습시킵니다. 
        _history = [];
        var fitParam = { 
          epochs: 100, // 100번 학습
          callbacks:{
            onEpochEnd: // 학습 상태 확인
              function(epoch, logs){ 
                console.log(&#39;epoch&#39;, epoch, logs, &#39;RMSE=&gt;&#39;, Math.sqrt(logs.loss));
                _history.push(logs); // 보기 좋게 그래프로 표시
                tfvis.show.history({name:&#39;loss&#39;, tab:&#39;역사&#39;}, _history, [&#39;loss&#39;]);
                tfvis.show.history({name:&#39;accuracy&#39;, tab:&#39;역사&#39;}, _history, [&#39;acc&#39;]); // 정확도에 대한 그래프 표현
              }
          }
        } 

        model.fit(독립변수.tensor, 종속변수.tensor, fitParam).then(function (result) { // danfo에서 제공하는 tensor로 DataFrame 사용 
            // 4. 모델을 이용합니다. 
            // 4.1 기존의 데이터를 이용
            예측한결과 = new dfd.DataFrame(model.predict(독립변수.tensor)); //danfo.js의 DataFrame으로 가져옴
            예측한결과.print();
            종속변수.print();

        });  
    })
&lt;/script&gt;
&lt;/body&gt;
&lt;/html&gt;</code></pre>
<h2 id="3-분류스러운-학습">3. 분류스러운 학습</h2>
<ul>
<li>컴퓨터에서는 확률을 <code>0과 1 사이의 숫자</code>로 바꿔야 사용하기 쉬움</li>
<li>어떻게? <strong>softmax라는 activationFunction</strong>을 사용해서 바꿈
<img src="https://images.velog.io/images/jess_j/post/3d4810d7-ab29-454c-a7ac-223cac5600fe/image.png" alt=""></li>
<li>분류에서는 MSE가 아닌 loss로 categoricalCrossentropy를 사용함</li>
<li>accuracy는 0~1 사이의 값. 1에 가까울 수록 높은 정확도를 가짐</li>
</ul>
]]></description>
        </item>
        <item>
            <title><![CDATA[Tensorflow (python)]]></title>
            <link>https://velog.io/@jess_j/Tensorflow-python</link>
            <guid>https://velog.io/@jess_j/Tensorflow-python</guid>
            <pubDate>Wed, 06 Oct 2021 05:28:32 GMT</pubDate>
            <description><![CDATA[<p>출처 : 생활코딩(<a href="https://opentutorials.org/course/4570">https://opentutorials.org/course/4570</a>)</p>
<h1 id="tensorflow-w-python">Tensorflow w/ python</h1>
<h2 id="오리엔테이션">오리엔테이션</h2>
<ul>
<li><p>머신 러닝 중 지도 학습 : 회귀(숫자), 분류(종류)</p>
</li>
<li><p>머신 러닝 알고리즘 예</p>
<ul>
<li>Decision Tree</li>
<li>RandomForest</li>
<li>KNN</li>
<li>SVM</li>
<li><strong>Neural Network</strong></li>
</ul>
</li>
<li><p>*<em>인공신경망 = 딥러닝 *</em></p>
</li>
<li><p>인공신경망을 깊게 쌓아서 만든 기계라는 뜻</p>
</li>
<li><p>인간의 신경을 모방한 이론</p>
</li>
</ul>
<ul>
<li>딥러닝 이론을 코딩으로 이용할 수 있도록 하는 라이브러리 예시<ul>
<li><strong>텐서 플로우</strong></li>
<li>PyTorch</li>
<li>Caffe2</li>
<li>Theano</li>
</ul>
</li>
</ul>
<h2 id="지도학습의-빅피처">지도학습의 빅피처</h2>
<ul>
<li><strong>지도 학습의 과정</strong></li>
</ul>
<ol>
<li>과거의 데이터를 준비</li>
<li>원인(독립변수)과 결과(종속변수)를 인식함 (중요!)</li>
<li>모델의 구조를 만듦</li>
<li>데이터로 모델을 학습(FIT) 한다 : 모델을 데이터에 맞게 피팅(FITTING) 한다.</li>
<li>모델 완성! 이용하기</li>
</ol>
<h2 id="판다스--표를-다루는-도구">판다스 : 표를 다루는 도구</h2>
<pre><code class="language-python">import pandas as pd

# 파일들로부터 데이터 읽어오기
파일경로 = &#39;https://raw.githubusercontent.com/blackdew/tensorflow1/master/csv/lemonade.csv&#39;
레몬에이드 = pd.read_csv(파일경로)

파일경로 = &#39;https://raw.githubusercontent.com/blackdew/tensorflow1/master/csv/boston.csv&#39;
보스턴 = pd.read_csv(파일경로)

파일경로 = &#39;https://raw.githubusercontent.com/blackdew/tensorflow1/master/csv/iris.csv&#39;
아이리스 = pd.read_csv(파일경로)

# 변수 안에 어떤 데이터가 들어있는지 확인 - 데이터 모양으로 확인하기 (행,열)
print(레몬에이드.shape)
print(보스턴.shape)
print(아이리스.shape)

# 칼럼 이름 출력
print(레몬에이드.columns)
print(보스턴.columns)
print(아이리스.columns)

# 독립변수와 종속변수를 분리하여 저장
x = 레몬에이드[[&#39;온도&#39;]]
y = 레몬에이드[[&#39;판매량&#39;]]
print(x.shape, y.shape)

x = 보스턴[[&#39;crim&#39;, &#39;zn&#39;, &#39;indus&#39;, &#39;chas&#39;, &#39;nox&#39;, &#39;rm&#39;, &#39;age&#39;, &#39;dis&#39;, &#39;rad&#39;, &#39;tax&#39;,
       &#39;ptratio&#39;, &#39;b&#39;, &#39;lstat&#39;]]
y = 보스턴[[&#39;medv&#39;]]
print(x.shape, y.shape)

x = 아이리스[[&#39;꽃잎길이&#39;, &#39;꽃잎폭&#39;, &#39;꽃받침길이&#39;, &#39;꽃받침폭&#39;]]
y = 아이리스[[&#39;품종&#39;]]
print(x.shape, y.shape)

레몬에이드.head()

보스턴.head()

아이리스.head()
</code></pre>
<h2 id="딥러닝-실습">딥러닝 실습</h2>
<h3 id="첫번째-레몬에이드-판매-예측">첫번째. 레몬에이드 판매 예측</h3>
<ul>
<li>shape=[숫자] : 독립변수의 개수</li>
<li>Dense(숫자) : 종속변수의 개수</li>
<li>epochs : 전체 데이터를 몇번 반복하여 학습 시킬지를 정함</li>
</ul>
<ul>
<li><strong>Loss 손실</strong></li>
</ul>
<p><img src="https://images.velog.io/images/jess_j/post/758cf5eb-5072-4100-8a3d-c5caba5a32ba/image.png" alt=""></p>
<pre><code class="language-python">model.fit(독립, 종속, epochs = 10)</code></pre>
<ul>
<li>몇번째 반복인지 / 각 학습마다 얼마의 시간이 걸렸는지 / <strong>학습이 얼마나 진행되었는지(loss)</strong></li>
<li>그 시점에 얼마나 정답에 가까이 맞추는 정도가 높아짐</li>
<li>(예측-결과=Error)^2 의 평균 = LOSS
: 즉 0이 되면 예측 = 결과 이므로 학습이 완벽하게 된 모델이라고 할 수 있음</li>
</ul>
<p>** 코드 **</p>
<pre><code class="language-python">#라이브러리 사용
import tensorflow as tf
import pandas as pd


#데이터 준비
파일경로 = &#39;https://raw.githubusercontent.com/blackdew/tensorflow1/master/csv/lemonade.csv&#39;
data = pd.read_csv(파일경로)
data.head()

# 종속변수, 독립변수
x = data[[&#39;온도&#39;]]
y = data[[&#39;판매량&#39;]]
print(x.shape, y.shape)

#모델 만들기
X = tf.keras.layers.Input(shape=[1])
Y = tf.keras.layers.Dense(1)(X)
model = tf.keras.models.Model(X, Y)
model.compile(loss=&#39;mse&#39;)

#모델 학습
model.fit(x, y, epochs=10000, verbose=0) # 화면 출력을 off
model.fit(x, y, epochs=10) 

# 모델을 이요하기
model.predict(x)

model.predict([[15]])</code></pre>
<h3 id="두번째-보스턴-집값-예측">두번째. 보스턴 집값 예측</h3>
<ul>
<li>인공신경망에서 뉴런의 역할을 하는 것 : 만든 모형과 수식
<img src="https://images.velog.io/images/jess_j/post/e5d11c65-4ece-48d8-997e-59d082b1fc61/image.png" alt=""></li>
<li>-&gt; *<em>퍼셉트론 Perceptron *</em></li>
<li>가중치(weight) w1,w2,w3... w13</li>
<li>편향(Bias) b</li>
<li><strong>코드</strong><pre><code class="language-python"># 라이브러리 사용
import tensorflow as tf
import pandas as pd

</code></pre>
</li>
</ul>
<h1 id="과거의-데이터-준비">과거의 데이터 준비</h1>
<p>파일경로 = &#39;<a href="https://raw.githubusercontent.com/blackdew/tensorflow1/master/csv/boston.csv&#39;">https://raw.githubusercontent.com/blackdew/tensorflow1/master/csv/boston.csv&#39;</a>
보스턴 = pd.read_csv(파일경로)
보스턴.head()
print(보스턴.columns)</p>
<h1 id="모델의-구조-만듦">모델의 구조 만듦</h1>
<p>독립 = 보스턴[[&#39;crim&#39;, &#39;zn&#39;, &#39;indus&#39;, &#39;chas&#39;, &#39;nox&#39;, &#39;rm&#39;, &#39;age&#39;, &#39;dis&#39;, &#39;rad&#39;, &#39;tax&#39;,
       &#39;ptratio&#39;, &#39;b&#39;, &#39;lstat&#39;]]
종속 = 보스턴[[&#39;medv&#39;]]
print(독립.shape, 종속.shape)</p>
<p>x = tf.keras.layers.Input(shape=[13])
y = tf.keras.layers.Dense(1)(x)
model = tf.keras.models.Model(x,y)
model.compile(loss=&#39;mse&#39;)</p>
<h1 id="데이터로-모델을-학습fit">데이터로 모델을 학습(FIT)</h1>
<p>model.fit(독립, 종속, epochs=1000, verbose=0)
model.fit(독립, 종속, epochs=10, verbose=1)</p>
<h1 id="모델을-이용">모델을 이용</h1>
<p>model.predict(독립[:5])</p>
<p>종속[0:5] #python의 슬라이싱(slicing) </p>
<h1 id="모델의-수식-확인">모델의 수식 확인</h1>
<p>model.get_weights()</p>
<pre><code>

### * 학습의 실제
- 수식의 가중치를 찾는 방법?
[https://docs.google.com/spreadsheets/d/1-bg8CeN2I55og4nnFXcPBnIxdW_n1ToOdrfwd0_A5Qc/edit#gid=0](https://docs.google.com/spreadsheets/d/1-bg8CeN2I55og4nnFXcPBnIxdW_n1ToOdrfwd0_A5Qc/edit#gid=0)


### 세번째. 아이리스 품종 종류
- **원핫인코딩(onehot-encoding)**
```python 아이리스 = pd.get_dummies(아이리스) ```
-&gt; 품종.setosa , 품종.virginica, 품종.versicolor...
- **소프트맥스** / cf. **시그모이드**
- 비율을 예측하는데 사용 됨
- softmax(함수 식) -&gt; 결과 값을 0과 1 사이로 나오게 함
- Indentity(y=x) 회귀모델
- Softmax 분류모델

- **Activation 활성화 함수**
- categorical_crossentropy : mse(loss)를 계산하는 확률
- metrics = &#39;accuracy&#39; &lt;- 0에서 1사이의 확률

- **코드**
```python
# 라이브러리 사용
import tensorflow as tf
import pandas as pd

# 과거 데이터 준비
파일경로 = &#39;https://raw.githubusercontent.com/blackdew/tensorflow1/master/csv/iris.csv&#39;
아이리스 = pd.read_csv(파일경로)
아이리스.head()

# 모델 구조 만들기 / 원핫인코딩
인코딩 = pd.get_dummies(아이리스)
인코딩.head()

인코딩.columns

# 독립변수와 종속변수
독립 = 인코딩[[&#39;꽃잎길이&#39;, &#39;꽃잎폭&#39;, &#39;꽃받침길이&#39;, &#39;꽃받침폭&#39;]]
종속 = 인코딩[[&#39;품종_setosa&#39;, &#39;품종_versicolor&#39;,
       &#39;품종_virginica&#39;]]

print(독립.shape, 종속.shape)

# 모델 구조 생성
x = tf.keras.layers.Input(shape=[4])
y = tf.keras.layers.Dense(3, activation=&#39;softmax&#39;)(x)
model = tf.keras.models.Model(x,y)
model.compile(loss = &#39;categorical_crossentropy&#39;,
              metrics=&#39;accuracy&#39;) # 사람이 보기 편한 정확도라는 척도 

# 데이터로 모델을 학습 (FIT)
model.fit(독립, 종속, epochs=100)

# 모델 이용하기
model.predict(독립[0:5])

print(종속[0:5])

model.predict(독립[-5:])

print(종속[-5:])

# 학습한 가중치 출력
model.get_weights()</code></pre><h3 id="네번째-신경망의-완성--히든-레이어">네번째. 신경망의 완성 : 히든 레이어</h3>
<ul>
<li>각각의 모델을 여러개 연결하여 하나의 모델을 만드는 것이 딥러닝, 인공지능망<pre><code class="language-python">x = tf.keras.layers.Input(shape=[13])
H = tf.keras.layers.Dense(5, activation=&#39;swish&#39;)(x) # 히든 레이어 추가
y = tf.keras.layers.Dense(1)(H) # x가 아닌 H임을 주의
model = tf.keras.models.Model(x,y)
model.compile(loss=&#39;mse&#39;)</code></pre>
</li>
<li>swish는 최근에 발표된 성능 좋은 히든 레이어 활성화 함수</li>
</ul>
<h2 id="추가-실습">추가 실습</h2>
<h3 id="데이터타입--숫자형-범주형으로-바꾸기">데이터타입 : 숫자형-&gt;범주형으로 바꾸기</h3>
<pre><code class="language-python">import tensorflow as tf
import pandas as pd

파일경로 = &#39;https://raw.githubusercontent.com/blackdew/tensorflow1/master/csv/iris2.csv&#39;
아이리스 = pd.read_csv(파일경로)
아이리스.head()

# 원핫인코딩
인코딩 = pd.get_dummies(아이리스)
인코딩.head()

# 결과: 인코딩 되지 않음! -&gt; 왜? 범주형이지만 숫자 데이터이기 때문에.

print(아이리스.dtypes)

# 품종 타입을 범주형으로 바꾸기
아이리스[&#39;품종&#39;] = 아이리스[&#39;품종&#39;].astype(&#39;category&#39;) # 아이리스의 품종 컬럼을 astype 함수로 &#39;카테고리&#39;로 바꿈
아이리스.dtypes

# 원핫인코딩
인코딩 = pd.get_dummies(아이리스)
인코딩.head()</code></pre>
<h3 id="na-데이터값-평균값으로-바꾸기">NA 데이터값 평균값으로 바꾸기</h3>
<pre><code class="language-python"># NA값 체크해보기
아이리스.isna().sum() # column 별로 na가 있는지 합을 보여줌

아이리스.tail()

# NA값에 꽃잎폭 평균값 넣어주기
mean = 아이리스[&#39;꽃잎폭&#39;].mean()
아이리스[&#39;꽃잎폭&#39;] = 아이리스[&#39;꽃잎폭&#39;].fillna(mean)

아이리스.tail()</code></pre>
<h3 id="학습-모델-향상시키기">학습 모델 향상시키기</h3>
<pre><code class="language-python"># 보스턴 집값 예측 데이터로 학습이 잘 되는 모델 만들기
- 사용할 레이어
  - tf.keras.layers.BatchNomalization()
  - tf.keras.layers.Activation(&#39;swish&#39;)

파일경로 = &#39;https://raw.githubusercontent.com/blackdew/tensorflow1/master/csv/boston.csv&#39;
보스턴 = pd.read_csv(파일경로)

독립 = 보스턴[[&#39;crim&#39;, &#39;zn&#39;, &#39;indus&#39;, &#39;chas&#39;, &#39;nox&#39;, &#39;rm&#39;, &#39;age&#39;, &#39;dis&#39;, &#39;rad&#39;, &#39;tax&#39;,
       &#39;ptratio&#39;, &#39;b&#39;, &#39;lstat&#39;]]
종속 = 보스턴[[&#39;medv&#39;]]
print(독립.shape, 종속.shape)

# 모델의 구조 만들기
X = tf.keras.layers.Input(shape=[13])
H = tf.keras.layers.Dense(8, activation=&#39;swish&#39;)(X) # 히든 레이어 3층 만들기
H = tf.keras.layers.Dense(8, activation=&#39;swish&#39;)(H)
H = tf.keras.layers.Dense(8, activation=&#39;swish&#39;)(H)
Y = tf.keras.layers.Dense(1)(H)

model = tf.keras.models.Model(X, Y)
model.compile(loss=&#39;mse&#39;)


model.fit(독립, 종속, epochs=1000)
# 결과가 아주 만족스럽지는 않음

# BatchNormalization을 사용해 성능 높이기
X = tf.keras.layers.Input(shape=[13])

H = tf.keras.layers.Dense(8)(X)
H = tf.keras.layers.BatchNormalization()(H)
H = tf.keras.layers.Activation(&#39;swish&#39;)(H)

H = tf.keras.layers.Dense(8)(H)
H = tf.keras.layers.BatchNormalization()(H)
H = tf.keras.layers.Activation(&#39;swish&#39;)(H)

H = tf.keras.layers.Dense(8)(H)
H = tf.keras.layers.BatchNormalization()(H)
H = tf.keras.layers.Activation(&#39;swish&#39;)(H)

Y = tf.keras.layers.Dense(1)(H)

model = tf.keras.models.Model(X, Y)
model.compile(loss=&#39;mse&#39;)


model.fit(독립, 종속, epochs=1000, batch_size=150)
# loss가 10대 초반으로 떨어짐</code></pre>
]]></description>
        </item>
        <item>
            <title><![CDATA[오렌지3(Orange3)]]></title>
            <link>https://velog.io/@jess_j/%EC%98%A4%EB%A0%8C%EC%A7%803Orange3</link>
            <guid>https://velog.io/@jess_j/%EC%98%A4%EB%A0%8C%EC%A7%803Orange3</guid>
            <pubDate>Fri, 01 Oct 2021 13:44:10 GMT</pubDate>
            <description><![CDATA[<p>출처 : 생활코딩 (<a href="https://opentutorials.org/course/4549">https://opentutorials.org/course/4549</a>) </p>
<h3 id="오렌지란">오렌지란?</h3>
<ul>
<li>표를 다루는 도구</li>
</ul>
<h3 id="시나리오와-전략">시나리오와 전략</h3>
<ul>
<li>입력 -&gt; 처리 -&gt; 출력</li>
<li>표</li>
<li>시각화</li>
<li>머신러닝 : 데이터로 기계를 학습시켜 미래를 예측하도록 함</li>
</ul>
<h3 id="기본-사용법">기본 사용법</h3>
<p><img src="https://images.velog.io/images/jess_j/post/b4b89cf8-50f4-42b1-8a5d-91a30dcd34de/image.png" alt=""></p>
<blockquote>
<p>** 구글 Docs 링크 사용하는 방법 **</p>
</blockquote>
<ol>
<li>File&gt;Share 버튼 클릭 </li>
<li>Get Link 색션에서 Change to anyone with the link 버튼클릭</li>
<li>Anyone with the link를 viewer 이상의 권한으로 지정</li>
<li>구글 시트의 주소에서 에서 /edit#grid=0 부분을 제거한 주소를 사용합니다.
예) <a href="https://docs.google.com/spreadsheets/d/1-ija64LCoZUafvFhsMsXjHu9jltwoOVvmBR8fSIJfRM/edit#gid=0">https://docs.google.com/spreadsheets/d/1-ija64LCoZUafvFhsMsXjHu9jltwoOVvmBR8fSIJfRM/edit#gid=0</a>
=&gt; <a href="https://docs.google.com/spreadsheets/d/1-ija64LCoZUafvFhsMsXjHu9jltwoOVvmBR8fSIJfRM">https://docs.google.com/spreadsheets/d/1-ija64LCoZUafvFhsMsXjHu9jltwoOVvmBR8fSIJfRM</a>
출처 : <a href="https://opentutorials.org/course/4549/28996">https://opentutorials.org/course/4549/28996</a> </li>
</ol>
<h3 id="표를-다루기">표를 다루기</h3>
<ul>
<li>행 row / 열 column</li>
<li>표 = 데이터 셋(data set)</li>
<li>table에서 또 table을 만들면 selected rows만 표시할 수 있음</li>
</ul>
<h3 id="통계와-시각화">통계와 시각화</h3>
<ul>
<li>대푯값과 분포 &lt;-어림짐작의 도구</li>
<li>대푯값 : 평균, 중앙값, 최빈값, .. </li>
<li>Boxplot </li>
<li>Scatterplot 산점도
<img src="https://images.velog.io/images/jess_j/post/492d6b68-1d5c-4bde-ba6b-e4ba5096cb98/image.png" alt=""></li>
<li>인과관계는 상관관계에 포함된 개념</li>
<li>원인 : 독립변수</li>
<li>결과 : 종속변수</li>
</ul>
<h3 id="오렌지3으로-머신러닝">오렌지3으로 머신러닝</h3>
<ul>
<li>독립변수와 종속변수를 찾아내어 -&gt; 컴퓨터에 학습 -&gt; 컴퓨터가 공식(모델)을 만들어냄</li>
<li>모르는 &#39;원인&#39;을 입력했을 때 &#39;결과&#39;를 도출하도록 함</li>
<li><img src="https://images.velog.io/images/jess_j/post/b3bb0bd8-83de-40fa-ab19-0fa6c87f1ae7/image.png" alt=""></li>
<li>지도학습 중 회귀(regression) 활용</li>
<li>Role<ul>
<li>skip : 학습시키고자 하는 데이터에서 상관 없는 데이터를 제외</li>
<li>meta : 실제로 분석 작업에 사용되진 않지만 정보성으로 남겨두는 것</li>
<li>target : 예측하고자 하는 타겟값(종속변수)</li>
<li>feature : 독립변수</li>
</ul>
</li>
<li><img src="https://images.velog.io/images/jess_j/post/f9ce5496-19b4-400e-95f2-5e401a49722c/image.png" alt=""></li>
</ul>
]]></description>
        </item>
        <item>
            <title><![CDATA[머신러닝(Machine Learning)]]></title>
            <link>https://velog.io/@jess_j/%EB%A8%B8%EC%8B%A0%EB%9F%AC%EB%8B%9DMachine-Learning</link>
            <guid>https://velog.io/@jess_j/%EB%A8%B8%EC%8B%A0%EB%9F%AC%EB%8B%9DMachine-Learning</guid>
            <pubDate>Thu, 30 Sep 2021 06:45:00 GMT</pubDate>
            <description><![CDATA[<h1 id="머신러닝1">머신러닝1</h1>
<p>출처 : 생활코딩(<a href="https://ml.yah.ac/">https://ml.yah.ac/</a>)</p>
<ul>
<li><p>인간이 하던 결정을 기계에게 맡기기 시작 : <strong>기계학습(Machine Learning)</strong></p>
</li>
<li><p>머신러닝 때문에 인간의 두뇌가 필요 없는 것은 아니며 우리의 &#39;판단 능력&#39;을 확장하여 더 빠르고 정확하게 판단할 수 있도록 돕는 것</p>
</li>
<li><p>습관은 의지를 이기고, 의지는 환경을, 환경은 습관을 바꿈 </p>
<ul>
<li>즉 습관을 바꾸기 위해 환경을 바꾸는 우회적 방법을 사용</li>
</ul>
</li>
<li><p><strong>일 = 꿈 + 능력</strong> &lt;- 꿈을 먼저 꾸는 것이 중요함</p>
<ul>
<li>궁리하는 습관을 들일 것!</li>
</ul>
</li>
<li><p>이 수업에서 주목할 것</p>
</li>
</ul>
<ol>
<li>원리</li>
<li>수학</li>
<li>코딩</li>
</ol>
<h3 id="techable-machine">Techable Machine</h3>
<ul>
<li>머신러닝에 대한 지식이 없이도 머신러닝을 구현할 수 있도록 돕는 도구</li>
<li><a href="https://teachablemachine.withgoogle.com/">Techable Machine 링크</a></li>
<li>우리가 만든 &#39;판단력&#39; = &#39;모델 model&#39;</li>
</ul>
<h3 id="모델-model">모델 Model</h3>
<ul>
<li>경험 -&gt; 교훈 -&gt; 그 후에 <code>추측</code> 가능</li>
<li>현상 -&gt; 추측(가설) -&gt; 검증하기 위한 실험 -&gt; 결과 -&gt; 이론 -&gt; <code>예측</code> 가능</li>
<li>교훈 == 이론</li>
<li>머신러닝은 이런 판단력을 기계에 부여한 것이며 그 기계를 <code>모델model</code>이라 부름</li>
<li>이 모델을 만드는 과정을 &#39;학습&#39;이라고 부름</li>
</ul>
<h3 id="머신러닝머신">머신러닝머신</h3>
<ul>
<li><a href="https://ml-app.yah.ac/">https://ml-app.yah.ac/</a> </li>
</ul>
<h3 id="애플리케이션과-프로그램">애플리케이션과 프로그램</h3>
<ul>
<li>애플리케이션 : 응용, 어떤 부품을 조합해서 만든 완제품 <ul>
<li>머신러닝이라는 모델이라는 부품을 조합해서 만든 소프트웨어 </li>
<li>머신러닝 어플리케이션</li>
</ul>
</li>
<li>프로그램 : 시간 순서라는 개념이 포함된 도구, 기계가 알아들을 수 있는 언어로 만든 것<ul>
<li>프로그래밍</li>
<li>프로그래머(엔지니어)</li>
</ul>
</li>
</ul>
<h3 id="사물-인터넷">사물 인터넷</h3>
<ul>
<li>사물 인터넷 = 프로그래밍 + 전자공학 + 네트워크 + 기계공학</li>
</ul>
<h3 id="데이터-과학과-데이터-공학">데이터 과학과 데이터 공학</h3>
<ul>
<li>데이터 과학 : 데이터 자체를 다룸</li>
<li>데이터 공학 : 데이터를 다루는 것을 도와주는 것</li>
<li>서로 육체와 영혼의 관계라고 생각하면 됨</li>
</ul>
<h3 id="표table--행과-열">표(table) : 행과 열</h3>
<ul>
<li><p><strong>행(row)</strong></p>
<ul>
<li>개체(instance)</li>
<li><em>관측치(observed value)</em></li>
<li>기록(record)</li>
<li>사례(example)</li>
<li>경우(case)</li>
</ul>
</li>
<li><p><strong>열(column)</strong></p>
<ul>
<li><em>특성(feature)</em></li>
<li>속성(attribute)</li>
<li><em>변수(variable)</em></li>
<li>필드(field)</li>
</ul>
</li>
</ul>
<h3 id="독립변수와-종속변수">독립변수와 종속변수</h3>
<ul>
<li>변수(variable) : 변할 수 있는 값</li>
<li>독립변수 : <strong>원인</strong>이 되는 열 (ex.온도)</li>
<li>종속변수 : 원인으로 인해 <strong>결과</strong>가 되는 열 (ex.열병환자수)</li>
<li>서로 상관 있는 특성(열)이 무엇이 있는지 확인하여 변수를 구분할 수 있음</li>
<li>독립변수와 종속변수는 서로 인과관계이다</li>
<li>인과관계 &lt;- 상관관계에 포함됨</li>
</ul>
<h3 id="머신러닝의-분류">머신러닝의 분류</h3>
<ul>
<li><code>기계학습</code> = 강화학습 + 지도학습(분류, 회귀) + 비지도학습(군집화, 변환, 연관) ...</li>
<li><code>지도학습</code> : 기계를 가르쳐(문제와 정답이 있음) 성능을 향상하는 것</li>
<li><code>비지도학습</code> : 기계에게 데이터에 대한 통찰력을 부여하는 것 , 정답을 알려주지 않아도 관찰을 통해 의미나 관계를 밝혀내는 것</li>
<li><code>강화학습</code> : 학습을 통해서 능력을 향상시키고 어떤 것이 더 좋은 결과인지 스스로 느끼며 수련하는 것임</li>
</ul>
<h4 id="1-지도학습">1. 지도학습</h4>
<ul>
<li>역사와 비슷</li>
<li>원인과 결과가 나타나있어 그 비슷한 일이 있을 때 결과를 예측할 수 있음</li>
<li>독립변수와 종속변수가 꼭 필요함</li>
<li>충분히 많은 데이터를 수집하여 학습하고 &#39;모델&#39;을 만듦</li>
<li>과거의 데이터를 독립변수와 종속변수로 분리하여 학습 -&gt; &#39;모델&#39; </li>
<li>머신러닝 : 공식의 대중화 (과거엔 공식은 권력자의 소유물이었음)</li>
</ul>
<h5 id="a-분류-classification">a. 분류 classification</h5>
<ul>
<li>성격에 맞는 것끼리 수납하는 것</li>
<li>과거에 만든 데이터를 통해 / 독립-종속 변수를 통해 (지도학습)</li>
<li>추측하고자하는 결과가 숫자가 아닌 <code>이름 혹은 문자열</code>일 때</li>
</ul>
<h5 id="b-회귀-regression">b. 회귀 regression</h5>
<ul>
<li>미지의 <code>숫자</code>를 예측하기 위해 사용하는 모델</li>
</ul>
<h4 id="2-비지도학습">2. 비지도학습</h4>
<ul>
<li>탐험적(미지의 세계를 탐험)</li>
<li>종속변수와 독립변수의 구분이 중요하지 않음</li>
</ul>
<h5 id="a-군집화-clustering">a. 군집화 clustering</h5>
<ul>
<li>군집화는 비슷한 관측치(행)를 찾아서 그룹을 만드는 것</li>
<li>분류와의 차이? : 그룹을 만드는 것 : 군집화 / 정해진 그룹에 넣는 것 : 분류</li>
<li>좌표 평면 활용하여 &#39;가까운 것 끼리&#39; -&gt; 표에 &#39;군집&#39;이라는 열을 추가</li>
</ul>
<h5 id="b-연관규칙학습-association-rule-learning">b. 연관규칙학습 Association rule learning</h5>
<ul>
<li>장바구니 학습법이라고 불림</li>
<li>특성(열)을 그룹화 하는 것</li>
</ul>
<h5 id="c-변환">c. 변환</h5>
<ul>
<li>? </li>
</ul>
<h4 id="3-강화학습-reinforcement-learning">3. 강화학습 reinforcement learning</h4>
<ul>
<li>강화학습은 경험을 통해 성능을 높임 (지도학습은 학습을 통해 성능을 높임)</li>
<li>게임 : 상태 / 상과 벌 -&gt; 게이머 : 관찰 -&gt; 판단력 강화 -&gt; 행동 변화 -&gt; 게임에 변화 </li>
<li>환경(environment), 에이전트(agent), 상태(state), 보상(reward), 정책(policy), 행동(action)</li>
</ul>
]]></description>
        </item>
        <item>
            <title><![CDATA[조건문과 print() 함수]]></title>
            <link>https://velog.io/@jess_j/%EC%A1%B0%EA%B1%B4%EB%AC%B8%EA%B3%BC-print-%ED%95%A8%EC%88%98</link>
            <guid>https://velog.io/@jess_j/%EC%A1%B0%EA%B1%B4%EB%AC%B8%EA%B3%BC-print-%ED%95%A8%EC%88%98</guid>
            <pubDate>Sat, 27 Mar 2021 16:25:09 GMT</pubDate>
            <description><![CDATA[<h1 id="조건문">조건문</h1>
<h2 id="if문">If문</h2>
<blockquote>
<p>형식은 <code>if 조건문:</code> 으로 주의할 점은 파이썬은 들여쓰기로 함수를 묶기 때문에 <strong>들여쓰기를 주의할 것!</strong></p>
</blockquote>
<pre><code class="language-python">&gt;&gt;&gt; a = 99
&gt;&gt;&gt; if a&lt;100:     # a가 100보다 작으면 참, 아니면 거짓. 참일 때만 실행된다.
    print(&quot;100보다 작군요&quot;)
100보다 작군요.</code></pre>
<h2 id="조건의-참과-거짓">조건의 참과 거짓</h2>
<blockquote>
<p>참(True)과 거짓(False)을 판단할 수 있는 기호들은 다음과 같다.</p>
</blockquote>
<ul>
<li>비교 연산 기호 (==, !=, &lt;, &gt;, &lt;=, &gt;=)</li>
<li>논리 기호 (and, or, not)</li>
<li>존재 여부 (in, not in)</li>
<li>자료형의 참과 거짓
이 중 값의 존재 여부와 자료형의 참과 거짓을 보겠다.</li>
</ul>
<h3 id="값의-존재-여부in-not-in">값의 존재 여부(in, not in)</h3>
<blockquote>
<p>in : 값이 존재할 때 True
not in : 값이 존재하지 않을 때 True</p>
</blockquote>
<pre><code class="language-python">&gt;&gt;&gt; &quot;Korean&quot; in [&quot;Korean&quot;, &quot;English&quot;]     # list다
True
&gt;&gt;&gt; list0 = [1,2,3]
&gt;&gt;&gt; a = 1
&gt;&gt;&gt; a in list0
True     # a라는 변수가 가진 1이라는 값이 list0 에 존재하므로 참이다

&gt;&gt;&gt; &quot;Japanese&quot; not in [&quot;Korean&quot;, &quot;English&quot;]
True</code></pre>
<h3 id="자료형의-참과-거짓">자료형의 참과 거짓</h3>
<blockquote>
<p>숫자형의 경우 <code>0은 False</code>, 나머지는 모두 True이다. 
이처럼 <strong>자료형에도 참과 거짓</strong>이 있다.
문자열(str), 리스트(list), 딕셔너리(dict)는 <code>비어있으면 False</code>, <code>하나라도 값이 있으면 True</code>다.</p>
</blockquote>
<table>
<thead>
<tr>
<th align="center"></th>
<th align="center">숫자</th>
<th align="center">문자열</th>
<th align="center">리스트</th>
<th align="center">딕셔너리</th>
</tr>
</thead>
<tbody><tr>
<td align="center">참</td>
<td align="center">0이 아닌 숫자</td>
<td align="center">&quot;string&quot;</td>
<td align="center">[1,2,3]</td>
<td align="center">{&quot;X&quot;, &quot;Y&quot;}</td>
</tr>
<tr>
<td align="center">거짓</td>
<td align="center">0</td>
<td align="center">&quot;&quot;</td>
<td align="center">[]</td>
<td align="center">{}</td>
</tr>
</tbody></table>
<h2 id="if문에서-들여쓰기의-중요성">If문에서 들여쓰기의 중요성</h2>
<pre><code class="language-python">&gt;&gt;&gt; a = 200
&gt;&gt;&gt; if a &lt; 100:
    print(&quot;100보다 작군요.&quot;)
   print(&quot;거짓이므로 이 문장은 안 보이겠죠&quot;)
&gt;&gt;&gt; print(&quot;프로그램 끝.&quot;)

거짓이므로 이 문장은 안 보이겠죠
프로그램 끝</code></pre>
<blockquote>
<p>만약 위의 코드에서 의도한 바가 a 값이 100보다 작으므로 &quot;거짓이므로~보이겠죠&quot; 문장이 나오지 않는 것이었다면 
위의 코드는 틀린 출력 결과를 보여준 것이다. 왜일까?</p>
</blockquote>
<pre><code class="language-python">&gt;&gt;&gt; a = 200
&gt;&gt;&gt; if a &lt; 100:
    print(&quot;100보다 작군요.&quot;)
        print(&quot;거짓이므로 이 문장은 안보이겠죠.&quot;)
&gt;&gt;&gt; print(&quot;프로그램 끝&quot;)</code></pre>
<blockquote>
<p>첫번째 코드와 다른점은 바로 <code>들여쓰기</code>다.
파이썬은 앞서 말했듯이 들여쓰기로 함수의 범위를 인식하기 때문에 들여쓰기를 맞춰주는 것은 필수적이다.</p>
</blockquote>
<h2 id="if-else문">If-else문</h2>
<blockquote>
<p>조건문이 참일 때 실행할 코드와 아닐때(그 외, else) 실행할 코드를 따로 정해주는 함수이다.</p>
</blockquote>
<pre><code class="language-python">&gt;&gt;&gt; a = 200
&gt;&gt;&gt; if a &lt; 100:
    print(&quot;100보다 작군요.&quot;)
    else:     # if의 조건문이 거짓(False)일 때!
        print(&quot;100보다 크군요.&quot;)
100보다 크군요.</code></pre>
<p>위의 코드는 조건문이 거짓이므로 그 외를 다루는 else로 빠져 print문을 실행했다.</p>
<h2 id="중첩-if문">중첩 If문</h2>
<blockquote>
<p>중첩 If문이란 If문을 한 번 실행한 후 <code>그 결과에서 다시 if문을 실행</code>하는 것이다.
If - If 도 가능하지만 If<del>elseIf</del>else 형식도 가능하다.
또한 If<del>elif</del>else 형식도 가능한데, 여기서 <code>elif</code>란 <strong>else와 If를 결합한 것</strong>으로, If외 다른 조건을 제안한다.</p>
</blockquote>
<pre><code class="language-python">score = int(input(&quot;점수를 입력하세요. :&quot;))

if score &gt;= 90:
    print(&quot;A&quot;)
elif score &gt;= 80: # 첫번째 거름망
    print(&quot;B&quot;)
elif score &gt;= 70: # 두번째 거름망
    print(&quot;C&quot;)
elif score &gt;= 60: # 세번째 거름망
    print(&quot;D&quot;)
else:
    print(&quot;F&quot;)

print(&quot;학점입니다!&quot;)</code></pre>
<p>위의 코드는 if문과 else 사이에 <code>총 3번의 거름망</code>이 있다고 보면 된다.
일반 If<del>else문에서는 If가 거짓이면 바로 그외를 다루는 else로 빠지지만,
**If</del>elif~else 문**에서는 elif가 거름망이 되어
If에서 거짓이 된 값을 받아 한번 더 참과 거짓을 가르는 것이다.</p>
<ul>
<li>elif의 조건이 True이면 해당되는 코드를 실행하고,</li>
<li>False가 되면 다음 elif 혹은 마지막 else로 빠진다.</li>
</ul>
<p>이런식으로 총 세번의 거름망에서 모두 False로 판단되면
드디어 원 If문과 짝인 else를 만나 코드를 실행한다.</p>
<h2 id="삼항-연산자를-사용한-if-문">삼항 연산자를 사용한 if 문</h2>
<blockquote>
<p>다음과 같은 코드가 있다고 보자.</p>
</blockquote>
<pre><code class="language-python">jumsu = 55
res = &#39;&#39;
if jumsu &gt;= 60:
    res = &#39;합격&#39;
esle :
    res = &#39;불합격&#39;
print(&#39;res&#39;)</code></pre>
<blockquote>
<p>위의 코드는 아래의 코드와 같은 결과값을 가진다.</p>
</blockquote>
<pre><code class="language-python">res = &#39;합격&#39; if jumsu &gt;= 60 else &#39;불합격&#39;</code></pre>
<blockquote>
<p><strong>삼항 연산자란 연산 대상자가 3개인 연산자</strong>이다.
앞서 배운 부호(+,-),not 등이 단항 연산자(연산 대상자가 1개)이며
+, -, * 등의 산술 연산자가 이항 연산자(연산 대상자가 2개)이다.
<strong>삼항 연산자는 한가지 유형만 존재</strong>한다.
형식은 다음과 같다.</p>
</blockquote>
<ul>
<li>값을 대입할 변수 = <code>(if조건이 참일 경우 값) if (조건문) else (if조건이 거짓일 경우 값)</code>
주의할 점은 일반 if~else 문과 달리 사이에 &#39;:&#39;가 없다는 점이다.</li>
</ul>
<hr>
<hr>
<h1 id="print-함수">Print() 함수</h1>
<blockquote>
<p>print() 함수에서 사용할 수 있는 서식은 다음과 같다.</p>
</blockquote>
<table>
<thead>
<tr>
<th align="left">서식</th>
<th align="left">값의 예</th>
<th align="left">설명</th>
</tr>
</thead>
<tbody><tr>
<td align="left">%d, %x, %o</td>
<td align="left">10,100,1234</td>
<td align="left">정수(10진수, 16진수, 8진수)</td>
</tr>
<tr>
<td align="left">%f</td>
<td align="left">0.5, 1.0, 3.14</td>
<td align="left">실수(소수점이 있음)</td>
</tr>
<tr>
<td align="left">%c</td>
<td align="left">&quot;b&quot;, &#39;비&#39;</td>
<td align="left">한 글자</td>
</tr>
<tr>
<td align="left">%s</td>
<td align="left">&quot;안녕&quot;, &quot;abcdefg&quot;, &quot;a&quot;</td>
<td align="left">두 글자 이상인 문자열(한 글자도 가능함)</td>
</tr>
</tbody></table>
<pre><code class="language-python">&gt;&gt;&gt; print(&quot;%d / %d = %d&quot; % (100,200,0.5))
100 / 200 = 0
# 뒤에 대입한 값은 0.5이지만 서식이 정수 형식이므로 0만 출력됨</code></pre>
<blockquote>
<p>서식을 활용할 때 <strong>%와 서식 사이</strong>에 숫자를 넣음으로써 <strong>확보할 자리를 정할 수 있다.</strong>
<code>print(&quot;%5d&quot; % 123)</code>과 같이 쓰게 되면, 정수 자리 5자리를 만들어 놓고
오른쪽 정렬로 값 123을 넣어 앞의 두자리는 공백으로 나타낸다.</p>
</blockquote>
<pre><code class="language-python">&gt;&gt;&gt; print(&quot;%d&quot; % 123)
&gt;&gt;&gt; print(&quot;%5d&quot; % 123)
123
  123     # 앞에 공백 2개가 존재한다.(5개 중에 3개 사용했으니까!)</code></pre>
<blockquote>
<p><strong>이 공백에 채울 값을 따로 정하는 것</strong>도 가능하다.
<code>print(&quot;%05d&quot; % 123)</code>과 같이 하는 것이다.
우선 5자리를 확보하고, 오른쪽 정렬로 값을 대입한 다음, 남은 자리(2자리)에는 숫자 &#39;0&#39;을 넣는 것이다.</p>
</blockquote>
<pre><code class="language-python">&gt;&gt;&gt; print(&quot;%5d&quot; % 123)
&gt;&gt;&gt; print(&quot;%05d&quot; % 123)
   123
 00123</code></pre>
<blockquote>
<p><strong>실수의 경우 소수점 아래 자릿수</strong>를 정할 수 있다.</p>
</blockquote>
<pre><code class="language-python">&gt;&gt;&gt; print(&quot;%f&quot; % 123.45)    #그냥 f로 지정하면 소수점 아래 6자리까지 무조건! 출력됨
&gt;&gt;&gt; print(&quot;%7.1f&quot; % 123.45)     #소수점을 포함해 7자리를 확보하고, 첫째자리 까지만 나타낸다.
&gt;&gt;&gt; print(&quot;%7.3f&quot; % 123.45)     #소수점을 포함해 7자리를 확보하고, 셋째자리 까지 나타낸다. 빈 자리는 0으로!
123.450000
  123.5                #첫째자리까지 나타내기 위해 둘째자리에서 반올림을 함.
123.450</code></pre>
<blockquote>
<p>문자열도 마찬가지이다.</p>
</blockquote>
<pre><code class="language-python">&gt;&gt;&gt; print(&quot;%s&quot; % &quot;Python&quot;)
&gt;&gt;&gt; print(&quot;%10s&quot; % &quot;Python&quot;)
Python
    Python
</code></pre>
<blockquote>
<p>만약 문자 <code>%</code> 자체를 나타내고 싶다면 어떻게 해야할까?
<strong>%%로 입력</strong>하면 포맷 코드로 인식하지 않고 문자열 자체로 인식한다!</p>
</blockquote>
<pre><code class="language-python">&gt;&gt;&gt; print(&quot;Error is %d %% .&quot; % 98)
Error is 98%.</code></pre>
<h2 id="이스케이프-문자escape-sequence">이스케이프 문자(Escape Sequence)</h2>
<blockquote>
<p>print()함수에서 특수 문자를 표현하는 역슬래시()로 표현하는 특수 표기법을 말한다.
이스케이프 문자는 다음과 같다. 그대로 출력하는 방법도 포함한다.</p>
</blockquote>
<table>
<thead>
<tr>
<th>이스케이프 문자</th>
<th>역할</th>
<th>설명</th>
</tr>
</thead>
<tbody><tr>
<td>\n</td>
<td>새로운 줄로 이동</td>
<td><code>Enter</code>을 누른 효과</td>
</tr>
<tr>
<td>\t</td>
<td>다음 탭으로 이동</td>
<td><code>Tap</code>을 누른 효과</td>
</tr>
<tr>
<td>\b</td>
<td>뒤로 한 칸 이동</td>
<td><code>Backspace</code>를 누른 효과</td>
</tr>
<tr>
<td>\\</td>
<td>\출력</td>
<td></td>
</tr>
<tr>
<td>&#39;</td>
<td>&#39;출력</td>
<td></td>
</tr>
<tr>
<td>&quot;</td>
<td>&quot;출력</td>
<td></td>
</tr>
</tbody></table>
<pre><code class="language-python">print(&quot;\n줄바꿈\n연습&quot;)
print(&quot;\t키\t연습&quot;)
print(&quot;\\\\\\역슬래시 3개 출력&quot;)
print(&quot;줄바꿈 기호 : \\n&quot;)
print(&quot;탭 키 기호 : \\t&quot;)
print(r&quot;\n \t \&quot; \\를 그대로 출력&quot;)        #print문 안의 문자열이 시작전 &#39;r&#39;을 넣어 이스케이프 문자의 효과를 제거한다.

#결과값
줄바꿈
연습
    키    연습
\\\역슬래시 3개 출력
줄바꿈 기호 : \n
탭 키 기호 : \t
\n \t \&quot; \\를 그대로 출력</code></pre>
<h2 id="print문-자동-줄바꿈">print문 자동 줄바꿈</h2>
<blockquote>
<p>print() 함수는 일반적으로 문자열을 다 찍고 그 뒤에 <strong>새로운 줄에서 시작하게 하도록 하는</strong> <code>개행 문자</code>가 포함되어 있다.
print()를 사용하면서 자동 줄바꿈을 없애기 위해서는
문자열 뒤에 <code>&#39;,&#39;를 쓰고 end = &#39;&#39; 를 이용</code>하여 문자열을 다 출력하고 할 동작을 변경해 줄 수 있다.
즉, 기본으로 포함된 개행 문자를 빼고 할 동작을 지정해주는 것이다.</p>
</blockquote>
<pre><code class="language-python">&gt;&gt;&gt; print(&quot;Hello&quot;) ; print(&quot;Python&quot;)
Hello
Python</code></pre>
<p>위와 같이 자동으로 줄바꿈 되는 개행 문자를</p>
<pre><code class="language-python">&gt;&gt;&gt; print(&quot;Hello&quot;, end = &#39;&#39;)
&gt;&gt;&gt; print(&quot;Python&quot;)
Hello Python</code></pre>
<p>end에 공백(&#39;&#39;)을 넣어 다음 print문을 이어서 출력할 수 있다.</p>
]]></description>
        </item>
        <item>
            <title><![CDATA[입출력과 연산자]]></title>
            <link>https://velog.io/@jess_j/%EC%9E%85%EC%B6%9C%EB%A0%A5%EA%B3%BC-%EC%97%B0%EC%82%B0%EC%9E%90</link>
            <guid>https://velog.io/@jess_j/%EC%9E%85%EC%B6%9C%EB%A0%A5%EA%B3%BC-%EC%97%B0%EC%82%B0%EC%9E%90</guid>
            <pubDate>Wed, 24 Mar 2021 16:00:08 GMT</pubDate>
            <description><![CDATA[<h1 id="입력과-출력">입력과 출력</h1>
<h3 id="print--화면에-출력하기">print() : 화면에 출력하기</h3>
<blockquote>
<p>함수 print()의 괄호에 변수 이름 혹은 문자열을 입력하면 출력해주는 함수이다.</p>
</blockquote>
<pre><code class="language-python">&gt;&gt;&gt; print(&quot;Hello world&quot;)
Hello world</code></pre>
<h3 id="input--사용자에게서-입력-받기">input() : 사용자에게서 입력 받기</h3>
<blockquote>
<p>input() 함수를 사용시 사용자가 enter를 입력할 때 까지 입력한 값이 모두 <code>문자열</code>로 저장된다.
이때 사용자에게 표시되는 문구는 코딩 작성시 미리 넣어둔 문자열로 변수에 저장되지 않음!<del>(안내문 격?)</del>
🚨 주의 : <strong>숫자를 입력해도 &#39;문자열&#39;로 저장</strong>되기 때문에 int() 함수 등을 사용해 숫자로 변환해야 한다.</p>
</blockquote>
<pre><code class="language-python">&gt;&gt;&gt; eng = input(&#39;영어 점수를 입력하세요 : &#39;)
5
&gt;&gt;&gt; print(eng)
5</code></pre>
<h3 id="int-float--문자열을-숫자-데이터로-변환">int(), float() : 문자열을 숫자 데이터로 변환</h3>
<blockquote>
<p>문자열로 입력 받은 값을 수로 변환하려면  int() 혹은 float() 함수 안에 input() 함수를 넣어주자.</p>
</blockquote>
<pre><code class="language-python">&gt;&gt;&gt; eng = int(input(&#39;영어 점수를 입력하세요 : &#39;))
5
&gt;&gt;&gt; kor = int(input(&#39;국어 점수를 입력하세요 : &#39;))
10
&gt;&gt;&gt; total = ent + kor        # 두 변수 모두 숫자로 변환했기 때문에 연산이 가능한 것임
&gt;&gt;&gt; print(total)
15</code></pre>
<hr>
<h1 id="연산자">연산자</h1>
<h3 id="연산자-종류">연산자 종류</h3>
<blockquote>
<p>기본 산술 연산의 종류는 다음과 같다</p>
</blockquote>
<table>
<thead>
<tr>
<th align="center">연산자</th>
<th align="center">의미</th>
<th align="center">사용 예</th>
<th align="center">결과</th>
</tr>
</thead>
<tbody><tr>
<td align="center"><strong>=</strong></td>
<td align="center">대입 연산자</td>
<td align="center">a = 7</td>
<td align="center">7</td>
</tr>
<tr>
<td align="center"><strong>+</strong></td>
<td align="center">더하기</td>
<td align="center">a = 7 + 3</td>
<td align="center">10</td>
</tr>
<tr>
<td align="center"><strong>-</strong></td>
<td align="center">빼기</td>
<td align="center">a = 7 - 3</td>
<td align="center">4</td>
</tr>
<tr>
<td align="center">*****</td>
<td align="center">곱하기</td>
<td align="center">a = 7  * 3</td>
<td align="center">21</td>
</tr>
<tr>
<td align="center"><strong>/</strong></td>
<td align="center">나누기</td>
<td align="center">a = 7 / 3</td>
<td align="center">2.3333..</td>
</tr>
<tr>
<td align="center"><strong>//</strong></td>
<td align="center">나누기(몫)</td>
<td align="center">a = 7 // 3</td>
<td align="center">2</td>
</tr>
<tr>
<td align="center"><strong>%</strong></td>
<td align="center">나머지값</td>
<td align="center">a = 7 % 3</td>
<td align="center">1</td>
</tr>
<tr>
<td align="center"><strong>**</strong></td>
<td align="center">제곱</td>
<td align="center">a = 7 ** 3</td>
<td align="center">343</td>
</tr>
</tbody></table>
<h3 id="기본-산술-연산자-우선-순위">기본 산술 연산자 우선 순위</h3>
<blockquote>
<p>연산은 기본적으로 왼쪽에서 오른쪽 방향으로 계산되며 
기본 산술 연산자의 우선 순위는 다음과 같다.</p>
</blockquote>
<table>
<thead>
<tr>
<th align="center">우선 순위</th>
<th align="center">연산 기호</th>
<th align="center">설명</th>
</tr>
</thead>
<tbody><tr>
<td align="center"><strong>1</strong></td>
<td align="center">( )</td>
<td align="center">a = 7</td>
</tr>
<tr>
<td align="center"><strong>2</strong></td>
<td align="center">**</td>
<td align="center">지수 연산 기호</td>
</tr>
<tr>
<td align="center"><strong>3</strong></td>
<td align="center">+, -</td>
<td align="center">양수, 음수 부호 기호</td>
</tr>
<tr>
<td align="center"><strong>4</strong></td>
<td align="center">*, / , //, %</td>
<td align="center">곱셉, 나눗셈 나머지 기호</td>
</tr>
<tr>
<td align="center"><strong>5</strong></td>
<td align="center">+, -</td>
<td align="center">덧셈, 뺄셈 기호</td>
</tr>
</tbody></table>
<h3 id="str--숫자를-문자열로-변환">str() : 숫자를 문자열로 변환</h3>
<blockquote>
<p>문자열을 숫자 데이터로 변환하는 함수와 반대로, 숫자 데이터를 문자열로 변환해주는 함수.
문자열도 연산이 가능하다. + 연산으로 문자열을 연결하거나 * 연산으로 여러번 출력하는 것도 가능하다.
🚨 주의 : 문자열은 문자열과만 더할 수 있음! 문자열 + 숫자는 불가능하다.</p>
</blockquote>
<pre><code class="language-python">&gt;&gt;&gt; a = 100; b = 100.123
&gt;&gt;&gt; str(a) + &#39;1&#39; ; str(b) + &#39;1&#39;
&#39;1001&#39;
&#39;100.1231&#39;</code></pre>
<h3 id="대입-연산자와-산술-연산자의-결합">대입 연산자와 산술 연산자의 결합</h3>
<blockquote>
<p>대입 연산자 = 외에 +=, -=, <em>=, /=, %=, //=, ***</em>= ** 가 있다. 
기존의 값에 산술 연산을 한 후 다시 대입하는 것을 의미한다. 
🚨 *<em>순서 주의! *</em><code>산술 연산자</code> 뒤에 <code>=</code>가 온다. </p>
</blockquote>
<pre><code class="language-python">&gt;&gt;&gt; a = 5
&gt;&gt;&gt; a
5
&gt;&gt;&gt; a += 5
&gt;&gt;&gt; a
10</code></pre>
<h3 id="관계-연산자">관계 연산자</h3>
<blockquote>
<p>어떤 것이 크거나 작거나 같은지 비교하여 참은 True 값으로 거짓은 False 값으로 반환한다.
주로 <code>조건문(if)</code>이나 <code>반복문(while)</code>에서 사용하며, 단독으로는 거의 사용하지 않음.</p>
</blockquote>
<table>
<thead>
<tr>
<th align="center">연산자</th>
<th align="center">의미</th>
<th align="center">설명</th>
</tr>
</thead>
<tbody><tr>
<td align="center"><strong>==</strong></td>
<td align="center">같음</td>
<td align="center">같으면 참</td>
</tr>
<tr>
<td align="center"><strong>!=</strong></td>
<td align="center">같지 않음</td>
<td align="center">다르면 참</td>
</tr>
<tr>
<td align="center"><strong>&gt;</strong></td>
<td align="center">큼</td>
<td align="center">좌측이 크면 참</td>
</tr>
<tr>
<td align="center"><strong>&lt;</strong></td>
<td align="center">작음</td>
<td align="center">우측이 크면 참</td>
</tr>
<tr>
<td align="center"><strong>&gt;=</strong></td>
<td align="center">크거나 작음</td>
<td align="center">좌측이 같거나 크면 참</td>
</tr>
<tr>
<td align="center"><strong>&lt;=</strong></td>
<td align="center">작거나 같음</td>
<td align="center">우측이 같거나 크면 참</td>
</tr>
</tbody></table>
<pre><code class="language-python">&gt;&gt;&gt; a, b = 100, 200
&gt;&gt;&gt; print( a==b, a != b, a&gt;b, a&lt;b, a&gt;= b, a&lt;=b)
False True False True False True</code></pre>
<h3 id="논리-연산자">논리 연산자</h3>
<blockquote>
<p>종류는 총 3가지 - and(그리고), or(또는), not(부정)</p>
</blockquote>
<table>
<thead>
<tr>
<th align="center">연산자</th>
<th align="center">의미</th>
<th align="center">설명</th>
<th align="center">사용 예</th>
</tr>
</thead>
<tbody><tr>
<td align="center"><strong>and(논리곱)</strong></td>
<td align="center">~이고, 그리고(동시)</td>
<td align="center">둘 다 참이여야 참</td>
<td align="center">(a&gt;100) and (a&lt;200)</td>
</tr>
<tr>
<td align="center"><strong>or(논리합)</strong></td>
<td align="center">~이거나, 또는(하나라도)</td>
<td align="center">둘 중 하나만 참이여도 참</td>
<td align="center">(a==100) or (a==200)</td>
</tr>
<tr>
<td align="center"><strong>not(논리부정)</strong></td>
<td align="center">~아니다, 부정</td>
<td align="center"><strong>참이면 거짓, 거짓이면 참</strong></td>
<td align="center">not(a&lt;100)</td>
</tr>
</tbody></table>
<pre><code class="language-python">&gt;&gt;&gt; a = 99
&gt;&gt;&gt; (a&gt;100) and (a&lt;200)
&gt;&gt;&gt; (a&gt;100) or (a&lt;200)
&gt;&gt;&gt; not(a == 100)        # 틀린게 맞으니까 참!
False
True
True</code></pre>
<h3 id="비트-연산자">비트 연산자</h3>
<blockquote>
<p>비트 연산자란 정수를 2진수로 변환한 후 각 자리의 비트끼리 연산을 수행하는 것을 말함.
비트 연산자의 종류에는 &amp;, , ^, ~, &lt;&lt;, &gt;&gt; 가 있다. 
🚨 주의 : 파이썬에서 <code>0은 False</code>, <code>1은 True</code>(0 이외의 값)이다.</p>
</blockquote>
<table>
<thead>
<tr>
<th align="center">연산자</th>
<th align="center">의미</th>
<th align="center">설명</th>
</tr>
</thead>
<tbody><tr>
<td align="center"><strong>&amp;</strong></td>
<td align="center">비트 논리곱(and)</td>
<td align="center">둘 다 1이면 1</td>
</tr>
<tr>
<td align="center">** | **</td>
<td align="center">비트 논리합(or)</td>
<td align="center">둘 중 하나면 1이면 1</td>
</tr>
<tr>
<td align="center"><strong>^</strong></td>
<td align="center">비트 논리적 배타합 (xor)</td>
<td align="center">둘이 같으면 0, 다르면 1</td>
</tr>
<tr>
<td align="center"><strong>~</strong></td>
<td align="center">비트 부정</td>
<td align="center">1은 0으로, 0은 1로</td>
</tr>
<tr>
<td align="center"><strong>&lt;&lt;</strong></td>
<td align="center">비트 이동(왼쪽)</td>
<td align="center">비트를 왼쪽으로 shift</td>
</tr>
<tr>
<td align="center"><strong>&gt;&gt;</strong></td>
<td align="center">비트 이동(우측)</td>
<td align="center">비트를 오른쪽으로 shift</td>
</tr>
</tbody></table>
<p>❗ 0과 비트 논리곱을 수행하면 어떤 숫자든 무조건 0이 됨(이미 0이 1이 아니므로 거짓)</p>
<h3 id="연산자-우선-순위">연산자 우선 순위</h3>
<p><img src="https://images.velog.io/images/jess_j/post/6b1458bf-b229-4c60-8bd0-1084992413af/image.png" alt="">
출처 : <a href="https://wikidocs.net/1165">https://wikidocs.net/1165</a> </p>
]]></description>
        </item>
        <item>
            <title><![CDATA[변수(Variable)와 데이터 타입]]></title>
            <link>https://velog.io/@jess_j/%EB%B3%80%EC%88%98Variable%EC%99%80-%EB%8D%B0%EC%9D%B4%ED%84%B0-%ED%83%80%EC%9E%85</link>
            <guid>https://velog.io/@jess_j/%EB%B3%80%EC%88%98Variable%EC%99%80-%EB%8D%B0%EC%9D%B4%ED%84%B0-%ED%83%80%EC%9E%85</guid>
            <pubDate>Tue, 23 Mar 2021 16:50:07 GMT</pubDate>
            <description><![CDATA[<h2 id="변수의-선언">변수의 선언</h2>
<blockquote>
<p><strong>변수(Variable)</strong>는 어떠한 값을 저장하는 메모리 공간(그릇).
변수 선언은 즉 값을 저장할 공간을 준비하는 것이며, 변수의 &#39;<strong>이름&#39;과 &#39;타입&#39;</strong>을 부여한다.</p>
</blockquote>
<pre><code class="language-python">boolVar = True
intVar = 0
floatVar = 0.0
strVar = &quot;&quot;</code></pre>
<p>👇👇👇</p>
<pre><code class="language-python">boolVar, intVar, floatVar, strVar = True, 0, 0.0, &quot;&quot;</code></pre>
<hr>
<blockquote>
<p>파이썬은 <code>(우측) = (좌측) 형식</code>으로 변수를 선언하며, 좌측의 값을 우측의 변수에 저장한다.</p>
</blockquote>
<pre><code class="language-python">var1 = var2 = var3 = var4 = 100</code></pre>
<p>👇👇👇</p>
<pre><code class="language-python">var4 = 100
var3 = var4
var2 = var3
var1 = var2</code></pre>
<hr>
<blockquote>
<p>파이썬의 특징이자 장점은 변수에 넣는 데이터 값에 따라 변수의 타입이 유연하게 바뀐다는 것이다.
즉, 별도로 변수의 타입을 변경하는 수고를 들일 필요가 없다.<del>(너무 좋다!)</del></p>
</blockquote>
<pre><code class="language-python">myVar = 100        # 정수형 변수를 생성
type(myVar)         # &lt;class &#39;int&#39;&gt; 가 출력
myVar = 100.0     # 실수값을 변수에 저장
type(myVar)        # &lt;class &#39;float&#39;&gt; 가 출력</code></pre>
<hr>
<h2 id="type-함수">Type() 함수</h2>
<blockquote>
<p>Type(변수) 함수를 사용하여 해당 변수의 데이터 타입을 알 수 있다.</p>
</blockquote>
<pre><code class="language-python">type(boolVar)        # &lt;class &#39;bool&#39;&gt;
type(intVar)        # &lt;class &#39;int&#39;&gt;
type(floatVar)        # &lt;class &#39;float&#39;&gt;
type(strVar)        # &lt;class &#39;stri&#39;&gt;</code></pre>
<hr>
<h2 id="자료형data-type">자료형(Data type)</h2>
<h3 id="1-숫자-자료형">1. 숫자 자료형</h3>
<blockquote>
<p>정수 및 실수 데이터형은</p>
</blockquote>
<ul>
<li><p>사칙 연산(+, -, *, /)</p>
</li>
<li><p>** (제곱)</p>
</li>
<li><p>% (나머지,modular)</p>
</li>
<li><p>// (나눈 후 소수점을 버리는 연산자)
를 사용할 수 있다.</p>
</li>
<li><p>정수형 : 양의 정수, 0, 음의 정수</p>
<pre><code class="language-python">a = 10
b = 0
c = -2</code></pre>
</li>
<li><p>실수형 : 소수점을 포함한 숫자</p>
<pre><code class="language-python">x = 1.23
y = -13.58
z = 2.3e5</code></pre>
</li>
<li><p>복소수형 : 실수와 허수를 모두 표기(i 대신 j 혹은 J를 사용함)</p>
<pre><code class="language-python">a = 3 + 3j
b = 4 + 10J</code></pre>
</li>
</ul>
<hr>
<h3 id="2-불린형">2. 불린형</h3>
<blockquote>
<p>불형(Boolean Data Type)은 참(True)이나 거짓(False)만 저장할 수 있다.</p>
</blockquote>
<pre><code class="language-python">a = True
type(a)        # &lt;class &#39;bool&#39;&gt;</code></pre>
<pre><code class="language-python">a = (999 == 999)     #비교의 결과도 나타냄
b = (1 &gt; 7)
print(a,b)
&gt;&gt;&gt; True False</code></pre>
<hr>
<h3 id="3-문자형-자료형">3. 문자형 자료형</h3>
<blockquote>
<p>&quot;&quot; 혹은 &#39;&#39;  로 감싼 문자 집합</p>
</blockquote>
<pre><code class="language-python">a = &quot;파이썬 공부중임&quot;
a
print(a)
type(a)
&gt;&gt;&gt; &#39;파이썬 공부중임&#39;
&gt;&gt;&gt; 파이썬 공부중임
&gt;&gt;&gt; &lt;class &#39;str&#39;&gt;</code></pre>
<blockquote>
<p>문자열 중간에 &quot; 혹은 &#39;를 출력하려면** 그와 다른 따옴표 종류로 전체를 감싸주어야 한다.**
<code>❓</code>  컴파일러는 한 따옴표 종류로 시작하면 나머지 한 따옴표가 나오면 문자형 변수의 값이 끝났다고 인식하기 때문!</p>
</blockquote>
<pre><code class="language-python">&quot;작은 따옴표는 &#39; 모양이다.&quot;
&#39;큰 따옴표는 &quot; 모양이다.&#39;
&gt;&gt;&gt; 작은 따옴표는 &#39; 모양이다.
&gt;&gt;&gt; 큰 따옴표는 &quot; 모양이다.</code></pre>
<blockquote>
<p>혹은 역슬래시() 뒤에 큰 따옴표나 작은 따옴표를 써도 됨.</p>
</blockquote>
<pre><code class="language-python">a = &quot;이건 큰 따옴표 \&quot; 모양임.&quot;
b = &#39;같은 따옴표로 감싸도 나오지롱! \&#39; 이건 작은 따옴표!&#39;
print(a, b)
&gt;&gt;&gt;  이건 큰 따옴표 &quot; 모양임. 같은 따옴표로 감싸도 나오지롱! &#39; 이건 작은 따옴표!</code></pre>
<blockquote>
<p>문자열 변수에 여러 줄을 넣고 싶다면 문장 중간에 <code>\n을 포함</code>시키거나 <code>따옴표 3개를 연속</code>해서 묶어버리자!</p>
</blockquote>
<pre><code class="language-python">a = &#39;파이썬 \n공부중입니다~&#39;
print(a)
&gt;&gt;&gt; 파이썬
공부중입니다~</code></pre>
<pre><code class="language-python">a = &quot;&quot;&quot;파이썬
공부중입니다~&quot;&quot;&quot;
a
print(a)
&gt;&gt;&gt; &#39;파이썬 \n 만세&#39;     # a값에 \n이 포함된 것을 알 수 있음
파이썬
만세</code></pre>
<blockquote>
<p>문자열은 메모리 한 자리마다 각 하나의 문자를 저장하고 <strong>순서 번호가 부여</strong>되어 그 번호로 각 문자에 접근할 수 있음.</p>
</blockquote>
<ul>
<li>번호는 0부터 시작</li>
<li>음수를 입력하면 문자열의 뒤에서부터 순번 시작(-1 부터)</li>
<li>범위 사용 가능 <code>[시작 위치 : 끝 위치 + 1]</code></li>
</ul>
<pre><code class="language-python">a = &#39;1$ 환율은 1100원입니다.&#39;
a[7:11]
&gt;&gt;&gt; &#39;1100&#39;</code></pre>
]]></description>
        </item>
    </channel>
</rss>