Adapting "LOcal Rule based Explanation" classification explanation to a regression problem - python

I am working on comparing different explaination techniques of black box prediction problems.
I read the paper about this rulebased explanation technique called LORE (https://arxiv.org/abs/1805.10820) and i have found the official repository (https://github.com/riccotti/LORE). They apply it to a classification problem, but i would need to use it on regression problem with a neural network i have created.
Since there's no documentation, and comments in code are really poor, i am having difficulty trying to understand how to change the code to adapt it to my case, so i was wondering if anyone had the same problem and, in case, how they solved it.

Related

keras normalization methods

Are the below two lines basically the same thing?
tf.keras.layers.experimental.preprocessing.Normalization()
tf.keras.layers.Normalization()
I am trying to normalize(standardize in this case) the inputs for
fitting the neural network model using Tensorflow. After googling I found the two choices above. They seem to be the same thing but I'm not so sure. If they aren't the same, could anyone tell me the exact difference?
They are technically the same thing. But you should use this one
tf.keras.layers.Normalization()
Because this one is not available anymore.
tf.keras.layers.experimental.preprocessing.Normalization()

Does some of the Keras pre-trained networks need particular pre-processing before being used?

Hi everybody I have this basic question that isn't related to any particular piece of code
I'm following some papers about the use of CNN to assess the quality of images and, in all of them, the networks that are being used are the ones offered by keras-applications (VGG16-19, ResNet..) with some variations depanding on the paper
Often, in these works, the variations to the basic networks aren't bound to them but valid for the whole paper, meaning the only differences should be the images input size and the specific image pre-processing function, the latters also provided within keras-application."basic network name"
My question is if what I'm doing is sufficient because, in fact, when I try to replicate the results of a paper, there are some networks that underperform (the results aren't that bad, meaning the network is still training in the right direction) compared to the expected results but others don't. In particular, I had problems with ResNet50 and VGG16 but not with MobileNet v1/v2 and InceptionV3: no matter how much learning rate (or even the dropouts) I use, the validation loss obtained at the end of the trainings are almost 10% worse to the published results when using ResNet or VGG
I'm sure the code is correct, as I said the only difference when changing the loaded basic network is which image pre-processing function is selected. At this point I have two possible ideas:
I'm using a different setup compared to the papers (tensorflow 1.15) and the Keras-applications has some kind of bug. In fact the last published version of that module has some bugs regarding the pre-processing in that the code threw an exception when I tried it for the first time. By digging on their Git page I found that that problem was endeed a bug that had already been fixed within the last commit (not yet published inside a proper release). Sadly, that doesn't mean its behaviour isn't bugged but I can't verify that by myself
Some networks, such as VGG16 and ResNet50, have more requirements to work properly and I'm missing them, what can you tell me from your experience? Have you found yourself in a situation like mine? Note that I'm not talking about parameters such as the dropouts, learning rates etc.. because they are provided by the papers, I'm wondering if for example the function, and relative interpolation, used to load the images could matter in any kind of way

How can I teach a model using single class in machine learning using Keras?

I am new to machine learning and currently got a good start in binary and multi-class model development using Keras.
Now I would like to learn how I could teach a model for outlier image detection.
I used the binary classification method to teach the outlier class by separating the outlier class from other image class. This method does not work as soon as I give an image that was not during teaching and the outcome is totally unpredictable.
Where should I start this ?
Is there any online tutorial(s) I could follow ?
There isn't such a thing as single-class classification. Your problem is binary since you are differentiating between two classes (normal, outlier).
Having said that, your problem might be too little data for the outliers. Unbalanced classes might not produce good results so you should try that first. The second problem might be the model's parameters not having the right values, this requires some experimentation on your part.
I can't say much since the problem is so vague. If you want to post some code and some results I could tell more.

How to start to recognize object in opencv

My final goal is to dynamically recognize different object which is 2D and often has same appearance(2D deck game) in video. I was studying opencv-python tutorial, but there aren't any topic about this, so I want to know what topic, library or function should I learn to reach my goal. Thanks.
You can try several Machine Learning techniques. You may get inspiration from Viola-Jones or Histograms of Oriented Gradients + SVM algorithms (even though those algorithms solve a problem that may differ yours, I had plenty of insights from them). In other words, try "sliding" a window along a horizontal and vertical axes of predefined aspect ratio and try to recognize the Region Of Interest with a model of your choice (CNN, SVM, Logistic Regression etc.). But the problem may be that you will need to train a model, which may require a lot of data.
Or you can do a template matching, which is more of Image Processing problem rather than Machine Learning. It would not require dataset and training, but it will be sensitive to noises, lighting, and position.
Good luck!

Complex Regression Model in Python

For a project I am working on, I need to find a model for the data graphed below that includes a sine or cosine component (hard to tell from the image but the data does follow a trig-like function for each period, although the amplitude/max/mins are changing).
data
I originally planned on finding a simple regression model for my data using Desmos before I saw how complex the data was, but alas, I do not think I am capable of determining what equation to use without the help of Python. I don't have much experience with regression in Python, I've only done basic linear modeling where I knew the type of equation and was just determining the coefficients/constants. Could anyone offer a guiding example, git code, or resources that would be useful for this?
Your question is pretty generic and looking at the graph, we cannot tell much about the data to give you a more detailed answer, but i'd say have a look at OLS
https://www.statsmodels.org/dev/generated/statsmodels.regression.linear_model.OLS.html
You could also look at scikit learn for the various regression models it provides.
http://scikit-learn.org/stable/modules/linear_model.html
Essentially,these packages will help you figure our the equation you are looking to have for your data.
Also, looks like your graph has an outlier ? Please note regression is very sensitive to outliers, so you may want to handle those data points before fitting the model.

Categories

Resources