Skip to content

Instantly share code, notes, and snippets.

View okanyenigun's full-sized avatar

Okan Yenigün okanyenigun

View GitHub Profile
@okanyenigun
okanyenigun / voxel1.py
Created September 22, 2022 13:17
voxel create_from_triangle_mesh
import numpy as np
import open3d as o3d
import open3d_tutorial as o3dtut
#get mesh data
bunny = o3d.data.BunnyMesh()
mesh = o3d.io.read_triangle_mesh(bunny.path)
#visualize mesh
mesh.scale(1 / np.max(mesh.get_max_bound() - mesh.get_min_bound()),
@okanyenigun
okanyenigun / lgbm.py
Created September 13, 2022 13:51
light gbm
import lightgbm as lgb
from sklearn.model_selection import GridSearchCV
param_grid = {
'objective': ["binary"],
'metric': ['binary_logloss'],
'boosting': ['gbdt','dart'],
'lambda_l1': [0, 0.1, 0.01],
'bagging_fraction': [0.7, 0.9],
'bagging_freq': [0,1],
@okanyenigun
okanyenigun / observer.py
Created September 12, 2022 14:57
observer design pattern
from abc import ABC, abstractmethod
class IObservable(ABC):
@abstractmethod
def subscribe(self, observer):
"""subscription"""
@abstractmethod
def unsubscribe(self, observer):
@okanyenigun
okanyenigun / catboost.py
Created September 5, 2022 10:16
catboost
import os
import pandas as pd
import numpy as np
np.set_printoptions(precision=4)
import catboost
print(catboost.__version__)
#dataset
from catboost.datasets import amazon
@okanyenigun
okanyenigun / knn.py
Last active August 22, 2022 16:27
knn scratch
import numpy as np
from collections import Counter
class Knn:
def __init__(self, k=5):
self.k = k
def fit(self,X,y):
self.X_train = X
@okanyenigun
okanyenigun / linearregression.scala
Created August 18, 2022 15:48
linear regression scala
// to start a spark session
import org.apache.spark.sql.SparkSession
// to use lineer regression model
import org.apache.spark.ml.regression.LinearRegression
//set logging to level of ERROR
import org.apache.log4j._
Logger.getLogger("org").setLevel(Level.ERROR)
//start a spark Session
@okanyenigun
okanyenigun / gaussian.py
Created August 15, 2022 11:21
gauss naive bayes
import pandas as pd
import matplotlib.pyplot as plt
from sklearn.pipeline import make_pipeline
from sklearn.naive_bayes import GaussianNB
from sklearn.preprocessing import QuantileTransformer
from sklearn.metrics import roc_curve, auc
plt.style.use('bmh')
plt.rcParams['figure.figsize'] = (10, 10)
title_config = {'fontsize': 20, 'y': 1.05}
@okanyenigun
okanyenigun / multinomial.py
Created August 15, 2022 10:57
naive bayes
import nltk
nltk.download('stopwords')
import pandas as pd
import numpy as np
from nltk.corpus import stopwords
import string
from sklearn.feature_extraction.text import CountVectorizer
from sklearn.preprocessing import LabelBinarizer
from sklearn.model_selection import train_test_split
from sklearn.naive_bayes import MultinomialNB
@okanyenigun
okanyenigun / template.py
Created August 12, 2022 11:05
template pattern
from abc import ABC, abstractmethod
class Ticket(ABC):
def method(self):
#read plate
plate = self.read_plate()
#check record
record = self.check_record(plate)
#decide price
@okanyenigun
okanyenigun / xgb.py
Created August 11, 2022 13:19
xgboost
import xgboost as xgb
import numpy as np
from sklearn.datasets import make_regression, make_gaussian_quantiles
from sklearn.metrics import mean_squared_error, confusion_matrix
from sklearn.model_selection import train_test_split
#REGRESSION
#generate regression data
X, y, _ = make_regression(n_samples=10000,#number of samples
n_features=10,#number of features