Skip to content

Instantly share code, notes, and snippets.

@supachaic
supachaic / Home.js
Last active January 8, 2019 04:40
src/views/Home.js
import React, { Component } from 'react';
import { Link } from 'react-router-dom';
export default class Home extends Component {
render() {
return (
<div>
<h2>BNK48 Facial Recognition App</h2>
<li>
<Link to="/photo">Photo Input</Link>
@supachaic
supachaic / App.js
Last active December 28, 2018 02:34
Facial Recognition SPA
import React, { Component } from 'react';
import { Route, Router } from 'react-router-dom';
import createHistory from 'history/createBrowserHistory';
import './App.css';
import Home from './views/Home';
class App extends Component {
render() {
return (
@supachaic
supachaic / combi.py
Created September 9, 2017 06:35
Search Combination and Vote
def all_subs(idx_list):
if idx_list == []:
return [[]]
indices = all_subs(idx_list[1:])
return indices + [[idx_list[0]] + i for i in indices]
def search_combination(predict_list, y_val, score_name):
idx_list = list(range(len(predict_list)))
def vote(estimators, threshold, X_train, y_train, X_val, y_val, X_test, score_name):
predict_list = []
estimator_list = []
for estimator_name in estimators:
try:
params, val_score, timestamp = get_params(estimator_name)
if val_score > threshold:
print('Ensemble add %s' % estimator_name)
@supachaic
supachaic / randomsearch.py
Created September 9, 2017 05:20
RandomSearch with XGBClassifier
import scipy.stats as st
from sklearn.model_selection import RandomizedSearchCV
from xgboost import XGBClassifier
# Preconfigure estimator and parameters
estimator = XGBClassifier(nthreads=-1)
params = {
"n_estimators": st.randint(3, 40),
"max_depth": st.randint(3, 40),
"learning_rate": st.uniform(0.05, 0.4),
@supachaic
supachaic / vote.py
Created September 9, 2017 05:15
ensemble vote
from sklearn.ensemble import RandomForestClassifier
from sklearn.ensemble import AdaBoostClassifier
from sklearn.ensemble import ExtraTreesClassifier, VotingClassifier
from xgboost import XGBClassifier
rfo = RandomForestClassifier()
ada = AdaBoostClassifier()
ext = ExtraTreesClassifier()
xgb = XGBClassifier()