leechungpa
    • Create new note
    • Create a note from template
      • Sharing URL Link copied
      • /edit
      • View mode
        • Edit mode
        • View mode
        • Book mode
        • Slide mode
        Edit mode View mode Book mode Slide mode
      • Customize slides
      • Note Permission
      • Read
        • Only me
        • Signed-in users
        • Everyone
        Only me Signed-in users Everyone
      • Write
        • Only me
        • Signed-in users
        • Everyone
        Only me Signed-in users Everyone
      • Engagement control Commenting, Suggest edit, Emoji Reply
    • Invite by email
      Invitee

      This note has no invitees

    • Publish Note

      Share your work with the world Congratulations! 🎉 Your note is out in the world Publish Note

      Your note will be visible on your profile and discoverable by anyone.
      Your note is now live.
      This note is visible on your profile and discoverable online.
      Everyone on the web can find and read all notes of this public team.
      See published notes
      Unpublish note
      Please check the box to agree to the Community Guidelines.
      View profile
    • Commenting
      Permission
      Disabled Forbidden Owners Signed-in users Everyone
    • Enable
    • Permission
      • Forbidden
      • Owners
      • Signed-in users
      • Everyone
    • Suggest edit
      Permission
      Disabled Forbidden Owners Signed-in users Everyone
    • Enable
    • Permission
      • Forbidden
      • Owners
      • Signed-in users
    • Emoji Reply
    • Enable
    • Versions and GitHub Sync
    • Note settings
    • Note Insights New
    • Engagement control
    • Make a copy
    • Transfer ownership
    • Delete this note
    • Save as template
    • Insert from template
    • Import from
      • Dropbox
      • Google Drive
      • Gist
      • Clipboard
    • Export to
      • Dropbox
      • Google Drive
      • Gist
    • Download
      • Markdown
      • HTML
      • Raw HTML
Menu Note settings Note Insights Versions and GitHub Sync Sharing URL Create Help
Create Create new note Create a note from template
Menu
Options
Engagement control Make a copy Transfer ownership Delete this note
Import from
Dropbox Google Drive Gist Clipboard
Export to
Dropbox Google Drive Gist
Download
Markdown HTML Raw HTML
Back
Sharing URL Link copied
/edit
View mode
  • Edit mode
  • View mode
  • Book mode
  • Slide mode
Edit mode View mode Book mode Slide mode
Customize slides
Note Permission
Read
Only me
  • Only me
  • Signed-in users
  • Everyone
Only me Signed-in users Everyone
Write
Only me
  • Only me
  • Signed-in users
  • Everyone
Only me Signed-in users Everyone
Engagement control Commenting, Suggest edit, Emoji Reply
  • Invite by email
    Invitee

    This note has no invitees

  • Publish Note

    Share your work with the world Congratulations! 🎉 Your note is out in the world Publish Note

    Your note will be visible on your profile and discoverable by anyone.
    Your note is now live.
    This note is visible on your profile and discoverable online.
    Everyone on the web can find and read all notes of this public team.
    See published notes
    Unpublish note
    Please check the box to agree to the Community Guidelines.
    View profile
    Engagement control
    Commenting
    Permission
    Disabled Forbidden Owners Signed-in users Everyone
    Enable
    Permission
    • Forbidden
    • Owners
    • Signed-in users
    • Everyone
    Suggest edit
    Permission
    Disabled Forbidden Owners Signed-in users Everyone
    Enable
    Permission
    • Forbidden
    • Owners
    • Signed-in users
    Emoji Reply
    Enable
    Import from Dropbox Google Drive Gist Clipboard
       Owned this note    Owned this note      
    Published Linked with GitHub
    • Any changes
      Be notified of any changes
    • Mention me
      Be notified of mention me
    • Unsubscribe
    # US crime [YonseiESC ESC-21SPRING](https://github.com/YonseiESC/ESC-21SPRING) 5조 한인욱, 강동인, 신예진, 이청파, 정유진 <br> <br> ## [US crime](http://archive.ics.uci.edu/ml/datasets/communities+and+crime) ![](https://i.imgur.com/7Igf4gk.png) <br> - murders 살인 / rapes 강간/ robberies 강도/ assaults 폭행 / burglaries (절도,강도 목적의) 주거침입/ larcenies 절도 / autoTheft 차량탈취 / arsons 방화, 8종류의 범죄에 대한 범죄지도 완성하기 - 강력범죄 : `murders`, `rapes`, `robberies`, `assaults` - 비강력 범죄: `burglaries`,`larcenies`,`autoTheft`,`arsons` - 147개의 변수, 2215개의 observation - 인구 관련 독립변수: 가구당 평균 구성 인원, 인구밀도 - 개인 특성 독립변수: 인종, 나이, 학력, 미/이혼, 가정, 이민 - 경제 관련 독립변수: 고용, 소득, 부동산 - 결측치가 아닌 지역들을 기반으로 모델을 세워서 예측되어야 하는 범죄 변수들의 결측치 채우기 <br> <br> ## Data 문제점! - 변수별 scale이 다름 ->scaling - skewed된 변수들이 있음->transformation - 변수들 간에 correlation이 높음-> correlation높은 변수들 제거 - 변수가 너무 많음-> 변수제거 ![](https://i.imgur.com/Q73GUwu.png) <br> <br> ## 변수 제거 ![](https://i.imgur.com/fFBVQ3j.png) - 결측치 비율이 84%이상인 변수 제거 - y변수 중 `murders`, `murderperpop`과 같이 구성되어 있는 것들은 `murders`제거하고 `murderperpop`사용 - `NumKidsBornNeverMar`, `PctKidsBornNeverMar` 같은 의미의 비율 변수 존재하기 때문에 제거 <br> <br> ## 결측치 평균으로 채우기 ```{python3} # NA 지우기 OtherPerCap_mean = data.OtherPerCap.mean() data.loc[data.OtherPerCap.isna(),'OtherPerCap'] = OtherPerCap_mean ``` - OtherPerCap: 결측치 1개 평균으로 대체 <br> <br> ## Correlation 처리 US crime data는 아래 그림에서 볼 수 있는 것처럼 몇개 변수들 간에 높은 correlation이 나타난다. 따라서 이에 대한 전처리 필요! ![](https://i.imgur.com/jlCPeoQ.png) <br> 1. `agePct12t21`, `agePct12t29`, `agePct16t24` - age 변수의 경우 A to B 살의 비율이 된다. - 당연히 나이의 범위가 겹치므로 Corr 이 높다. - 변환: `agePct22t29`(agePct12t29 - agePct12t21)` 로 변환 - 제거변수: `agePct16t24` 2. `medFamInc`, `perCapInc`, `whitePerCap` - `medFamInc` : family 중위 소득 - `perCapInc`: 1인당 소득 - `whitePerCap`: 1인당 백인 소득 - 제거변수: `perCapInc` (타 1인당 인종 소득이 1인당 소득을 구성) 3. `PctPopUnderPov`, `PctLess9thGrade`, `PctNotHSGrad` - `PctPopUnderPov` : poverty level 하의 비율 - `PctLess9thGrade`: 25세 이상 중 9학년(대학)미만 비율 - `PctNotHSGrad`: 25세 이상 중 고졸 미만 비율 - 제거변수: `PctNotHSGrad` (`PctLess9thGrade`에 포함됨) 4. `MalePctDivorce`, `FemalePctDiv`, `TotalPctDiv` - `FemalePctDiv` : 여성이혼비율 - `MalePctDivorce` : 남성 이혼 비율 - `TotalPctDiv`: 총 이혼비율 - 제거변수: `FemalePctDiv`,`MalePctDivorce` (`TotalPctDiv`에 포함) 5. `PctFam2Par`,`PctKids2Par`,`PctYoungKids2Par`,`PctTeen2Par` - `PctFam2Par`: 두부모+kids 가족 비율 - `PctKids2Par`: 두 부모와 함께 거주하는 kids 비율 - `PctYoungKids2Par`: 두 부모와 함께 거주하는 4살 이하의 아동 비율 - `PctTeen2Par` : 두 부모와 함께 거주하는 12-17살 아이들 비율 - 제거변수: `PctKids2Par`,`PctYoungKids2Par`,`PctTeen2Par` 6. `PctWorkMomYoungKids`,`PctWorkMom` - `PctWorkMomYoungKids` : 6살 이하의 아이가 있는 워킹맘의 비율 - `PctWorkMom`: 18살 이하의 아이가 있는 워킹맘의 비율 - 제거변수: `PctWorkMomYoungKids` 7. `PctImmigRecent` , `PctImmigRec5`, `PctImmigRec8`, `PctImmigRec10` - `PctImmigRecent`: 지난 3년 이내에 이민한 이민자의 비율 - 제거변수: `PctImmigRec5`, `PctImmigRec8`, `PctImmigRec10` 8. `PctRecentImmig`, `PctRecImmig5`, `PctRecImmig8`, `PctRecImmig10` - `PctRecentImmig`: 지난 3년 이내에 이민한 인구의 비율 - 제거변수: `PctRecImmig5`, `PctRecImmig8`, `PctRecImmig10` 9. `PctLargHouseFam`,`PctLargHouseOccup` - `PctLargHouseFam`: 가족이 6명 이상인 비율 - `PctLargHouseOccup`: 구성원이 6명 이상인 all occupied households 의 비율 - 제거변수: `PctLargHouseOccup` 10. `OwnOccLowQuart`, `OwnOccMedVal`, `OwnOccHiQuart`, `RentLowQ`, `RentMedian RentHighQ`, `MedRent` - `own` : 집을 소유한 사람의 집값 - `rent` : 집세를 내는 사람의 입장에서 집세 - `med` : 총 집세 중앙값 - 다소 corr이 높게 나타나지만, 각각의 칼럼의 의미가 있다고 생각해 일단 보류 11. `NumInShelters`, `NumStreet` - `NumInShelters` : 노숙자 보호소에 있는 노숙자 수 - `NumStreet` : 길에서 지내는 노숙자의 수 - 제거변수: 없음 <br> <br> ## scaling - 변수들의 단위가 다르기 때문에 **standard scaling**을 통해 scaling을 해줌. - (x-평균)/표준편차 `agePct12t29` ![](https://imgur.com/4VeZlMC.png) <br> ## 최종 변수 - 독립변수 84개, 종속변수 8개 - 독립변수: - 개인 특성: 인종 `racepctblack` ,`racePctWhite` , 학력 `PctLess9thGrade`, 나이 `agePct12t29`, `agePct22t29` , 이민 `PctImmigRecent` 등등 - 인구 관련: 가구당 평균 구성 인원 `PctLargHouseFam`, 인구밀도 `PopDens`등등 - 경제 관련: 소득 `medIncome`, `medFamInc`, 빈곤 `PctPopUnderPov`, `NumInShelters` 등등 <br> - 종속변수 : - `murdPerPop` `rapesPerPop` `robbbPerPop` `assaultPerPop` `burglPerPop` `larcPerPop` `autoTheftPerPop` `arsonsPerPop` <br> <br> ## 시각화 ![](https://i.imgur.com/7avKb4l.png) - Smart Monkey 라는 스프레드 부가기능을 이용해 위치를 지오코딩 - Mexicocity 같은 미국이 아닌 도시가 섞여있음 그래서 이를 제외하고 시각화 ![](https://i.imgur.com/iRa7bMU.png) - 시각화를 할 때에는 인구당 범죄를 시각화 하기로 하였음 - 100K의 인구수 당 범죄의 수 - 우리가 구하고자 하는 8종의 범죄에 대해서 곁측치를 제외한 범죄 수를 시각화 ![](https://i.imgur.com/UFKCLA3.png) - 진한 남색일수록 범죄율이 높은것 (자세한것은 링크에서 설명) ![](https://i.imgur.com/vMJRPOV.png) ![](https://i.imgur.com/0xk02Up.png) [시각화 링크](https://public.tableau.com/profile/haninwook#!/vizhome/Book1_16216167187690/Final1) <br> <br> ## 계획 - 변수별 transformation 필요 (Log? Power? TBD) ![](https://i.imgur.com/00icRnn.png) NumUnderPov - 범죄별로 모델링 진행 (Frequentist vs Bayesian) - Feature importance, 계수 등에 대한 분석 - Y 결측치 데이터로 범죄 예측 후 범죄지도 완성

    Import from clipboard

    Paste your markdown or webpage here...

    Advanced permission required

    Your current role can only read. Ask the system administrator to acquire write and comment permission.

    This team is disabled

    Sorry, this team is disabled. You can't edit this note.

    This note is locked

    Sorry, only owner can edit this note.

    Reach the limit

    Sorry, you've reached the max length this note can be.
    Please reduce the content or divide it to more notes, thank you!

    Import from Gist

    Import from Snippet

    or

    Export to Snippet

    Are you sure?

    Do you really want to delete this note?
    All users will lose their connection.

    Create a note from template

    Create a note from template

    Oops...
    This template has been removed or transferred.
    Upgrade
    All
    • All
    • Team
    No template.

    Create a template

    Upgrade

    Delete template

    Do you really want to delete this template?
    Turn this template into a regular note and keep its content, versions, and comments.

    This page need refresh

    You have an incompatible client version.
    Refresh to update.
    New version available!
    See releases notes here
    Refresh to enjoy new features.
    Your user state has changed.
    Refresh to load new user state.

    Sign in

    Forgot password

    or

    By clicking below, you agree to our terms of service.

    Sign in via Facebook Sign in via Twitter Sign in via GitHub Sign in via Dropbox Sign in with Wallet
    Wallet ( )
    Connect another wallet

    New to HackMD? Sign up

    Help

    • English
    • 中文
    • Français
    • Deutsch
    • 日本語
    • Español
    • Català
    • Ελληνικά
    • Português
    • italiano
    • Türkçe
    • Русский
    • Nederlands
    • hrvatski jezik
    • język polski
    • Українська
    • हिन्दी
    • svenska
    • Esperanto
    • dansk

    Documents

    Help & Tutorial

    How to use Book mode

    Slide Example

    API Docs

    Edit in VSCode

    Install browser extension

    Contacts

    Feedback

    Discord

    Send us email

    Resources

    Releases

    Pricing

    Blog

    Policy

    Terms

    Privacy

    Cheatsheet

    Syntax Example Reference
    # Header Header 基本排版
    - Unordered List
    • Unordered List
    1. Ordered List
    1. Ordered List
    - [ ] Todo List
    • Todo List
    > Blockquote
    Blockquote
    **Bold font** Bold font
    *Italics font* Italics font
    ~~Strikethrough~~ Strikethrough
    19^th^ 19th
    H~2~O H2O
    ++Inserted text++ Inserted text
    ==Marked text== Marked text
    [link text](https:// "title") Link
    ![image alt](https:// "title") Image
    `Code` Code 在筆記中貼入程式碼
    ```javascript
    var i = 0;
    ```
    var i = 0;
    :smile: :smile: Emoji list
    {%youtube youtube_id %} Externals
    $L^aT_eX$ LaTeX
    :::info
    This is a alert area.
    :::

    This is a alert area.

    Versions and GitHub Sync
    Get Full History Access

    • Edit version name
    • Delete

    revision author avatar     named on  

    More Less

    Note content is identical to the latest version.
    Compare
      Choose a version
      No search result
      Version not found
    Sign in to link this note to GitHub
    Learn more
    This note is not linked with GitHub
     

    Feedback

    Submission failed, please try again

    Thanks for your support.

    On a scale of 0-10, how likely is it that you would recommend HackMD to your friends, family or business associates?

    Please give us some advice and help us improve HackMD.

     

    Thanks for your feedback

    Remove version name

    Do you want to remove this version name and description?

    Transfer ownership

    Transfer to
      Warning: is a public team. If you transfer note to this team, everyone on the web can find and read this note.

        Link with GitHub

        Please authorize HackMD on GitHub
        • Please sign in to GitHub and install the HackMD app on your GitHub repo.
        • HackMD links with GitHub through a GitHub App. You can choose which repo to install our App.
        Learn more  Sign in to GitHub

        Push the note to GitHub Push to GitHub Pull a file from GitHub

          Authorize again
         

        Choose which file to push to

        Select repo
        Refresh Authorize more repos
        Select branch
        Select file
        Select branch
        Choose version(s) to push
        • Save a new version and push
        • Choose from existing versions
        Include title and tags
        Available push count

        Pull from GitHub

         
        File from GitHub
        File from HackMD

        GitHub Link Settings

        File linked

        Linked by
        File path
        Last synced branch
        Available push count

        Danger Zone

        Unlink
        You will no longer receive notification when GitHub file changes after unlink.

        Syncing

        Push failed

        Push successfully