This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Build prepared classifier on the training data | |
*/ | |
public void fit() { | |
try { | |
classifier.buildClassifier(trainData); | |
} catch (Exception e) { | |
LOGGER.warning(e.getMessage()); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* 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) | |
*/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private static Logger LOGGER = Logger.getLogger("DebitCreditInternalSystem"); | |
private FilteredClassifier classifier; | |
/** | |
* Declare train and test data Instances | |
*/ | |
private Instances trainData; | |
/** | |
* Declare Instance's attributes | |
*/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | |
*/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Naive Bayes | |
*/ | |
import weka.classifiers.bayes.NaiveBayesMultinomial; | |
/** | |
* Weka tools | |
*/ | |
import weka.classifiers.Evaluation; | |
import weka.classifiers.meta.FilteredClassifier; | |
import weka.core.Attribute; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.io.IOException; | |
public class NlpProductClassifier { | |
public static void main(String[] args) throws IOException { | |
NLPClassifier CL = new NLPClassifier(); | |
/** | |
* Sentence detector test | |
*/ |
NewerOlder