Skip to content

Instantly share code, notes, and snippets.

View AlexTitovWork's full-sized avatar
🎯
Focused

Alex T AlexTitovWork

🎯
Focused
View GitHub Profile
@AlexTitovWork
AlexTitovWork / faces_detection.py
Last active September 16, 2021 19:31
faces detection based on yolo3 standard model
# load yolov3 model and perform object detection
# based on https://github.com/experiencor/keras-yolo3
# Partically coded by Interceptor 16.09.2021
# @name Alex Titov
# @email alexeytitovwork@gmail.com
import numpy as np
from numpy import expand_dims
from keras.models import load_model
from keras.preprocessing.image import load_img
from keras.preprocessing.image import img_to_array
@AlexTitovWork
AlexTitovWork / newton_method.py
Created January 15, 2021 17:24
# Newton's method # Second order method
import numpy as np
# ################################################################################
# Newton's method
# Second order method
def Newtons_method(max_iters, threshold, XY_init, func, grad_func, second_grad, learning_rate=0.05):
X, Y = XY_init
w = np.array([X, Y])
w_history_N = X, Y
f_history_N = func(X, Y, extra_param)
delta_w = np.zeros(XY_init.shape)
@AlexTitovWork
AlexTitovWork / gradient_descent.py
Created January 15, 2021 15:01
# Gradient descent or Cauchy method # First order method
import numpy as np
# ################################################################################
# Gradient descent or Cauchy method
# First order method
def gradient_descent(max_iters, threshold, XY_init, func, grad_func, learning_rate=0.05):
X, Y = XY_init
w = np.array([X, Y])
w_history = X, Y
f_history = func(X, Y, extra_param)
delta_w = np.zeros(XY_init.shape)
@AlexTitovWork
AlexTitovWork / plotHimmelblau.py
Last active March 6, 2024 09:12
Plotting the Himmelblau function
import numpy as np
import matplotlib.pyplot as plt
# ################################################################################
def plot_function():
# Make data.
X = np.arange(-5, 5, 0.25)
Y = np.arange(-5, 5, 0.25)
X, Y = np.meshgrid(X, Y)
Z = (X ** 2 + Y - 11) ** 2 + (X + Y ** 2 - 7) ** 2
/**
* Build prepared classifier on the training data
*/
public void fit() {
try {
classifier.buildClassifier(trainData);
} catch (Exception e) {
LOGGER.warning(e.getMessage());
}
}
@AlexTitovWork
AlexTitovWork / transformWeka.java
Last active December 6, 2019 21:38
transformWeka.java
/**
* load training data and set feature generators
*/
public void transform() {
try {
trainData = loadDataset(TRAIN_DATA);
saveArff(trainData, TRAIN_ARFF_ARFF);
/**
* create the filter and set the attribute to be transformed from text into a feature vector (the last one)
*/
private static Logger LOGGER = Logger.getLogger("DebitCreditInternalSystem");
private FilteredClassifier classifier;
/**
* Declare train and test data Instances
*/
private Instances trainData;
/**
* Declare Instance's attributes
*/
DebitCreditWekaClassifier() {
/*
* Class for running an arbitrary classifier on data that has been passed through an arbitrary filter.
*/
classifier = new FilteredClassifier();
/**
* Class for building and using a multinomial Naive Bayes classifier. For more information see,
* Andrew Mccallum, Kamal Nigam: A Comparison of Event Models for Naive Bayes Text Classification.
* https://weka.sourceforge.io/doc.dev/weka/classifiers/bayes/NaiveBayesMultinomial.html
*/
@AlexTitovWork
AlexTitovWork / DebitCreditWekaClassifierConstructor.java
Last active December 4, 2019 21:49
constructor of DebitCreditWekaClassifier class
/**
* Naive Bayes
*/
import weka.classifiers.bayes.NaiveBayesMultinomial;
/**
* Weka tools
*/
import weka.classifiers.Evaluation;
import weka.classifiers.meta.FilteredClassifier;
import weka.core.Attribute;
@AlexTitovWork
AlexTitovWork / NlpProductClassifier.java
Created October 27, 2019 14:45
NlpProductClassifier main test
import java.io.IOException;
public class NlpProductClassifier {
public static void main(String[] args) throws IOException {
NLPClassifier CL = new NLPClassifier();
/**
* Sentence detector test
*/