category
stringclasses
107 values
title
stringlengths
15
179
question_link
stringlengths
59
147
question_body
stringlengths
53
33.8k
answer_html
stringlengths
0
28.8k
__index_level_0__
int64
0
1.58k
implement classification
Can anyone teach me how to implement multiple binary classification for SVM by openCV?
https://stackoverflow.com/questions/27766889/can-anyone-teach-me-how-to-implement-multiple-binary-classification-for-svm-by-o
<p>I have read the article about the following three links</p> <p><a href="http://answers.opencv.org/question/42623/face-recognition-using-svm/" rel="nofollow noreferrer">http://answers.opencv.org/question/42623/face-recognition-using-svm/</a></p> <p><a href="https://stackoverflow.com/questions/14694810/using-opencv-...
134
implement classification
PyTorch correct implementation of classification on an autoencoder
https://stackoverflow.com/questions/78056762/pytorch-correct-implementation-of-classification-on-an-autoencoder
<p><strong>EDIT: embarrassingly my error was shuffling the data only and not the labels.</strong></p> <p>I was given an assignment to create an lstm autoEncoder in pytorch to reconstruct mnist images. next the assignment asked to modify the network to also allow for classification of the reconstructed images, an import...
<p>Since your classification layer is a single linear layer that takes the reconstruction predictions as input and outputs the class predictions, the network has to find a hard balance between reconstruction quality and linear separability of the predicted images.</p> <p>If you want to keep this architecture, you shoul...
135
implement classification
How to implement LSTM for binary classification?
https://stackoverflow.com/questions/60775942/how-to-implement-lstm-for-binary-classification
<p>I am a beginner in Deep Learning. I trying to implement LSTM for binary classification.I have EEG dataset which has 11 features(continuous valued) and 1 output which is either 0 or 1. The subjects(persons) were watching a 5 minute long video and after every 30 seconds they gave their review whether they like(1) it o...
136
implement classification
Scikit-learn vs. WEKA classification model implementation
https://stackoverflow.com/questions/66478239/scikit-learn-vs-weka-classification-model-implementation
<p>Am I correct to assume that the classification models implementations in scikit-learn and WEKA (e.g. Naive Bayes, Random Forest etc.) produce the same results (not taking processing time and such into account)?</p> <p>I am asking, because I wrote my pipeline in Python and would like to use scikit-learn for easy inte...
137
implement classification
How to implement F1 score in LightGBM for multi-class classification in R?
https://stackoverflow.com/questions/72213497/how-to-implement-f1-score-in-lightgbm-for-multi-class-classification-in-r
<p>I am using the LightGBM package in R to create my model. I have already defined a function that calculates macro-F1 (defined as the average of F1s throughout all class predictions). I need to report CV macro-F1, so I would like to embed this score into <code>lgb.cv</code>. Nevertheless, the metric is not available i...
138
implement classification
How to implement image classification using just convolutional layers?
https://stackoverflow.com/questions/66446915/how-to-implement-image-classification-using-just-convolutional-layers
<p>I'm trying to make an image classification model that outputs a prediction based on a sliding window. The only way to do that is to have the network's output layer as a Conv2D layer.</p> <p>Here is my model architecture:</p> <pre><code>inputs = Input((None, None, 3)) x = Conv2D(filters = 32, kernel_size = (3,3), st...
139
implement classification
Tensorflow implementation for bank transaction classification
https://stackoverflow.com/questions/57001614/tensorflow-implementation-for-bank-transaction-classification
<p>I am building a simple machine learning model that takes bank transactions as input (see features below) and I want to predict the spend category (label). I have already worked through some beginner's tutorials, such as <a href="https://developers.google.com/machine-learning/crash-course/" rel="nofollow noreferrer">...
<p>This seems to be a classification problem, but there are some issues for me with your question, there are some steps that you need to take before dumping all the data into a model.</p> <p>The thing is that I see no preprocessing of the data, are you using all features? Do they need to be scaled? Do you need to enco...
140
implement classification
Implementation of Focal loss for multi label classification
https://stackoverflow.com/questions/57635169/implementation-of-focal-loss-for-multi-label-classification
<p>trying to write focal loss for multi-label classification </p> <pre><code>class FocalLoss(nn.Module): def __init__(self, gamma=2, alpha=0.25): self._gamma = gamma self._alpha = alpha def forward(self, y_true, y_pred): cross_entropy_loss = torch.nn.BCELoss(y_true, y_pred) p_t...
<p>You shouldn't inherit from <code>torch.nn.Module</code> as it's designed for modules with learnable parameters (e.g. neural networks).</p> <p>Just create normal functor or function and you should be fine.</p> <p>BTW. If you inherit from it, you should call <code>super().__init__()</code> somewhere in your <code>__in...
141
implement classification
Implementation of text classification in MATLAB with naive bayes
https://stackoverflow.com/questions/27562711/implementation-of-text-classification-in-matlab-with-naive-bayes
<p>I want to implement text classification with Naive Bayes algorithm in MATLAB. I have for now 3 matrices:</p> <ol> <li>Class priors (8*2 cell - 8 class names, for each class its % from the training) </li> <li>Training Data: word count matrices - (15000*9 cell- for each class, counting of every feature (word) . the ...
<p>Here is an example of Naive Bayes classification,</p> <pre><code>x1 = 5 * rand(100,1); y1 = 5 * rand(100,1); data1 = [x1,y1]; x2 = -5 * rand(100,1); y2 = 5 * rand(100,1); data2 = [x2,y2]; x3 = -5 * rand(100,1); y3 = -5 * rand(100,1); data3 = [x3,y3]; traindata = [data1(1:50,:);data2(1:50,:);data3(1:50,:)]; testdat...
142
implement classification
How to implement network using Bert as a paragraph encoder in long text classification, in keras?
https://stackoverflow.com/questions/58703885/how-to-implement-network-using-bert-as-a-paragraph-encoder-in-long-text-classifi
<p>I am doing a long text classification task, which has more than 10000 words in doc, I am planing to use Bert as a paragraph encoder, then feed the embeddings of paragraph to BiLSTM step by step. The network is as below:</p> <blockquote> <p>Input: (batch_size, max_paragraph_len, max_tokens_per_para,embedding_size)</p...
<p>I believe you can check the following <a href="https://medium.com/@brn.pistone/bert-fine-tuning-for-tensorflow-2-0-with-keras-api-9913fc1348f6" rel="nofollow noreferrer">article</a>. The author shows how to load a pre-trained BERT model, embed it into a Keras layer and use it into a customized Deep Neural Network. ...
143
implement classification
Implementing a Basic Neural Network to Perform Classification with Neuroph
https://stackoverflow.com/questions/74893033/implementing-a-basic-neural-network-to-perform-classification-with-neuroph
<p>I'm very new to neural networks, and decided to try implementing a basic one using Neuroph in Java to perform multiclass classification using Multilayer Perceptron.</p> <pre><code>public static void main(String[] args) { final MultiLayerPerceptron neuralNetwork = new MultiLayerPerceptron(2, 3, 3, 3); ...
144
implement classification
How to implement Negation Features in SVM classification (NLP) using imdb Movie_Reviews corpus
https://stackoverflow.com/questions/27818607/how-to-implement-negation-features-in-svm-classification-nlp-using-imdb-movie
<p>I am trying to understand Negation feature in NLP , so I thought to implement it. I am working on imdb movie review dataset. Consider I am having data as follows-</p> <pre><code>Movie was great but it's overly sentimental and at times terribly mushy , not to mention very manipulative but great action </code></pre> ...
<p>You can check this <a href="http://www.umiacs.umd.edu/~saif/WebPages/Abstracts/NRC-SentimentAnalysis.htm" rel="nofollow">NRC Sentiment Analysis</a> system for text classification using negation. It's very well explained. Also they claim their <a href="http://www.aclweb.org/anthology/S14-2077" rel="nofollow">SemEval ...
145
implement classification
Use pandas to implement data classification
https://stackoverflow.com/questions/70520090/use-pandas-to-implement-data-classification
<p><a href="https://i.sstatic.net/4mKZ5.png" rel="nofollow noreferrer">enter image description here</a>I have an excel file, the rows in it represent each day, a total of 365 days, each column represents a region, a total of 2310 regions, and the content is the temperature of each day. Now I want to use 1° as an interv...
<pre><code>df = pd.read_excel('Step 1- Mapping SA2 to Climate Zone- Mean Temperature.xlsx',sheet_name='Daily Mean 2003-SA2') df_value = df.drop(columns=['date']) df_column = df_value.iloc[:,[0]] i = 0 list_range = [] list_MFT = [] while i &lt;= len(df_value.columns): df_column = df_value.iloc[:, [i]] for index,...
146
implement classification
How to implement a Classification Problem in Deep Learning for an EEG application?
https://stackoverflow.com/questions/63042214/how-to-implement-a-classification-problem-in-deep-learning-for-an-eeg-applicatio
<p>I am new to this and would like to know how should I implement a classification problem for my EEG application. I did some digging and found that the traditional machine learning methods based on EEG signal always consider the features of the time-domain and/or frequency-domain. Similarly, I have the frequency domai...
147
implement classification
Classification perceptron implementation
https://stackoverflow.com/questions/45258144/classification-perceptron-implementation
<p>I have written Percentron example in Python from <a href="https://www.youtube.com/watch?v=ntKn5TPHHAk" rel="nofollow noreferrer">here</a>. </p> <p>Here is the complete code </p> <pre><code>import matplotlib.pyplot as plt import random as rnd import matplotlib.animation as animation NUM_POINTS = 5 LEANING_RATE=0.1...
<p>I looked at your code and the video and I believe the way your code is written, the points start out as green, if their guess matches their target they turn red and if their guess doesn't match the target they turn blue. This repeats with the remaining blue eventually turning red as their guess matches the target. ...
148
implement classification
Pyspark - Classification Implementation
https://stackoverflow.com/questions/45161978/pyspark-classification-implementation
<p>I have a use case to predict the Multi Class labeled value. I have basic doubts in data preparation using Pyspark Implementation.</p> <p>Let say I have the below dataset:</p> <pre><code>A B C Label 10 class1 Boy Cricket 12 class3 Boy Football 11.6 class2 Girl Hockey .. .. .. .. 12.2...
149
implement classification
How to implement K-NN classification from a k-d tree?
https://stackoverflow.com/questions/54632821/how-to-implement-k-nn-classification-from-a-k-d-tree
<p>I'm trying to write the code for K-NN classification using k-d tree without using any libraries. So far I have been able to write the code for k-d tree but I cant seem to understand how do I find the k nearest neighbors once the tree has been formed from a training set. k-d tree code:</p> <pre><code>#include&lt;bi...
<p>First don't use <code>&lt;bits/stdc++.h&gt;</code>. That's wrong.</p> <p>To find the k closest elements, you need to go through the tree in a way that will traverse the closest elements first. Then, if you don't have enough elements, go and traverse the ones that are further.</p> <p>I won't write the code here, ju...
150
implement classification
SparkNLP Text classification using BertSentenceEmbeddings
https://stackoverflow.com/questions/65236746/sparknlp-text-classification-using-bertsentenceembeddings
<p>I am struggling with implementing classification usecase using the <code>BertSentenceEmbeddings</code> in python. Mostly I get <code>classNotFoundError</code> and I think I am unable to figure out the right versions of libraries (spark-nlp, pyspark). I followed most of options suggested on web but had no luck.</p> <...
<p>This <a href="https://github.com/JohnSnowLabs/spark-nlp-workshop/blob/master/tutorials/Certification_Trainings/Public/5.Text_Classification_with_ClassifierDL.ipynb" rel="nofollow noreferrer">tutorial</a> helped me solve this error.</p> <p>Thank you Maziyar for the help on Spark-NLP slack.</p>
151
implement classification
Implement multivariate normal pdf in c++ for image classification
https://stackoverflow.com/questions/17282956/implement-multivariate-normal-pdf-in-c-for-image-classification
<p>I am looking to implement the multivariate normal PDF [ <a href="http://en.wikipedia.org/wiki/Multivariate_normal_distribution#Density_function" rel="nofollow">1</a> ] in C++ to assign each pixel in an image membership of a class, i.e.</p> <pre><code> for each pixel for each class compute mul...
<p>I am not aware of a ready-to-go one-step solution. For a two-step mix-and-match approach, you could familiarize yourself with <a href="http://www.boost.org/doc/libs/1_53_0/libs/math/doc/html/index.html" rel="nofollow">Boost.Math</a> which has an <a href="http://www.boost.org/doc/libs/1_53_0/libs/math/doc/sf_and_dist...
152
implement classification
Is there a GPU implementation multiclass classification function in MATLAB?
https://stackoverflow.com/questions/35809904/is-there-a-gpu-implementation-multiclass-classification-function-in-matlab
<p>I have a multiclass classification task, and I have tried to use 'trainSoftmaxLayer' in Matlab, but it's a CPU implementation version, and is slow. So I tried to read the documentation for a GPU option, like 'trainSoftmaxLayer('useGPU', 'yes')' in traditional neural network, but there isn't any related options. </p>...
<p>Finally, the problem is sovled by hacking the source code of trainSoftmaxLayer.m, which is provided by MATLAB. We can write our own GPU-enabled softmax layer like this:</p> <pre><code>function [net] = trainClassifier(x, t, use_gpu, showWindow) net = network; % define topology net.numInputs = 1; net.numLayers = 1; ...
153
implement classification
What is open set classification in data mining?
https://stackoverflow.com/questions/67326572/what-is-open-set-classification-in-data-mining
<p>What exactly is open set classification in data mining? Is it a synonym or another word for one of these classification types?</p> <p>-Binary Classification <br> -Multi-Class Classification <br> -Multi-Label Classification <br> -Imbalanced Classification</p> <p>I have been browsing the web for a while but can't seem...
<p>According to <a href="https://journals.plos.org/plosone/article?id=10.1371/journal.pone.0238302#:%7E:text=Open%20set%20classification%20(OSC)%20is,an%20incorrect%20label%20%5B3%5D." rel="nofollow noreferrer">this researh paper</a></p> <blockquote> <p>Open set classification (OSC) is the ability for a classifier to r...
154
implement classification
How to implement asymmetric relationship in machine learning Classification algorithm?
https://stackoverflow.com/questions/67857508/how-to-implement-asymmetric-relationship-in-machine-learning-classification-algo
<p>I am trying to build a classification system, that takes pairs of images as input and output {0 or 1} if image B is sub-category of image A.</p> <p>Below are some examples of the data.</p> <ul> <li>Input: Image A [Apple Tree] &amp; Image B [Apple] | Output: [1]</li> <li>Input: [Orange Tree] &amp; [Orange] | Output: ...
<p>I suggest using some kind of data augmentation to teach your model the nature of the problem, let's say your model has an input layer to accept 2 images and a flag to show desire relation, what if you adding some synthetic pairs to clarify the problem (direction of the relation) to the model. precisely you can add a...
155
implement classification
How to stratify the training and testing data in Scikit-Learn?
https://stackoverflow.com/questions/60530673/how-to-stratify-the-training-and-testing-data-in-scikit-learn
<p>I am trying to implement Classification algorithm for Iris Dataset (Downloaded from Kaggle). In the Species column the classes (Iris-setosa, Iris-versicolor , Iris-virginica) are in sorted order. How can I stratify the train and test data using Scikit-Learn?</p>
<p>If you want to shuffle and split your data with 0.3 test ratio, you can use</p> <pre><code>sklearn.model_selection import train_test_split X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.3, shuffle=True) </code></pre> <p>where X is your data, y is corresponding labels, <strong>test_size</str...
156
implement classification
Scikit-learn: SVM implementation (I obtain a perfect classification)
https://stackoverflow.com/questions/31211026/scikit-learn-svm-implementation-i-obtain-a-perfect-classification
<p>I am new in machine learning and in scikit-learn. I started to use it in order to classify different datasets. For that I started applying scikit-learn's SVC with <a href="http://pastebin.com/wxSLhEsB" rel="nofollow">this dataset</a>, It's a huge JSON with this a structure similar to this:</p> <pre><code>{"name": "...
157
implement classification
Implementing HuggingFace BERT using tensorflow fro sentence classification
https://stackoverflow.com/questions/62370354/implementing-huggingface-bert-using-tensorflow-fro-sentence-classification
<p>I am trying to train a model for real disaster tweets prediction(Kaggle Competition) using the Hugging face bert model for classification of the tweets.</p> <p>I have followed many tutorials and have used many models of bert but none could run in COlab and thros the error</p> <p>My Code is: </p> <pre><code>!pip i...
<p>Follow this tutorial on Text classification using BERT: <a href="https://pysnacks.com/machine-learning/bert-text-classification-with-fine-tuning/" rel="nofollow noreferrer">https://pysnacks.com/machine-learning/bert-text-classification-with-fine-tuning/</a></p> <p>It has working code on Google Colab(using GPU) and ...
158
implement classification
How to fix &#39;Object arrays cannot be loaded when allow_pickle=False&#39; for imdb.load_data() function?
https://stackoverflow.com/questions/55890813/how-to-fix-object-arrays-cannot-be-loaded-when-allow-pickle-false-for-imdb-loa
<p>I'm trying to implement the binary classification example using the IMDb dataset in <strong>Google Colab</strong>. I have implemented this model before. But when I tried to do it again after a few days, it returned a <code>value error: 'Object arrays cannot be loaded when allow_pickle=False'</code> for the load_data...
<p>Here's a trick to force <code>imdb.load_data</code> to allow pickle by, in your notebook, replacing this line:</p> <pre class="lang-py prettyprint-override"><code>(train_data, train_labels), (test_data, test_labels) = imdb.load_data(num_words=10000) </code></pre> <p>by this:</p> <pre class="lang-py prettyprint-ov...
159
implement classification
knn classification 10 fold implement and sorting
https://stackoverflow.com/questions/33930897/knn-classification-10-fold-implement-and-sorting
<p>i have 8 feature from a mat file each of this feature divided 4 part (X_train , Y_train , X_test,Y_test) for 10 times randomly obtained this parameter now i should classify this feature according KNN my code is here</p> <pre><code> kk=7; bb=1; mdl1= ClassificationKNN.fit([X1_train{bb};X2_t...
<p>at first you should define the mdl variable size </p> <pre><code>mdll= cell(10, 8); </code></pre> <p>then form this for loop </p> <pre><code>for j=1:10 mdll{j}= ClassificationKNN.fit([X_train{j}{1};X_train{j}{2};X_train{j}{3};X_train{j}{4};X_train{j}{5};X_train{j}{6};X_train{j}{7};X_train{j}{8};X_train{j}{9}...
160
implement classification
How to implement multilabel classification on UTKFace dataset using Tensorflow and Keras?
https://stackoverflow.com/questions/66852823/how-to-implement-multilabel-classification-on-utkface-dataset-using-tensorflow-a
<p>Basically I am trying to predict Age, Gender and Race from <a href="https://susanqq.github.io/UTKFace/" rel="nofollow noreferrer">UTKFace dataset</a> by building multilabel classification model using Tensorflow and Keras. This is what my preprocessed dataset looks like . I have couple of questions here</p> <ol> <li>...
<p>First you should use to_categorical (one hot encode) in your labels:</p> <pre><code>df['Age'] = tf.keras.utils.to_categorical(df['Age']) df['Gender'] = tf.keras.utils.to_categorical(df['Gender']) df['Racevalues'] = tf.keras.utils.to_categorical(df['Racevalues']) </code></pre> <p>And so:</p> <pre><code>traindata = tr...
161
implement classification
Classification of detectors, extractors and matchers
https://stackoverflow.com/questions/14808429/classification-of-detectors-extractors-and-matchers
<p>I am new to opencv and trying to implement image matching between two images. For this purpose, I'm trying to understand the difference between feature descriptors, descriptor extractors and descriptor matchers. I came across a lot of terms and tried to read about them on the opencv documentation website but I just ...
<blockquote> <p>I understand how FAST, SIFT, SURF work but can't seem to figure out which ones of the above are only detectors and which are extractors.</p> </blockquote> <p>Basically, from that list of feature detectors/extractors (link to articles: <a href="http://www.edwardrosten.com/work/fast.html" rel="norefe...
162
implement classification
How to implement kmeans clustering as a feature for classification techniques in SVM?
https://stackoverflow.com/questions/70532307/how-to-implement-kmeans-clustering-as-a-feature-for-classification-techniques-in
<p>Ive already created a clustering and saved the model but im confused what should i do with this model and how to use it as a feature for classification. This clustering is based on the coordinate of a crime place. after the data has been clustered, i want to use the clustered model as features in SVM.</p> <pre><code...
<p>Your problem is not much clear, but if you want to see the behavior of clusters, I recommend you to use a tool like <a href="https://www.cs.waikato.ac.nz/ml/weka/" rel="nofollow noreferrer">Weka</a>, so that you can freely cluster them and get meaningful inferences before going into complex coding stuff!</p>
163
implement classification
How can I implement zero-shot classification using MindsDB and MQL (for my MongoDB instance)?
https://stackoverflow.com/questions/75522060/how-can-i-implement-zero-shot-classification-using-mindsdb-and-mql-for-my-mongo
<p>I am using <a href="https://github.com/mindsdb/mindsdb" rel="nofollow noreferrer">MindsDB</a> to do a zero-shot classification using the <code>facebook/bart-large-mnli</code> model and the web store data I have in a MongoDB instance. MindsDB documentation only explains how to achieve this using SQL, but I would like...
<p>MindsDB just released a new version of the docs that contains the Mongo Query Language examples. To use the zero-shot classification you will need to provide <strong>task</strong> and <strong>candidate_labels</strong> in the model training_parameters as:</p> <pre><code>db.models.insertOne({ name: 'my_model_na...
164
implement classification
Implementation of n-grams in python code for multi-class text classification
https://stackoverflow.com/questions/55555159/implementation-of-n-grams-in-python-code-for-multi-class-text-classification
<p>I am new to python and working on the multi-class text classification of contract documents of the construction industry. I am facing problems in the implementation of n-grams in my code which I produced form by getting help from different online sources. I want to implement unigram, bi-gram, and tri-gram in my code...
<p>At first you fit vectorizer on texts:</p> <pre><code>tfidf_vect_ngram.fit(df['description']) </code></pre> <p>And then try to apply it to counts:</p> <pre><code>counts = count_vect.fit_transform(df['description']) X_train, X_test, y_train, y_test = train_test_split(counts, df['types'], test_size=0.3, random_stat...
165
implement classification
multiple classification using Liblinear in Accord.net Framework
https://stackoverflow.com/questions/29619258/multiple-classification-using-liblinear-in-accord-net-framework
<p>I need to implement multiple classification classifier using Liblinear. Accord.net machine learning framework provides all of Liblinear properties except the Crammer and Singer’s formulation for multi-class classification. <a href="http://crsouza.com/2014/12/liblinear-algorithms-in-c/" rel="nofollow">This is the pro...
<p>The usual way of learning a multi-class machine is by using the <a href="http://accord-framework.net/docs/html/T_Accord_MachineLearning_VectorMachines_Learning_MulticlassSupportVectorLearning.htm" rel="nofollow noreferrer">MulticlassSupportVectorLearning class</a>. This class can teach one-vs-one machines that can t...
166
implement classification
Implementing Binary Classification for LSTM and Linear Layer Output
https://stackoverflow.com/questions/71565894/implementing-binary-classification-for-lstm-and-linear-layer-output
<p>I'm working on developing a wake word model for my AI assistant. My model architecture includes an LSTM layer to process audio data, followed by a Linear Layer. However, I'm encountering an unexpected output shape from the Linear Layer, which is causing confusion.</p> <p>After passing the LSTM output (shape: 4, 32, ...
<p>You can try this:</p> <pre class="lang-py prettyprint-override"><code>hn = hn[-1, :, :] out = self.classifier(hn) </code></pre>
167
implement classification
CNN + LSTM implementation error for image classification
https://stackoverflow.com/questions/73161256/cnn-lstm-implementation-error-for-image-classification
<p>I am trying to implement a CNN network + LSTM to be able to predict 4 different classes based on the sequence of x-ray images, which were preprocessed to 150x150x3 shape. My X-train shape is (4067, 150, 150, 3). When I am executing the code <strong>model.fit()</strong>, i am getting the error.</p> <pre><code># x_tra...
168
implement classification
Best method to implement text classification (2 classes)
https://stackoverflow.com/questions/20766487/best-method-to-implement-text-classification-2-classes
<p>I have to write classifier for corpus of texts, which should separate all my texts into 2 classes. The corpus is very large (near 4 millions for test, and 50000 for study). But, what algorithm should I choose?</p> <ul> <li>Naive Bayesian</li> <li>Neural networks</li> <li>SVM</li> <li>Random forest</li> <li>kNN (why...
<p>As a 2-classes text classifier, I don't think you need:</p> <p>(1) KNN: it is a clustering method rather than classification, and it is slow;</p> <p>(2) Random forest: the decision trees may not be a good option in high sparse dimensions;</p> <p>You can try:</p> <p>(1) naive bayesian: most straightforward and ea...
169
implement classification
I want to implement a machine learning or deep learning model for text classification (100 classes)
https://stackoverflow.com/questions/58990776/i-want-to-implement-a-machine-learning-or-deep-learning-model-for-text-classific
<p>I have a dataset that is similar to the one where we have movie plots and their genres. The number of classes is around 100. What algorithm should I choose for this 100 class classification? The classification is multi-label because 1 movie can have multiple genres Please recommend anyone from the following. You are...
<p>An important step in machine learning engineering consists of properly inspecting the data. Herby you get some insight that determines what algorithm to choose. Sometimes, you might try out more than one algorithm and compare the models, in order to be sure, that you tried your best on the data.</p> <p>Since you di...
170
implement classification
C4.5 decision tree: classification probability distribution?
https://stackoverflow.com/questions/11854710/c4-5-decision-tree-classification-probability-distribution
<p>I'm using Weka's J48 (C4.5) decision tree classifier. In general for a decision tree, can a classification probability distribution be determined once you hit a leaf? I know with Naive Bayes, each classification attempt produces a classification distribution.</p> <p>If it is possible with a decision tree, is this c...
<p>As each leaf has a classification decision that is in fact a discrete distribution, one that has 100% for the class it indicates and 0 for all other classes. You could use the training set to generate a distribution for all inner nodes if you want, as well.</p> <p>If you do pruning after you learn the tree, you can...
171
implement classification
How can I implement regression after multi-class multi-label classification?
https://stackoverflow.com/questions/78572569/how-can-i-implement-regression-after-multi-class-multi-label-classification
<p>I have a dataset where some objects (15%) belong to different classes and have a property value for each of those classes. How can I make a model that predicts multi-label or multi-class and then make a regression prediction based on the output of the classifier? I also need to output the probabilities for each clas...
172
implement classification
Implementation of Data Augmentation for Image Classification with Convolutional Neural Networks
https://stackoverflow.com/questions/22050186/implementation-of-data-augmentation-for-image-classification-with-convolutional
<p>I'm doing image classification with cudaconvnet with Daniel Nouri's noccn module, and want to implement data augmentation by taking lots of patches of an original image (and flipping it). When would it be best for this to take place?</p> <p>I've identified 3 stages in the training process when it could:<br> a) when...
<p>Right, you'd want to have augmented samples as randomly interspersed throughout the rest of the data as possible. Otherwise, you'll definitely run into problems as you've mentioned because the batches won't be properly sampled and your gradient descent steps will be too biased. I am not too familiar with cudaconvnet...
173
implement classification
How can I implement ROC curve analysis for this naive Bayes classification algorithm in R?
https://stackoverflow.com/questions/47883541/how-can-i-implement-roc-curve-analysis-for-this-naive-bayes-classification-algor
<p>There are very complicated examples on the Internet. I couldn't apply them to my code. I have a data set consisting of 14 independent and one dependent variables. I'm making classification with R. Here is my code:</p> <pre><code>dataset &lt;- read.table(&quot;adult.data&quot;, sep = &quot;,&quot;, na.strings = c(&qu...
<p>For a ROC curve to work, you need some threshold or hyperparameter.</p> <p>The numeric output of Bayes classifiers tends to be too unreliable (while the binary decision is usually OK), and there is no obvious hyperparameter. You could try treating your prior probability (in a binary problem only!) as parameter, and...
174
implement classification
implementing image classification in rnn
https://stackoverflow.com/questions/53041396/implementing-image-classification-in-rnn
<p>I have implemented an example of classifying cats and dogs using cnn. You can get the code from <a href="https://github.com/venkateshtata/cnn_medium./tree/master" rel="nofollow noreferrer">here</a> and <a href="https://becominghuman.ai/building-an-image-classifier-using-deep-learning-in-python-totally-from-a-beginne...
<p>Keras provides an example of how to classify the <a href="https://en.wikipedia.org/wiki/MNIST_database" rel="nofollow noreferrer">MNIST</a> dataset using an <a href="https://en.wikipedia.org/wiki/Long_short-term_memory" rel="nofollow noreferrer">LSTM</a> <a href="https://github.com/keras-team/keras/blob/master/examp...
175
implement classification
unsupervised text classification with php
https://stackoverflow.com/questions/15305817/unsupervised-text-classification-with-php
<p>Are there any pre-made libraries for PHP that can be used to help with tasks involving unsupervised text classification <sup><a href="http://en.wikipedia.org/wiki/Document_classification#Automatic_document_classification" rel="nofollow">information</a></sup>?</p> <p>I've looked around the site at other questions, b...
<p><a href="https://github.com/gburtini/Learning-Library-for-PHP" rel="nofollow">https://github.com/gburtini/Learning-Library-for-PHP</a></p> <p>Some general unsupervised algorithms already implemented here. Maybe it will be you useful for you.</p>
176
implement classification
Big performance difference between Pytorch and Keras implementation in text classification
https://stackoverflow.com/questions/61737314/big-performance-difference-between-pytorch-and-keras-implementation-in-text-clas
<p>I have implemented CNN in both Keras and Pytorch for a multi-label text classification task. Two implementations ended with two very different performances. CNN with Keras is noticeable outperform the CNN with Pytorch. Both used one layer CNN with kernel size 4.</p> <p>The Pytorch version scores <strong>0.023 for m...
177
implement classification
Using Naive bayes classification on android
https://stackoverflow.com/questions/33456621/using-naive-bayes-classification-on-android
<p>I am developing an android news app that should extract specific news topics from the web then make further classification to group news articles in categories using naive Bayes classification, any body know how to implement it in Android or even in Java ? </p>
<p>You could try finding an <a href="https://github.com/search?l=Java&amp;q=naive+bayes&amp;type=Repositories&amp;utf8=%E2%9C%93" rel="nofollow">open source Java implementation on GitHub</a>.</p>
178
implement classification
One versus One and One versus All multiclass classification using logistic regression in python
https://stackoverflow.com/questions/58481324/one-versus-one-and-one-versus-all-multiclass-classification-using-logistic-regre
<p>This is my understanding of OvO versus OvA: One versus One is binary classification like Banana versus Orange. One versus All/Rest classification turns it into multiple different binary classification problems. My implementation in python for these 2 strategies yield very similar results :</p> <p><strong>OvA</stron...
<p>I ended up using the sklearn inbuilt class for oneVsRestClassifier and OneVsOneclassifier</p>
179
implement classification
how to implement tensorflow&#39;s next_batch for own data
https://stackoverflow.com/questions/40994583/how-to-implement-tensorflows-next-batch-for-own-data
<p>In the <a href="https://www.tensorflow.org/versions/r0.10/tutorials/mnist/beginners/index.html" rel="noreferrer">tensorflow MNIST tutorial</a> the <code>mnist.train.next_batch(100)</code> function comes very handy. I am now trying to implement a simple classification myself. I have my training data in a numpy array....
<p>The link you posted says: <em>"we get a "batch" of one hundred random data points from our training set"</em>. In my example I use a global function (not a method like in your example) so there will be a difference in syntax.</p> <p>In my function you'll need to pass the number of samples wanted and the data array....
180
implement classification
How to implement pixel-wise classification for scene labeling in TensorFlow?
https://stackoverflow.com/questions/35317029/how-to-implement-pixel-wise-classification-for-scene-labeling-in-tensorflow
<p>I am working on a deep learning model using <strong>Google's TensorFlow</strong>. The model should be used to <strong>segment and label scenes</strong>. </p> <ol> <li>I am using the <strong>SiftFlow dataset</strong> which has <em>33 semantic classes</em> and <em>images with 256x256 pixels</em>. </li> <li>As a resu...
<p>To apply softmax and use a <strong>cross entropy loss</strong>, you have to keep <strong>intact</strong> the final output of your network of size <em>batch_size x 256 x 256 x 33</em>. Therefore you <strong>cannot use</strong> mean averaging or argmax because it would destroy the output probabilities of your network....
181
implement classification
Hyperparameters tuning with keras tuner for classification problem
https://stackoverflow.com/questions/72935023/hyperparameters-tuning-with-keras-tuner-for-classification-problem
<p>I an trying implement both classification problem and the regression problem with Keras tuner. here is my code for the regression problem:</p> <pre><code> def build_model(hp): model = keras.Sequential() for i in range(hp.Int('num_layers', 2, 20)): model.add(layers.Dense(units=hp.Int('u...
<p>To use this code for a classification problem, you will have to change the loss function, the objective function and the activation function of your output layer. Depending on the number of classes, you will use different functions:</p> <div class="s-table-container"> <table class="s-table"> <thead> <tr> <th>Number ...
182
implement classification
Is there a way to inform classifiers in R of the relative costs of misclassification?
https://stackoverflow.com/questions/44548414/is-there-a-way-to-inform-classifiers-in-r-of-the-relative-costs-of-misclassifica
<p>This is a general question. Are there classifiers in R -- functions that perform classification implementing classification algorithms-- that accept as input argument the relative cost of misclassification. E.g. if a misclassification of a positive to negative has cost 1 the opposite has cost 3.</p> <p>If yes whic...
<p>Yes. If you are using the <a href="https://cran.r-project.org/web/packages/caret/caret.pdf" rel="nofollow noreferrer">caret</a> package (you should; it provides 'standardization' for 200+ classification and regression methods by wrapping almost all relevant R's packages), you can set the <em>weights</em> argument of...
183
implement classification
Spark Multi Label classification
https://stackoverflow.com/questions/39167288/spark-multi-label-classification
<p>I am looking to implement with Spark, a multi label classification algorithm with multi output, but I am surprised that there isn’t any model in Spark Machine Learning libraries that can do this.</p> <p>How can I do this with Spark ?</p> <p>Otherwise Scikit Learn Logistic Regresssion support multi label classifica...
<p>Also in Spark there is Logistic Regression that supports multilabel classification based on the api <a href="http://spark.apache.org/docs/2.1.0/api/java/org/apache/spark/mllib/classification/LogisticRegressionWithSGD.html" rel="noreferrer">documentation</a>. See also <a href="https://github.com/apache/spark/blob/mas...
184
implement classification
How can I increase the efficiency of my Python implementation for the k Nearest Neighbours classification?
https://stackoverflow.com/questions/42764141/how-can-i-increase-the-efficiency-of-my-python-implementation-for-the-k-nearest
<p>I tried to implement the k Nearest Neighbour classification algorithm for images in Python, here is my code<br> <pre><code> def classifyImage(self, RGBAValsForOneImage, kVal): redMaster = RGBAValsForOneImage[0] greenMaster = RGBAValsForOneImage[1] blueMaster = RGBAValsForOneI...
185
implement classification
Using Tensorflow&#39;s Connectionist Temporal Classification (CTC) implementation
https://stackoverflow.com/questions/38059247/using-tensorflows-connectionist-temporal-classification-ctc-implementation
<p>I'm trying to use the Tensorflow's CTC implementation under contrib package (tf.contrib.ctc.ctc_loss) without success. </p> <ul> <li>First of all, anyone know where can I read a good step-by-step tutorial? Tensorflow's documentation is very poor on this topic.</li> <li>Do I have to provide to ctc_loss the labels wi...
<p>I'm trying to do the same thing. Here's what I found you may be interested in.</p> <p>It was really hard to find the tutorial for CTC, but <a href="https://github.com/tensorflow/tensorflow/blob/679f95e9d8d538c3c02c0da45606bab22a71420e/tensorflow/python/kernel_tests/ctc_loss_op_test.py" rel="nofollow noreferrer">thi...
186
implement classification
How to use run_classifer.py,an example of Pytorch implementation of Bert for classification Task?
https://stackoverflow.com/questions/56151673/how-to-use-run-classifer-py-an-example-of-pytorch-implementation-of-bert-for-cla
<p>How to use the fine-tuned bert pytorch model for classification (CoLa) task?</p> <p>I do not see the argument <code>--do_predict</code>, in <code>/examples/run_classifier.py</code>. </p> <p>However, <code>--do_predict</code> exists in the original implementation of the Bert.</p> <p>The fine-tuned model is getting...
187
implement classification
Hierarchical transformer for document classification: model implementation error, extracting attention weights
https://stackoverflow.com/questions/62825520/hierarchical-transformer-for-document-classification-model-implementation-error
<p>I am trying to implement a hierarchical transformer for document classification in Keras/tensorflow, in which:</p> <p>(1) a word-level transformer produces a representation of each sentence, and attention weights for each word, and,</p> <p>(2) a sentence-level transformer uses the outputs from (1) to produce a repre...
<p>I got NotImplementedError as well while trying to do the same thing as you. The thing is Keras's TimeDistributed layer needs to know its inner custom layer's output shapes. So you should add compute_output_shape method to your custom layers.</p> <p>In your case MultiHeadSelfAttention, TransformerBlock and TokenAndPo...
188
implement classification
Keras classification model with pure numpy classification layer
https://stackoverflow.com/questions/74951226/keras-classification-model-with-pure-numpy-classification-layer
<p>I have a multiclass(108 classes) classification model which I want to apply transfer learning to the classification layer. I want to deploy this model in a low computing resource device (Raspberry Pi) and I thought to implement the classification layer in pure numpy instead of using Keras or TF. Below is my original...
189
implement classification
R: How to create multiple maps (rworldmap) with different classification borders?
https://stackoverflow.com/questions/34472450/r-how-to-create-multiple-maps-rworldmap-with-different-classification-borders
<p>Based on my former <a href="https://stackoverflow.com/questions/33945984/r-how-to-create-multiple-maps-rworldmap-using-apply">question</a> answered by @Andy, I wanted to have different classification intervals per map using Jenks natural breaks. For this I use the library <code>classInt</code>, which works fine for ...
<p>From the example provided in the link</p> <pre><code>spdf &lt;- df </code></pre> <p>As there are non-numeric columns, we can subset the dataset for those columns with names that have either 'BLUE' or 'GREEN' with <code>grep</code> ('i1'), then we loop over those columns,apply the <code>classIntervals</code> functi...
190
implement classification
How Can I Implement a Multiclass Multilabel Classification in Keras
https://stackoverflow.com/questions/62747053/how-can-i-implement-a-multiclass-multilabel-classification-in-keras
<p>Suppose I have some set of input outputs like below:</p> <pre><code>input1 : [0 1 1 1 0 ... 1] output1 : [1 2 2 3 ... 3 3 1 2 2] ... </code></pre> <p>the inputs are always <strong>0 or 1</strong> and the outputs are always <strong>1 or 2 or 3</strong></p> <p>how can I create a neural network in keras that can fit o...
<p>For your last classification layer, you should give it a <code>softmax</code> activation. This activation is used for classifications. It may require you to one hot encode your outputs though.</p>
191
implement classification
Neural Network Ordinal Classification for Age
https://stackoverflow.com/questions/38375401/neural-network-ordinal-classification-for-age
<p>I have created a simple neural network (Python, Theano) to estimate a persons age based on their spending history from a selection of different stores. Unfortunately, it is not particularly accurate.</p> <p>The accuracy might be hurt by the fact that the network has no knowledge of ordinality. For the network there...
<p>This problem came up in a previous <a href="https://www.kaggle.com/c/diabetic-retinopathy-detection/forums/t/13115/paper-on-using-ann-for-ordinal-problems" rel="noreferrer">Kaggle competition</a> (this thread references the paper I mentioned in the comments).</p> <p>The idea is that, say you had 5 age groups, where ...
192
implement classification
Multilabel classification in ML.NET
https://stackoverflow.com/questions/67411717/multilabel-classification-in-ml-net
<p>I am looking to implement multilabel classification using ML.NET. I read few posts which say it is not possible directly but rather through problem transformation by converting it into multiple binary classification problems. So essentially I will be required to create <code>n</code> classifier if my dataset has <co...
<p>Create N boolean columns. Example naming pattern: Label01, Label02, ...LabelNN.</p> <p>Training pipeline, add N sets of: (one for each boolean label)</p> <pre class="lang-cs prettyprint-override"><code>.Append(mlContext.BinaryClassification.Trainers.LightGbm(labelColumnName: &quot;Label01&quot;, featureColumnName: &...
193
implement classification
Implementation of SVM for classification without library in c++
https://stackoverflow.com/questions/27501444/implementation-of-svm-for-classification-without-library-in-c
<p>I'm studying Support Vector Machine last few weeks. I understand the theoretical concept how I can classify a data into two classes. But its unclear to me how to select support vector and generate separating line to classify new data using C++.</p> <p>Suppose, I have two training data set for two classes</p> <p><i...
<p>I will join to most people's advice and say that you should really consider using a library. SVM algorithm is tricky enough to add the noise if something is not working because of a bug in your implementation. Not even talking about how hard is to make an scalable implementation in both memory size and time.</p> <p...
194
implement classification
Add attention mechanism to classification problem
https://stackoverflow.com/questions/57493402/add-attention-mechanism-to-classification-problem
<p>Currently, I am trying to implement attention mechanism to (sequence frame) video classification. So I am implementing the attention between CNN (feature extraction) -> attention -> LSTM (classification to specific class). I followed two papers for the implementation: "Action Recognition using visual attention" and ...
195
implement classification
Problem with &quot;metalearner&quot; for multi-class classification in H2O AutoML (3.24.0.5) implemented in R
https://stackoverflow.com/questions/57149718/problem-with-metalearner-for-multi-class-classification-in-h2o-automl-3-24-0
<p>I am trying H2O AutoML for multi-class classification. Everything seems to be working fine except when I am trying to extract the variable importance from metalearner for the StackedEnsemble.</p> <p>This is what I am getting from code:</p> <pre><code># Get the &quot;BestOfFamily&quot; Stacked Ensemble model se.best ...
196
implement classification
Android - Weka Classification is Taking too much time
https://stackoverflow.com/questions/24505823/android-weka-classification-is-taking-too-much-time
<p>I am using weka library for implementing classification algorithms in android, Though Weka lib is not fully compatible with android , I am using <a href="https://github.com/rjmarsan/Weka-for-Android" rel="nofollow noreferrer">Weka For Android</a> as lib in my app. But its taking too much time for building model</p> ...
197
implement classification
MultiLabel Classification using Conditional Random Field
https://stackoverflow.com/questions/37531532/multilabel-classification-using-conditional-random-field
<p>Is it possible to use Conditional Random Field for MultiLabel Classification? I saw a python CRF implementation at <a href="https://pystruct.github.io/user_guide.html" rel="noreferrer">https://pystruct.github.io/user_guide.html</a>, but couldn't figure a way to do multilabel classification.</p>
<p>The basic CRF doesn't support multilabel classification. However, some extensions have been explored, such as the Collective Multi-label (CML) and the Collective Multi-label with Features (CMLF). From (1):</p> <blockquote> <p>A conditional random field (CRF) based model is presented in [21] where two multi-labe...
198
implement classification
How to convert to a multi-class classification model?
https://stackoverflow.com/questions/52783281/how-to-convert-to-a-multi-class-classification-model
<p>I am trying to implement multi-class classification using the <a href="https://github.com/GoogleCloudPlatform/cloudml-samples/tree/master/flowers" rel="nofollow noreferrer">cloud samples github</a>.It was a classification model and i have to alter the code.I found some suggestion to change the final layer and loss f...
<p>Please refer to the following article:</p> <p><a href="https://towardsdatascience.com/multi-label-image-classification-with-inception-net-cbb2ee538e30" rel="nofollow noreferrer">https://towardsdatascience.com/multi-label-image-classification-with-inception-net-cbb2ee538e30</a></p> <p>The technique used in that art...
199
solve differential equations
python solving differential equations
https://stackoverflow.com/questions/46406222/python-solving-differential-equations
<p>I am attempting to solve four different differential equations. After googling and researching I was able to finally understand how the solver works but I can't get this problem specifically to run correctly. Code compiles but the graphs are incorrect. </p> <p>I think the problem lies in the volume expression insid...
<p>Taking the hints of the variable names and equation structure, you are considering a chemical reaction</p> <pre><code>A + B -&gt; C + D </code></pre> <p>There are 2 sources of changes in the concentration <code>a,b,c,d</code> of reactants <code>A,B,C,D</code>, </p> <ul> <li>the reaction itself with reaction spee...
200
solve differential equations
Octave to solve differential equations
https://stackoverflow.com/questions/23186185/octave-to-solve-differential-equations
<p>How do I solve the differential equation y'+y=t with y(0)=24?</p> <p>Do I need to defined the differential equation with a file in the form .m?</p>
<p>To solve ordinary differential equations you've got the function lsode (run lsode for help).</p> <pre><code>f = @(y,t) t-y; t = linspace(0,5,50)'; y=lsode(f, 24, t); plot(t,y); print -djpg figure-lsnode.jpg </code></pre> <p><a href="https://i.sstatic.net/K7eTt.jpg" rel="nofollow noreferrer"><img src="https://i.sst...
201
solve differential equations
solve differential equation with iterated parameter
https://stackoverflow.com/questions/35386600/solve-differential-equation-with-iterated-parameter
<p>I'm lerning to solve Differential equation using (scipy.integrate.odeint) and (scipy.integrate.ode). I have a simple example:</p> <p><code>dy/dt=f[i]*t</code></p> <p>and f is parameter corresponding to t[i], same like the example in code ; i.e. </p> <p><code>t[0]=0.0, f[0]=0.0</code></p> <p><code>t[1]=0.1, f[1]=...
<p>What you are doing is closer to integrating y'(t)=t^2, y(0)=0, resulting in y(t)=t^3/3. That you factor t^2 as f*t and hack f into a step function version of t only adds a small perturbation to that.</p> <hr> <p>The integral of <code>t[i]*t</code> over <code>t[i]..t[i+1]</code> is</p> <pre><code>y[i+1]-y[i] = t[i...
202
solve differential equations
Solving Differential equations in Matlab, ode45
https://stackoverflow.com/questions/16449166/solving-differential-equations-in-matlab-ode45
<p>I'm trying to solve a system with three differential equations with the function ode45 in Matlab. I do not really understand the errors i am getting and i could use some help understanding what im doing wrong.</p> <p>The differential equations are the following:</p> <pre><code>F1 = -k1y1+k2(y2-y1) F2 = -k2(y2-y1)+...
<p>A while passed since I did some Matlab programming, but as far as I remember, you should pass variables to the function, i.e. write <code>@(x,y)kopplad(x,y)</code>, if I understand you code in a correct way. If the rest (global variables and equations) are correct, everything shall be fine.</p>
203
solve differential equations
trying to solve differential equations simultaneously
https://stackoverflow.com/questions/65436977/trying-to-solve-differential-equations-simultaneously
<p>I am trying to build a code for chemical reactor design which is able to solve for the pressure drop, conversion, and temperature of a reactor. All these parameters have differential equations, so i tried to define them inside a function to be able to integrate them using ODEINT. However it seems that the function i...
<p>Inside line</p> <pre><code>ra=k*np.sqrt((1-X)/X)*((0.2-0.11*X)/(1-0.055*X)*(P/P0)-(x/(kp*(1-x)))**2) </code></pre> <p>you probably want to use <code>...X/(kp*(1-X))...</code> instead of <code>...x/(kp*(1-x))...</code> (i.e. use upper X), lower <code>x</code> is list type.</p> <p>If you want to use some list variable...
204
solve differential equations
Solve differential equation with SymPy
https://stackoverflow.com/questions/45308747/solve-differential-equation-with-sympy
<p>I have the following differential equation that I would like to solve with SymPy</p> <p><a href="https://i.sstatic.net/bYuJG.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/bYuJG.png" alt="enter image description here"></a></p> <p>This differential equation has the implicit solution (with h(0) = [0,...
<p>SymPy leaves the integral unevaluated because it is unsure about the sign of 1-y in the integral. </p> <p>The differential equation has a singularity at h=1, and its behavior depends on what side of 1 we are. There isn't a way to say that h(t) &lt; 1, but one can substitute h(t) = 1 - g(t) where g is a positive fun...
205
solve differential equations
Any way to solve a system of coupled differential equations in python?
https://stackoverflow.com/questions/16909779/any-way-to-solve-a-system-of-coupled-differential-equations-in-python
<p>I've been working with sympy and scipy, but can't find or figure out how to solve a system of coupled differential equations (non-linear, first-order). </p> <p>So is there any way to solve coupled differential equations? </p> <p>The equations are of the form:</p> <pre><code>V11'(s) = -12*v12(s)**2 v22'(s) = 12*v...
<p>For the numerical solution of ODEs with scipy, see <a href="https://docs.scipy.org/doc/scipy/reference/generated/scipy.integrate.solve_ivp.html" rel="nofollow noreferrer"><code>scipy.integrate.solve_ivp</code></a>, <a href="http://docs.scipy.org/doc/scipy/reference/generated/scipy.integrate.odeint.html" rel="nofoll...
206
solve differential equations
How to solve these differential equations?
https://stackoverflow.com/questions/39543756/how-to-solve-these-differential-equations
<p>I am working on a heat exchanger and found these differential equations from a paper. I never had such equation as you can see even if it's a single order differential equation a term "dy" is always hanging at right side of the equation.</p> <p>I am trying to solve them in matlab but due to dy, I am not able to put...
<p>Look at Eqs (23) and (24). They specify the definitions of \dot{m}_p and \dot{m}_s so that when you plug them into Eqs (19) and (20) they lose the floating differentials.</p>
207
solve differential equations
Solving partial differential equations using C#
https://stackoverflow.com/questions/1452255/solving-partial-differential-equations-using-c
<p>I am working on a project (C# and .NET Framework) which requires me to solve some partial differential equations. Are there any specific libraries based on .NET Framework that I could see and make my work simpler?</p> <p>I have worked with MATLAb and solving partial differential equations is very straightforward th...
<p>You could solve the problem in MATLAB and use the <a href="http://www.mathworks.co.uk/products/compiler/" rel="nofollow noreferrer">MATLAB compiler</a> + <a href="http://www.mathworks.co.uk/products/netbuilder/" rel="nofollow noreferrer">Builder NE toolbox</a> to create a .NET assembly which links to the rest of you...
208
solve differential equations
matlab solving numerical differential equations [pic]
https://stackoverflow.com/questions/74961611/matlab-solving-numerical-differential-equations-pic
<p>I'm trying to solve this numerical differential equations, can someone help? <img src="https://i.sstatic.net/3Qtwf.png" alt="pic of the differential equations" /></p> <pre><code>clc; clear; syms A1(z) A2(z) lamda1 = 1560*(10^-9); c=3*(10^8); d_eff=27*(10^-12); omga1=(2*pi*c)/(lamda1); omga2=omga1*2; n=2.2; k1=(n*omg...
<p>in this question both <strong>ODE</strong> are coupled, hence there's only 1 <strong>ODE</strong> to solve:</p> <p><strong>1.-</strong> use 1st equation to write</p> <pre><code>A1=f(A2,dA2/dz) </code></pre> <p>and feed this expression into 2nd equation.</p> <p><strong>2.-</strong> regroup</p> <pre><code>n1=1j*k1^4/k...
209
solve differential equations
Solving Differential equations with 7 unknowns
https://stackoverflow.com/questions/31263825/solving-differential-equations-with-7-unknowns
<p>I want to solve the 7 differential equations which are functions of time for the 7 unknowns. I wanted to find the solutions of the equations:</p> <pre><code>eo(t)=f1(e_0(t),e_1(t),e_2(t),e_3(t),w_1(t),w_2(t),w_3(t)) e1(t)=f2(e_0(t),e_1(t),e_2(t),e_3(t),w_1(t),w_2(t),w_3(t)) e2(t)=f3(e_0(t),e_1(t),e_2(t),e_3(t),w_1(...
<p>This error means that <code>ode45</code> cannot solve symbolic equations (your variables are of type 'sym'). In fact <a href="https://en.wikipedia.org/wiki/Dormand%E2%80%93Prince_method" rel="nofollow">ode45</a> is a numerical solver which works on functions, not on symbolical expressions. Here's how to <a href="htt...
210
solve differential equations
Solving differential Equation using BOOST Libraries
https://stackoverflow.com/questions/58036187/solving-differential-equation-using-boost-libraries
<p>I have to find next state of my robot which can be found though solving differential equations. In MATLAB i used ode45 function and on c++ i found on internet that i have to use some method like stepper runga kutta dopri5. I tried to understand its implementation and somehow got an idea. Now my states are X,Y and th...
<p>The answer depends on how you want to pass the parameters <code>v</code> and <code>w</code> to the integrator.</p> <p>One approach in C++11 is to use a <a href="https://en.cppreference.com/w/cpp/language/lambda" rel="nofollow noreferrer">lambda</a>. Your function and a call to the stepper would look like this (depe...
211
solve differential equations
How to solve three quadratic differential equations in Python?
https://stackoverflow.com/questions/50552094/how-to-solve-three-quadratic-differential-equations-in-python
<p>I've just started to use Python for scientific drawing to plot numerical solutions of differential equations. I know how to use modules to solve and plot single differential equations, but have no idea about systems of differential equation. How can I plot following coupled system?</p> <p>My system of differential ...
<p>General purpose ODE integrators expect the dynamical system reduced to an abstract first order system. Such a system has a state vector space and the differential equation provides velocity vectors for that space. Here the state has 3 scalar components, which gives a 3D vector as state. If you want to use the compon...
212
solve differential equations
Error while solving differential equations matlab
https://stackoverflow.com/questions/37668362/error-while-solving-differential-equations-matlab
<p>I'm looking for way to solve this differential equations. </p> <p><img src="https://i.sstatic.net/TVpfw.png" alt="equations"></p> <p>I've got small experience solving this type of equations, so here's my noob code</p> <pre><code>function lab1() [t,h]=ode45('threepoint', [0 1000], [0 0.25]); plot(t, h); functio...
<p>Please take a close look at <code>help ode45</code>. I admit this part of the usage might not be clear, so take a look at <code>doc ode45</code> too.</p> <p>Here's the essence of your problem. You want to solve a differential equation of 10 variables, each a function of <code>t</code>. So, how does a general solver...
213
solve differential equations
Differential Equations in Python
https://stackoverflow.com/questions/5847201/differential-equations-in-python
<p>I'm working with a DE system, and I wanted to know which is the most commonly used python library to solve Differential Equations if any.</p> <p>My Equations are non Linear First Order equations.</p>
<p>If you need to solve large nonlinear systems (especially stiff ones), the scipy tools will be slow and awkward. The <a href="http://pydstool.sourceforge.net/" rel="noreferrer" title="PyDSTool">PyDSTool</a> package is now quite commonly used in this situation. It lets your equations be automatically converted into C ...
214
solve differential equations
Solve Differential equation using Python PyDDE solver
https://stackoverflow.com/questions/25926957/solve-differential-equation-using-python-pydde-solver
<p>I am trying to solve following differential equation using python package PyDDE:</p> <pre><code>dy[i]/dt = w[i] + K/N * \sum{j=1toN} sin(y[j] -y[i]), where i = 1,2,3,4...N=50 </code></pre> <p>Below is the python code to solve this equation</p> <pre><code>from numpy import random, sin, arange, pi, array, zeros imp...
<p>So I have had a look at what was going on internally, and both errors</p> <pre><code>DDE Error: Something is wrong: perhaps one of the supplied variables has the wrong type? DDE Error: Problem initialisation failed! </code></pre> <p>come from the following operation failing: map(float,initstate) (see the <a href="...
215
solve differential equations
Euler beam, solving differential equation in python
https://stackoverflow.com/questions/48060894/euler-beam-solving-differential-equation-in-python
<p>I must solve the Euler Bernoulli differential beam equation which is:</p> <pre><code>w’’’’(x) = q(x) </code></pre> <p>and boundary conditions:</p> <pre><code>w(0) = w(l) = 0 </code></pre> <p>and </p> <pre><code>w′′(0) = w′′(l) = 0 </code></pre> <p>The beam is as shown on the picture below:</p> <p><a href="ht...
<p>You need to transform the ODE into a first order system, setting <code>u0=w</code> one possible and usually used system is</p> <pre class="lang-none prettyprint-override"><code> u0'=u1, u1'=u2, u2'=u3, u3'=q(x) </code></pre> <p>This can be implemented as</p> <pre><code>def ODEfunc(u,x): return [ u[1],...
216
solve differential equations
Solving Differential Equation Sympy
https://stackoverflow.com/questions/38950163/solving-differential-equation-sympy
<p>I haven't been able to find particular solutions to this differential equation.</p> <pre><code>from sympy import * m = float(raw_input('Mass:\n&gt; ')) g = 9.8 k = float(raw_input('Drag Coefficient:\n&gt; ')) v = Function('v') f1 = g * m t = Symbol('t') v = Function('v') equation = dsolve(f1 - k * v(t) - m * Deriv...
<p>I believe Sympy is not yet able to take into account initial conditions. Although <code>dsolve</code> has the option <code>ics</code> for entering initial conditions (see the documentation), it appears to be of limited use. </p> <p>Therefore, you need to apply the initial conditions manually. For example:</p> <pre...
217
solve differential equations
Solve couple of differential equations using Python
https://stackoverflow.com/questions/54689574/solve-couple-of-differential-equations-using-python
<p>I have to solve this couple of differential equations</p> <pre><code>dxdt = a - b*x*z dydt = c*y*exp(-E) dzdt = dxdt - sum(dydt*dE) </code></pre> <p>with a, b and c constants and E an array.</p> <p>As you can see, I need to process an integration over E to determine dzdt. Thus, dydt is an array also.</p> <p>I ...
218
solve differential equations
solving differential equations with parameters varying over intervals
https://stackoverflow.com/questions/39747767/solving-differential-equations-with-parameters-varying-over-intervals
<p>I would like to solve a system of differential equations with parameters varying over intervlas.</p> <p>Here is my code:</p> <pre><code># LOADING PACKAGES library(deSolve) # DATA CREATION t1 &lt;- data.frame(times=seq(from=0,to=5,by=0.1),interval=c(rep(0,10),rep(1,20),rep(2,21))) length(t1[which(t1$times&lt;1...
<p>@Mily comment: Yes, it is possible with <code>t1</code>, here the solution:</p> <p>Define <code>t1</code> (Intervall is not needed in my point of view). </p> <pre><code>t1 &lt;- data.frame(times=seq(from=0, to=5, by=0.1)) t1$mueDP=c(rep(3.1,10),rep(2.6,20),rep(1.1,21)) t1$mueHD=c(rep(2.6,10),rep(1.7,20),rep(1.3,21...
219
solve differential equations
Solving differential equations on c++
https://stackoverflow.com/questions/46287315/solving-differential-equations-on-c
<p>The <strong>main</strong> function runs a loop that feeds vector values to a serie of sequentially interdependent differential equations found in another function <strong>gate_probabilities</strong>, which feeds back the calculations to main and the loop repeats.</p> <p>The solutions for the equations are serially ...
<p>Your line</p> <pre><code>timevector.push_back( timevector[i - 1] + dt ); </code></pre> <p>will not work on the very first loop run, as timevector is empty.</p>
220
solve differential equations
How to solve differential equation using Python builtin function odeint?
https://stackoverflow.com/questions/27820725/how-to-solve-differential-equation-using-python-builtin-function-odeint
<p>I want to solve this differential equations with the given initial conditions:</p> <pre><code>(3x-1)y''-(3x+2)y'+(6x-8)y=0, y(0)=2, y'(0)=3 </code></pre> <p>the ans should be <br><br> <code>y=2*exp(2*x)-x*exp(-x)</code></p> <p>here is my code:</p> <pre><code>def g(y,x): y0 = y[0] y1 = y[1] y2 = (6*x-...
<p>There are several things wrong here. Firstly, your equation is apparently</p> <p>(3x-1)y''-(3x+2)y'-(6x-8)y=0; y(0)=2, y'(0)=3</p> <p>(note the sign of the term in y). For this equation, your analytical solution and definition of <code>y2</code> are correct.</p> <p>Secondly, as the @Warren Weckesser says, you mus...
221
solve differential equations
How to solve a system of differential equations?
https://stackoverflow.com/questions/28802527/how-to-solve-a-system-of-differential-equations
<p>For a homework assignment, my professor asked us to solve a system of differential equations using MATLAB. Using the mathworks website, I did</p> <pre><code>syms f(t) g(t) h(t) [f(t), g(t), h(t)] = dsolve(diff(f) == .25*g*h,... diff(g) == -2/3*f*h,... diff(h) == .5*f*g, f(0) == 1, g(0) == -2, h(0) == 3) </code></pr...
<pre><code>%x(1),x(2),x(3)=f,g,h fun = @(t,x) [0.25*x(2)*x(3); -2/3*x(1)*x(3); -0.5*x(1)*x(2)]; [t,x] = ode45(fun,[0 100],[1 2 3]); plot3(x(:,1),x(:,2),x(:,3)) %x has three columns which contains values of f,g,h as a function of time from %time t=0 to t=100 %please check ode45 in matlab to see what these arguments mea...
222
solve differential equations
Solving a system of differential equations by scipy.integrate.odeint
https://stackoverflow.com/questions/69786953/solving-a-system-of-differential-equations-by-scipy-integrate-odeint
<p>I am trying to solve a differential equation and I get this following error</p> <pre><code>/usr/local/lib/python3.7/dist-packages/scipy/integrate/odepack.py in odeint(func, y0, t, args, Dfun, col_deriv, full_output, ml, mu, rtol, atol, tcrit, h0, hmax, hmin, ixpr, mxstep, mxhnil, mxordn, mxords, printmessg, tfirst) ...
<p>If &quot;f&quot; is variable and dependent on &quot;t&quot;, then you can define it as a function of &quot;t&quot; and use that function instead of &quot;f&quot; in your rxn1 function. For example:</p> <pre><code>def f(t): # relation between f and t return value def rxn1(C,t): return np.array([f(t)*C0/v...
223
solve differential equations
Solving Ordinary Differential Equations using Euler in Java Programming
https://stackoverflow.com/questions/55960894/solving-ordinary-differential-equations-using-euler-in-java-programming
<p>I'm trying to write a java program that will solve any ordinary differential equations using Euler method, but I don't know how to write a code to get any differential equation from the user. I was only able to write the code to solve a predefined ordinary differential equations. </p> <p>I was able to come with a c...
<p>What you are looking for is the ability to compile some code at run time, where part of the code is supplied by the user.</p> <p>There is a package called JOOR that gives you a Reflect class that contains a compile method. The method takes two parameters (a package name:String and the Java code:String). I've never ...
224
solve differential equations
Solving system of coupled differential equations using Runge-Kutta in python
https://stackoverflow.com/questions/63811138/solving-system-of-coupled-differential-equations-using-runge-kutta-in-python
<p>This python code can solve one non- coupled differential equation:</p> <pre><code>import numpy as np import matplotlib.pyplot as plt import numba import time start_time = time.clock() @numba.jit() # A sample differential equation &quot;dy / dx = (x - y**2)/2&quot; def dydx(x, y): return ((x - y**2)/2) # F...
<p>With the help of others, I got to this:</p> <pre><code>import numpy as np from math import sqrt import matplotlib.pyplot as plt import numba import time start_time = time.clock() a=1 b=1 c=1 d=1 # Equations: @numba.jit() #du/dt=V(u,t) def V(u,t): x, y, vx, vy = u return np.array([vy,vx,a*x+b*y,c*x+d*y]) ...
225
solve differential equations
How to solve differential equations simultaneously using python?
https://stackoverflow.com/questions/60561147/how-to-solve-differential-equations-simultaneously-using-python
<p>I do have three differential equations of the form:</p> <pre><code>dx/dt= (-K1*x) dI/dt= ((K1*(x) - (K2*I**2))/2) dm/dt= 0.5*(K2*I**2) </code></pre> <p>I have data for time, x, I and m, with respect to time. How to calculate K1 and K2 using available packages in python? Can anyone help me with a sample code?</p> ...
226
solve differential equations
Wrong Answer while solving differential equation in C
https://stackoverflow.com/questions/56919237/wrong-answer-while-solving-differential-equation-in-c
<p>I am new to C programming and am writing a program to solve simple differential equations which gives output as the value of x. But I'm not getting the correct result.</p> <p>I am getting the correct value of the equation, but the value of the differential equation is wrong. The code compiles without any warnings o...
<p>You are making a simple logical error. In the function <code>float deriv(float a[], int deg, float x)</code> It should be <code>d[i] = (deg-i)*a[deg-i]*ps;</code>. So your function would look something like this</p> <pre><code>/* function for finding the derivative at some value of x */ float deriv(float a[], int ...
227
solve differential equations
Differential Equation Solve() Not Working (Julia)
https://stackoverflow.com/questions/65344695/differential-equation-solve-not-working-julia
<p>I'm super new to this and I couldn't really find any help online, so sorry if this has been answered before. I tried to follow this simple example on ordinary differential equations</p> <pre><code>using DifferentialEquations f(t,u) = 1.01*u u0=1/2 tspan = (0.0,1.0) prob = ODEProblem(f,u0,tspan) sol = solve(prob,Tsit...
<p>It looks like you've been following <a href="https://diffeq.sciml.ai/v2.0/tutorials/ode_example.html" rel="nofollow noreferrer">this example</a> from the <code>DifferentialEquations.jl</code> documentation; oddly enough Google seems to prioritise the documentation for v2.0 (see the URL in the link).</p> <p>The docum...
228
solve differential equations
Solving differential equations in Matlab - In-Vitro Dissolution
https://stackoverflow.com/questions/59101142/solving-differential-equations-in-matlab-in-vitro-dissolution
<p>I am trying to solve a similar problem to this one: <a href="https://stackoverflow.com/questions/58895739/solving-differential-equations-in-matlab">Solving Differential Equations in Matlab</a></p> <p>However, this time the scenario is not injection of a drug into the subcutaneous tissue and its subsequent dissoluti...
<p>I can not really reproduce your problem. I use the "standard" python modules numpy and scipy, copied the block of parameters, </p> <pre class="lang-py prettyprint-override"><code>MW=336.43; # molecular weight D=9.916e-5*(MW**-0.4569)*60/600000 #m2/s - [D(cm2/min)=9.916e-5*(MW^-0.4569)*60], divide by 600,000 to conv...
229
solve differential equations
Solving differential equations with a function called at each time step
https://stackoverflow.com/questions/67605649/solving-differential-equations-with-a-function-called-at-each-time-step
<p>System of equations</p> <pre><code>def SEIRD_gov(y, t, beta_0, c_1, c_2, sigma, gamma, dr, ro, tg, g_1, g_2, ind): S, E, I, R, D = y dSdt = -beta_gov(t, beta_0, c_1, c_2, tg, g_1, g_2, ind) * S * I/N dEdt = beta_gov(t, beta_0, c_1, c_2, tg, g_1, g_2, ind) * I * S/N - sigma * E dIdt = sigma * E -...
<p>I guess what you are missing is that <code>ind</code> must be a function, because it is a time-dependent coefficient.</p> <p>I'm assuming <code>df_region</code> is a <code>DataFrame</code> from <code>pandas</code>.</p> <p>So, modify the <code>ind</code> definition in your code to:</p> <pre><code>self_isolation_value...
230
solve differential equations
Combining solve and dsolve to solve equation systems with differential and algebraic equations
https://stackoverflow.com/questions/17701718/combining-solve-and-dsolve-to-solve-equation-systems-with-differential-and-algeb
<p>I am trying to solve equation systems, which contain algebraic as well as differential equations. To do this symbolically I need to combine dsolve and solve (do I?).</p> <p>Consider the following example: We have three base equations</p> <pre><code>a == b + c; % algebraic equation diff(b,1) == 1/C1*y(t); % differe...
<p>Now I assumed that you wanted the code to be rather general, so I made it to be able to work with any given number of equations and any given number of variables, and I did no calculation by hand.</p> <p>Note that the way that the symbolic Toolbox works changes drastically from year to year, but hopefully this will...
231
solve differential equations
Solve system differential equations (Sun and Jupiter trajectories)
https://stackoverflow.com/questions/59518547/solve-system-differential-equations-sun-and-jupiter-trajectories
<p>I'm trying to solve a system of differential equations and find the trajectory of Sun and Jupiter. But I don't have a nice trajectory, only some points. Could you help? ("Soleil" means Sun)</p> <p><a href="https://i.sstatic.net/bafUV.jpg" rel="nofollow noreferrer"><img src="https://i.sstatic.net/bafUV.jpg" alt="ent...
<p>Currently I see the following problems in your code that render your observations unreproducible (apart from missing reference values):</p> <ul> <li><p>In the initial data, the length unit is the astronomical unit and the time unit is one day. The unit of the gravitational constant is <code>m^3 s^-1 kg^-2</code>, s...
232
solve differential equations
solving two dimension-differential equations in python with scipy
https://stackoverflow.com/questions/34618488/solving-two-dimension-differential-equations-in-python-with-scipy
<p>i am a newbie to python. I have a simple differential systems, which consists of two variables and two differential equations and initial conditions <code>x0=1, y0=2</code>:</p> <pre><code>dx/dt=6*y dy/dt=(2t-3x)/4y </code></pre> <p>now i am trying to solve these two differential equations and i choose <code>odei...
<p>Apply trick to desingularize the division by <code>y</code>, print all ODE function evaluations, plot both components, and use the right differential equation with the modified code</p> <pre><code>import matplotlib.pyplot as pl import numpy as np from scipy.integrate import odeint def func(z,t): x, y=z pri...
233