Skip to content

Instantly share code, notes, and snippets.

View xhinker's full-sized avatar

Andrew Zhu xhinker

View GitHub Profile
@xhinker
xhinker / nn_breast_cancer_weights.py
Last active March 24, 2022 17:51
Use NN to build prediction model for breast cancer dataset from scikit-learn.
from sklearn import datasets
from sklearn.preprocessing import StandardScaler
from sklearn.model_selection import train_test_split
import numpy as np
# prepare data
bc = datasets.load_breast_cancer()
X,y = bc.data,bc.target
n_samples,n_features = X.shape
X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.5, random_state=1234)
@xhinker
xhinker / nn_three_weight_w_bias.py
Created March 24, 2022 06:29
Three weights system estimation
import numpy as np
X = np.array(
[[1,2,3,1]
,[2,3,4,1]
,[3,4,5,1]
,[4,3,2,1]
,[12,13,14,1]
,[7,8,9,1]
,[5,2,10,1]]
,dtype=np.float32
@xhinker
xhinker / nn_estimate_one_w.py
Created March 24, 2022 05:43
nn_estimate_one_weight
import numpy as np
# model = y = 2*x + 3
X = np.array([1,2,3,4],dtype=np.float32)
Y = [(2*x + 3) for x in X]
w,b = 0.0,0.0
def forward(x):
return w*x+b
def loss(y,y_pred):
@xhinker
xhinker / pyqt_app.py
Last active April 21, 2022 09:42
pyqt 6 app sample
from PySide6.QtWidgets import (
QApplication
,QMessageBox
,QWidget
,QLabel
,QPushButton
,QVBoxLayout
)
app = QApplication([])
@xhinker
xhinker / python_thread_perf.py
Created August 27, 2021 04:16
Python Multi-Thread without Thread - 5
import time
from threading import Thread
from concurrent.futures import ThreadPoolExecutor,as_completed
def factorize(number):
result = []
for i in range(1, number+1):
if number % i == 0:
result.append(i)
return result