Neural Network์ ์๋ ์๋ฆฌ๋ฅผ ์์๋ณด๊ธฐ์ํด Logistic Regression์ hidden layer๋ฅผ 1์ธต ์ถ๊ฐํด๋ณธ๋ค. ์ด hidden layer๋ฅผ ์ถ๊ฐํจ์ผ๋ก์ ๊ธฐ์กด์ Logistic Regression์ผ๋ก ํ๋ณํ์ง ๋ชปํ๋ XOR problem๋ ํด๊ฒฐ ํ ์ ์๊ฒ๋๋ค. ๊ทธ ์ด์ ๋ hidden layer๊ฐ ์ถ๊ฐํ๊ฒ๋๋ฉด ๊ตฌ๋ณ์ ๊ธฐ์ค์ด ๋๋ hyper plane์ ์ฌ๋ฌ๊ฐ๋ฅผ ์ฌ์ฉํ๊ฒ ๋์ ์ด๋ถ๋ฒ์ ์ธ ์์ธก์ ํ์ง์๊ณ ๋์ฑ ์ ์ฐํ๊ฒ ์์ธก์ ํ ์ ์๊ฒ ๋๋ค.

logistic function์ ์ค์ ์ ์ฒด์งํฉ $x$๋ฅผ [0, 1] ์ฌ์ด ๊ฐ์ผ๋ก ์ถ๋ ฅํด์ฃผ๋ ํจ์๋ค.
\[y = \frac{1}{1+e^{-x}}\]

data shape : 2000000 x 28
# data analysis and wrangling
import pandas as pd
import numpy as np
import random as rnd
pd.set_option('display.max_columns', 100)
# visualization
import seaborn as sns
import matplotlib.pyplot as plt
%matplotlib inline
# machine learning
from sklearn.linear_model import LogisticRegression
from sklearn.svm import SVC, LinearSVC
from sklearn.ensemble import RandomForestClassifier
from sklearn.neighbors import KNeighborsClassifier
from sklearn.naive_bayes import GaussianNB
from sklearn.linear_model import Perceptron
from sklearn.linear_model import SGDClassifier
from sklearn.tree import DecisionTreeClassifier
itertools๋ ๋ฒ๋ฆด๊ฒ ํ๋์๋ ์์ฃผ ์ ์ฉํ ๋ชจ๋์ด๋ค.
๋ฌดํ ์ดํฐ๋ ์ดํฐ
countcyclerepeat์ดํฐ๋ ์ดํฐ
accumulatechainchain.from_iterablecompressdropwhilefilterfalsegroupbyisliceteezip_longest์กฐํฉํ
productpermutationscombinationscombinations_with_replacement
functools ๋ชจ๋์์ ํจ์๊ฐ ๊ฝค๋ง์ง๋ง ๋ด๊ฐ ํ๋จํ์ ๋, ์ฝ๋ฉํ
์คํธ์ ํ์ํ ํจ์ ๋ช๊ฐ์ง๋ค๋ง ์ถ๋ ค๋ณด์๋ค. ์ฝ๋ฉํ
์คํธ์๋ ๋ฑํ ๊ฐ์ฒด์งํฅ์ ์ธ ํ๋ก๊ทธ๋จ์ด ํ์ํ์ง ์๊ธฐ ๋๋ฌธ์, class์ ๊ด๋ จ๋ ํจ์๋ ์ ์ธํ์๋ค.
lru_cachereduce

Java๋ฌธ์ (15) + SQL ๋ฌธ์ (9) ์ ์ธ
from collections import defaultdict
from itertools import groupby
def solution(s):
lumps = defaultdict(lambda: defaultdict(int))
for char, group in groupby(s):
lumps[char][len(list(group))] += 1
unpretty = ((n := len(s)) - 1) * n * (n + 1) // 6
for lump in lumps.values():
total = sum(l * count for l, count in lump.items())
both_side = sum(lump.values())
for i in range(1, max(lump) + 1):
unpretty -= total * (total - 1) // 2
total -= both_side
both_side -= lump[i]
return unpretty