text
stringlengths
81
47k
source
stringlengths
59
147
Question: <p>How to download bert models and load in python?</p> <pre class="lang-py prettyprint-override"><code>from sentence_transformers import SentenceTransformer model = SentenceTransformer('bert-base-nli-mean-tokens') </code></pre> <p><strong>How to save the pretrained model and load in python?</strong></p> Answ...
https://stackoverflow.com/questions/67950523/how-to-download-bert-models-and-load-in-python
Question: <p>I am working on a binary classification task and would like to try adding lstm layer on top of the last hidden layer of huggingface BERT model, however, I couldn't reach the last hidden layer. Is it possible to combine BERT with LSTM?</p> <pre class="lang-py prettyprint-override"><code>tokenizer = BertToke...
https://stackoverflow.com/questions/65763465/how-to-add-lstm-layer-on-top-of-huggingface-bert-model
Question: <p>I am training the binary classfier using BERT model implement in hugging face library</p> <pre><code>training_args = TrainingArguments( &quot;deleted_tweets_trainer&quot;, num_train_epochs = 1, #logging_steps=100, evaluation_strategy='steps', remove_u...
https://stackoverflow.com/questions/68871329/slow-training-of-bert-model-hugging-face
Question: <p>For some reason, I need to do further (2nd-stage) pre-training on Huggingface Bert model, and I find my training outcome is very bad.</p> <p>After debugging for hours, surprisingly, I find even training one single batch after loading the base model, will cause the model to predict a very bad choice when I ...
https://stackoverflow.com/questions/69127607/one-single-batch-training-on-huggingface-bert-model-ruins-the-model
Question: <p>I am trying to use BERT for sentiment analysis but I suspect I am doing something wrong. In my code I am fine tuning bert using <code>bert-for-tf2</code> but after 1 epoch I am getting an accuracy of 42% when a simple GRU model was getting around 73% accuracy. What should I be doing different to effectivel...
https://stackoverflow.com/questions/60732018/how-to-make-bert-model-converge
Question: <p>Prior to passing my tokens through encoder in BERT model, I would like to perform some processing on their embeddings. I extracted the embedding weight using:</p> <pre><code>from transformers import TFBertModel # Load a pre-trained BERT model model = TFBertModel.from_pretrained('bert-base-uncased') # Get...
https://stackoverflow.com/questions/75491528/what-does-the-embedding-elements-stand-for-in-huggingface-bert-model
Question: <p>I want to make BERT model by training with more data (not a fine-tuning, the base model which will be trained is 'bert-base-uncased'). However, do i always need to create own tokenizer for one model? when i use 'bert-base-uncased' tokenizer to train model, it give me some error.</p> <pre><code>Traceback (m...
https://stackoverflow.com/questions/71547846/does-bert-model-and-tokenizer-should-be-trained-with-same-data
Question: <p>When training the bert model, the weights are saved well, but the entire model is not saved.</p> <p>After <code>model.fit</code>, save model as <code>model.save_weights('bert_xxx.h5')</code> and <code>load_weights</code> works fine, but since only weights are saved, the model frame must be loaded separatel...
https://stackoverflow.com/questions/72674057/cant-save-model-in-saved-model-format-when-finetune-bert-model
Question: <p>I was able to deploy a NLP model using BERT embedding following this example (using TF 1.14.0 on CPU and tensorflow-model-server): <a href="https://mc.ai/how-to-ship-machine-learning-models-into-production-with-tensorflow-serving-and-kubernetes/" rel="nofollow noreferrer">https://mc.ai/how-to-ship-machine...
https://stackoverflow.com/questions/60777281/debugging-tensorflow-serving-on-bert-model
Question: <p>I want to make sure my BertModel does not loads pre-trained weights. I am using auto class (hugging face) which loads model automatically.</p> <p>My question is how do I load bert model without pretrained weights?</p> Answer: <p>Use AutoConfig instead of AutoModel:</p> <pre><code>from transformers import ...
https://stackoverflow.com/questions/65072694/make-sure-bert-model-does-not-load-pretrained-weights
Question: <p>I have managed to get the BERT model to work on johnsnowlabs-spark-nlp library. I am able to save the "trained model" on disk as follows.</p> <h1>Fit Model</h1> <pre><code>df_bert_trained = bert_pipeline.fit(textRDD) df_bert=df_bert_trained.transform(textRDD) </code></pre> <h1>save model</h1> <pre><co...
https://stackoverflow.com/questions/59881819/persist-bert-model-on-disk-as-pickle-file
Question: <p>Is there a <em>Step by step explanation</em> on how to <strong>Fine-tune HuggingFace BERT</strong> model for text classification?</p> Answer: <h1>Fine Tuning Approach</h1> <p>There are multiple approaches to fine-tune BERT for the target tasks.</p> <ol> <li>Further Pre-training the base BERT model</li> <l...
https://stackoverflow.com/questions/69025750/how-to-fine-tune-huggingface-bert-model-for-text-classification
Question: <p>I am unable to figure out why my BERT model dosen't get pas the training command. I am using pytorch-lightning. I am running the code on AWS EC2(p3.2xLarge) and it does show me the available GPU but I can't really figure out the device side error. Could someone please guide me towards a direction? I really...
https://stackoverflow.com/questions/72753200/training-the-bert-model-with-pytorch
Question: <p>It is the first time that I want to use BERT. I'm trying to execute this code.</p> <pre><code>from keras_bert import load_trained_model_from_checkpoint config_path = './model/bert_config.json' checkpoint_path = './model/model.ckpt-1400000' bert = load_trained_model_from_checkpoint(config_path, checkpoint_p...
https://stackoverflow.com/questions/63484093/bert-model-as-model-ckpt-1400000
Question: <p>How to estimate the number of neurons (units) in the BERT model? <strong>Note</strong> this is different from the number of model parameters.</p> Answer: <p>Depending on which field you come from the &quot;neurons&quot; definition might differ.</p> <p>In general, people in computer science conflates <code...
https://stackoverflow.com/questions/75844264/how-many-neurons-units-are-there-in-the-bert-model
Question: <p>I am trying to learn NLP using BERT. While trying to import bert model and tokenizer in colab. I am facing the below error.</p> <pre><code>ImportError: cannot import name '_LazyModule' from 'transformers.file_utils' (/usr/local/lib/python3.7/dist-packages/transformers/file_utils.py) </code></pre> <p>Here i...
https://stackoverflow.com/questions/73359430/unable-to-import-bert-model-with-all-packages
Question: <p>I'm trying to fine-tune/pre-train an existing BERT model for sentiment analysis by using Trainer API in <code>transformers</code> library. My training dataset looks like this:</p> <pre><code>Text Sentiment This was good place 1 This was bad place ...
https://stackoverflow.com/questions/70263251/valueerror-when-pre-training-bert-model-using-trainer-api
Question: <p>I got error in linear function</p> <pre><code>class MixModel(nn.Module): def __init__(self,pre_trained='bert-base-uncased'): super().__init__() self.bert = AutoModel.from_pretrained('distilbert-base-uncased') self.hidden_size = self.bert.config.hidden_size self....
https://stackoverflow.com/questions/71309113/cnn-model-and-bert-with-text
Question: <p>I come here after I have been googling during many hours for to know if it's was possible to make a fine-tune <code>BERT</code> Question Answering with only question and context ? I am beginner with BERT model so I don't know the deep mechanism that it have even after many search. Thanks you for your answe...
https://stackoverflow.com/questions/77783666/fine-tuning-a-bert-model-without-answers
Question: <p>I have trained my pre-trained BERT model from the Hugging Face library on the <code>Jigsaw Toxic Comment Classification dataset</code> to detect hateful comments. However, when I try to do infer with the positive sentences, it is giving me wrong results.</p> <p>For example, if I provide the sentence: <code...
https://stackoverflow.com/questions/69757233/pre-trained-bert-model-learning-wrong-way
Question: <p>I have tried below codes for reusing the saved BERT model.</p> <pre><code>def serving_input_receiver_fn(): feature_spec = { "input_ids" : tf.FixedLenFeature([MAX_SEQ_LENGTH], tf.int64), "input_mask" : tf.FixedLenFeature([MAX_SEQ_LENGTH], tf.int64), "segment_ids" : tf.FixedLenFeature([MAX_SEQ...
https://stackoverflow.com/questions/58115439/how-to-reuse-the-bert-model-using-tensorflow-contrib
Question: <p>I am using BERT for Named Entity Recognition. Initially I had only 18 labels, and I trained the model using the 18 labels and saved the model. Now I added 2 more new labels, and when I updated the previously saved model I am getting the following error:</p> <pre class="lang-sh prettyprint-override"><code>...
https://stackoverflow.com/questions/62337074/adding-new-labels-to-an-already-trained-bert-model
Question: <p>I am training a BERT model on spam classification using JAX on TPUs. My model hasn't been learning nor its results have changed.</p> <pre><code>Epoch 0: Train Loss = 2.7961559295654297: Train Accuracy: 0.30608975887298584 Eval Loss = 3.6600053310394287: Eval Accuracy = 0.0 Epoch 1: Train Loss = 2.796155929...
https://stackoverflow.com/questions/79383687/bert-model-not-learning-using-jax-results-dont-change
Question: <p>I have fine-tuned a Bert model and testing my output from different layers. I tested this in sagemaker , with my own custom script (see below) and the output i get is of BaseModelOutputWithPoolingAndCrossAttentions class. How can i convert the output of this , specially the tensor values from the last_hidd...
https://stackoverflow.com/questions/73830782/how-to-convert-bert-model-output-to-json
Question: <p>Here is my problem: I am working on the German text classification project. I use spacy for that and decided to fine-tune its pretrained BERT model to get better results. However, when I try to load it to the code, it shows me errors.</p> <p>Here is what I've done:</p> <ol> <li>Installed spacy-transforme...
https://stackoverflow.com/questions/61899118/cannot-load-german-bert-model-in-spacy
Question: <p>I'm trying to train my model using GPUs.</p> <p>When I execute it I get this error below:</p> <pre><code>File &quot;main.py&quot;, line 95, in train loss.backward() File &quot;/opt/conda/lib/python3.7/site-packages/torch/tensor.py&quot;, line 198, in backward torch.autograd.backward(self, gradient, retain_...
https://stackoverflow.com/questions/62991456/i-have-an-error-while-training-bert-model
Question: <p>I have a basic conceptual doubt. When i train a bert model on sentence say:</p> <pre><code>Train: &quot;went to get loan from bank&quot; Test :&quot;received education loan from bank&quot; </code></pre> <p>How does the test sentence assigns the weights for each token because i however dont pass exact sent...
https://stackoverflow.com/questions/65925640/assigning-weights-during-testing-the-bert-model
Question: <p>Receiving an error once running the BERT model. Up till this point the code runs successfully. Error I receive is AttributeError: 'str' object has no attribute 'shape'. The previous step before the code was creating a custom data generator. Using this the model was created. To provide context the model I u...
https://stackoverflow.com/questions/67046637/how-to-solve-attribute-error-after-running-bert-model
Question: <p>I am using the <a href="https://github.com/pair-code/lit" rel="nofollow noreferrer">Language Interpretability Toolkit</a> (LIT) to load and analyze a BERT model that I pre-trained on an NER task.</p> <p>However, when I'm starting the LIT script with the path to my pre-trained model passed to it, it fails t...
https://stackoverflow.com/questions/66561880/weights-of-pre-trained-bert-model-not-initialized
Question: <p>I have tried to follow Tensorflow instructions to use BERT model: (<a href="https://www.tensorflow.org/tutorials/text/classify_text_with_bert" rel="noreferrer">https://www.tensorflow.org/tutorials/text/classify_text_with_bert</a>)</p> <p>However, when I run these lines:</p> <pre><code>text_test = ['this is...
https://stackoverflow.com/questions/65298391/error-with-using-bert-model-from-tensorflow
Question: <p>The bert model gives us the two outputs, one gives us the [batch,maxlen,hiddenstates] and other one is [batch, hidden States of cls token]. But I did not understood when to use the specific output. Can anyone tell me for which task which output should be used??</p> Answer: <p>The output is usually <code>...
https://stackoverflow.com/questions/63673511/how-to-use-the-outputs-of-bert-model
Question: <p>I've been trying to use <code>spaCy</code>'s pretrained BERT model <code>de_trf_bertbasecased_lg</code> to increase accuracy in my classification project. I used to build a model from scratch using <code>de_core_news_sm</code> and everything worked fine: I had an accuracy around 70%. But now I am using BER...
https://stackoverflow.com/questions/61943409/spacys-bert-model-doesnt-learn
Question: <p>I'm having some issues trying to calculate the accuracy of a custom BERT model which also uses the pretrained model from Huggingface. This is the code that I have :</p> <pre><code>import numpy as np import pandas as pd from sklearn import metrics, linear_model import torch from torch.utils.data import Data...
https://stackoverflow.com/questions/67420868/issues-calculating-accuracy-for-custom-bert-model
Question: <p>I want you to use different pretrain bert model embeddings for the bert score. How can I do that? P, R, F1 = score(cand, ref, lang=&quot;bn&quot;, model_type=&quot;distilbert-base-uncased&quot;, verbose=True) In model_type if use my pretain model then it gives a keyError.</p> Answer: <p>You need to pass ...
https://stackoverflow.com/questions/76306997/how-to-use-a-different-pre-trained-bert-model-with-bert-score
Question: <p>(I'm following <a href="https://mccormickml.com/2019/05/14/BERT-word-embeddings-tutorial/" rel="noreferrer">this</a> pytorch tutorial about BERT word embeddings, and in the tutorial the author is access the intermediate layers of the BERT model.)</p> <p>What I want is to access the last, lets say, 4 last ...
https://stackoverflow.com/questions/61465103/how-to-get-intermediate-layers-output-of-pre-trained-bert-model-in-huggingface
Question: <p>My custom BERT model's architecture:</p> <pre><code>class BertArticleClassifier(nn.Module): def __init__(self, n_classes, freeze_bert_weights=False): super(BertArticleClassifier, self).__init__() self.bert = AutoModel.from_pretrained('bert-base-uncased') if freeze_bert_weights...
https://stackoverflow.com/questions/68596995/why-is-bert-model-with-pytorch-native-approach-not-learning
Question: <p>I am trying to fine-tune a pretrained BERT model on amazon-review dataset. For that I extended the <code>run_classifier</code> file by the following processor:</p> <pre><code>class AmazonProcessor(DataProcessor): """Processor for the Amazon data set.""" def get_train_examples(self, data_dir): """...
https://stackoverflow.com/questions/56769943/bert-model-does-not-learn-new-task
Question: <p>I want some help regarding adding additional words in the existing BERT model. I have two quires kindly guide me:</p> <p>I am working on NER task for a domain:</p> <p>There are few words (not sure the exact numbers) that BERT recognized as [UNK], but those entities are required for the model to recognize. ...
https://stackoverflow.com/questions/64816669/using-pretrained-bert-model-to-add-additional-words-that-are-not-recognized-by-t
Question: <p>I want to run the <a href="https://github.com/vdobrovolskii/wl-coref" rel="nofollow noreferrer">wl-coref</a> model with an Electra model instead of a Bert model. However, I get an error message with the Electra model and can't find a hint in the Huggingface documentation on how to fix it.</p> <p>I try diff...
https://stackoverflow.com/questions/72680932/try-to-run-an-nlp-model-with-an-electra-instead-of-a-bert-model
Question: <p>I'm predicting sentiment analysis of Tweets with positive, negative, and neutral classes. I've trained a BERT model using Hugging Face. Now I'd like to make predictions on a dataframe of unlabeled Twitter text and I'm having difficulty.</p> <p>I've followed the following tutorial (<a href="https://curiousi...
https://stackoverflow.com/questions/69820318/predicting-sentiment-of-raw-text-using-trained-bert-model-hugging-face
Question: <p>I have generated new Base BERT model(<strong>dataset1_model_cased_L-12_H-768_A-12</strong>) using <strong>cased_L-12_H-768_A-12</strong> as trained multi label classification from <a href="https://github.com/dmis-lab/biobert/blob/master/run_classifier.py" rel="nofollow noreferrer">biobert-run_classifier</a...
https://stackoverflow.com/questions/62948266/retraining-existing-base-bert-model-with-additional-data
Question: <p>Hi I encounter this error when I was training my Bert Model for sentiment analysis, where my classes have 3 outcomes and my input data is text.</p> <p>So I got the above error when I am training the model. I have searched some of the guides and tried to set this parameter to my bert model <code>bert_model ...
https://stackoverflow.com/questions/72442319/typeerror-dropout-argument-input-position-1-must-be-tensor-not-str-bert
Question: <p>I have already trained a bert model and saved it in the .pb format and I want to retrain the model with new datasets that i custom made, so in order to not to lose the previous training and such, how do I train the model with the new data so the model could update it self any approaches? this is my trainin...
https://stackoverflow.com/questions/72040423/how-do-i-retrain-bert-model-with-new-data
Question: <p>I already fine-tuned a BERT model ( with the huggingface library) for a classification task to predict a post category in two types (1 and 0, for example). But, I would need to retrieve the &quot;relevant tokens&quot; for the documents that are predicted as category 1 (for example). I know that I can use t...
https://stackoverflow.com/questions/66860788/retrieve-the-relevant-tokens-with-a-bert-model-already-fine-tuned
Question: <p>First i create tokenizer as follow</p> <pre><code>from tokenizers import Tokenizer from tokenizers.models import BPE,WordPiece tokenizer = Tokenizer(WordPiece(unk_token=&quot;[UNK]&quot;)) from tokenizers.trainers import BpeTrainer,WordPieceTrainer trainer = WordPieceTrainer(vocab_size=5000,min_frequency=...
https://stackoverflow.com/questions/67957446/train-bert-model-from-scratch-on-a-different-language
Question: <p>I have pre-trained a bert model with custom corpus then got vocab file, checkpoints, model.bin, tfrecords, etc.</p> <p>Then I loaded the model as below :</p> <pre class="lang-py prettyprint-override"><code># Load pre-trained model (weights) model = BertModel.from_pretrained('/content/drive/My Drive/Anirban...
https://stackoverflow.com/questions/64365122/huggingface-pre-trained-bert-model-is-not-working
Question: <p>I am new to nlp and i want to build a bert model for sentiment Analysis so i am following this tuto <a href="https://curiousily.com/posts/sentiment-analysis-with-bert-and-hugging-face-using-pytorch-and-python/" rel="nofollow noreferrer">https://curiousily.com/posts/sentiment-analysis-with-bert-and-hugging-...
https://stackoverflow.com/questions/65461593/tensor-type-attributes-in-bert-model-returned-as-string
Question: <p>I'm a novice in writing neural networks. I have just started using BERT models, while running BERT for text summarization using the examples in <a href="https://pypi.org/project/bert-extractive-summarizer/" rel="nofollow noreferrer">bert extractive summarizer</a> I get the following error with the pretrain...
https://stackoverflow.com/questions/63832094/i-get-error-while-downloading-bert-models-for-summarization
Question: <p>I am trying to implement the BERT model architecture using Hugging Face and KERAS. I am learning this from the Kaggle (<a href="https://www.kaggle.com/tanulsingh077/deep-learning-for-nlp-zero-to-transformers-bert" rel="noreferrer">link</a>) and try to understand it. When I tokenized my data, I face some pr...
https://stackoverflow.com/questions/66743649/bert-model-enable-padding-got-an-unexpected-keyword-argument-max-length
Question: <p>I am working on training the BERT Model for Pytorch. I'm quite new to Pytorch as well. My code as replicated from: <a href="https://towardsdatascience.com/text-classification-with-bert-in-pytorch-887965e5820f" rel="nofollow noreferrer">https://towardsdatascience.com/text-classification-with-bert-in-pytorch...
https://stackoverflow.com/questions/75622232/index-out-of-range-in-self-bert-model-tuning-pytorch
Question: <p>I am doing text classification with keras model (sequential). Now, what can I do to improve the model performance (the accuracy, the val accuracy, the prediction, etc). This is my model architecture:</p> <pre><code>from tensorflow.keras.callbacks import EarlyStopping, ModelCheckpoint from keras.utils.vis_u...
https://stackoverflow.com/questions/66356324/how-can-i-integrate-bert-model-in-my-notebook-python
Question: <p>For example I have an original sentence. The word <strong>barking</strong> corresponds to the word that is missing.</p> <pre><code>Original Sentence : The dog is barking. Incomplete Sentence : The dog is ___________. </code></pre> <p>For example, using the BERT model, it predicts the word crying instead...
https://stackoverflow.com/questions/58840538/bert-model-evaluation-measure-in-terms-of-syntax-correctness-and-semantic-cohere
Question: <p>I'm encountering persistent issues deploying a custom container to Vertex AI using gcloud ai endpoints deploy-model. I'm trying to deploy a BERT model packaged in a Docker image, but I'm consistently facing errors despite providing the correct Artifact Registry image path.</p> <p>Here's a breakdown of my s...
https://stackoverflow.com/questions/79502332/gcloud-ai-endpoints-deploy-model-fails-with-model-server-exited-unexpectedly
Question: <p>I am using this code to train Bert for Turkish language model classification with 2 labels. But when I run the following code:</p> <pre><code>import numpy as np import pandas as pd df = pd.read_excel (r'preparedDataNoId.xlsx') df = df.sample(frac = 1) from sklearn.model_selection import train_test_split ...
https://stackoverflow.com/questions/65073823/bert-model-train-dont-want-to-stop
Question: <p>So, I made a custom dataset consisting of reviews form several E-learning sites. What I am trying to do is build a model that can recognize emotions based on text and for training I am using the dataset I've made via scraping. While working on BERT, I encountered this error</p> <p><code>normalize() argumen...
https://stackoverflow.com/questions/67360987/bert-model-bug-encountered-during-training
Question: <p>I am trying to fine tune a Huggingface Bert model using Tensorflow (on ColabPro GPU enabled) for tweets sentiment analysis. I followed step by step the guide on the Huggingface website, but I am experiencing a weird training time. This happens with all the Bert models I tried. I have two datasets of differ...
https://stackoverflow.com/questions/72139450/weird-behaviour-when-finetuning-huggingface-bert-model-with-tensorflow
Question: <p>I am using a pre-trained BERT sentence transformer model, as described here <a href="https://www.sbert.net/docs/training/overview.html" rel="noreferrer">https://www.sbert.net/docs/training/overview.html</a> , to get embeddings for sentences.</p> <p>I want to fine-tune these pre-trained embeddings, and I am...
https://stackoverflow.com/questions/69562624/fine-tuning-bert-sentence-transformer-model
Question: <p>I have sentiment analysis model using BERT and I want to get the result from predicting text via FastAPI but it always give negative answer (I think it is because the prediction didn't give prediction result).</p> <p>This is my code:</p> <pre><code>import uvicorn from fastapi import FastAPI import joblib ...
https://stackoverflow.com/questions/65885841/fastapi-return-bert-model-result-and-metrics
Question: <p>Hi here is a part of my code to use a pre-trained bert model for classification: </p> <pre><code> model = BertForSequenceClassification.from_pretrained( "bert-base-uncased", # Use the 12-layer BERT model, with an uncased vocab. num_labels = 2, # The number of output labels--2 for binary class...
https://stackoverflow.com/questions/60561504/runtimeerror-working-on-ia-tryna-use-a-pre-trained-bert-model
Question: <p>I am unaware to use the derived checkpoints from pre-trained BERT model for the task of semantic text similarity.</p> <p>I have run a pre-trained BERT model with some domain of corpora from scratch. I have got the checkpoints and graph.pbtxt file from the code below. But I am unaware on how to use those f...
https://stackoverflow.com/questions/57461607/how-to-use-pretrained-checkpoints-of-bert-model-on-semantic-text-similarity-task
Question: <p>For the line: loss = model(b_input_ids, token_type_ids=None, attention_mask=b_input_mask, labels=b_labels) I have labels hot encoded such that it is a tensor of 32x17, since the batch size is 32 and there are 17 classes for the text categories. However, BERT model only takes for the label with a single dim...
https://stackoverflow.com/questions/68104425/bert-model-loss-function-from-one-hot-encoded-labels
Question: <p>I had fine tuned a bert model in pytorch and saved its checkpoints via <code>torch.save(model.state_dict(), 'model.pt')</code></p> <p>Now When I want to reload the model, I have to explain whole network again and reload the weights and then push to the device.</p> <p>Can anyone tell me how can I save the b...
https://stackoverflow.com/questions/71561761/how-to-load-a-fine-tuned-pytorch-huggingface-bert-model-from-a-checkpoint-file
Question: <p>I try to work with ktrain to finetune bert model. I'm using pandas dataframe named train_df to store my data.</p> <p><code>x_train, x_val, y_train, y_val = train_test_split(train_df['text'], train_df['target'], shuffle=True, test_size = 0.2, random_state=random_seed, stratify=train_df['target'])</code></p>...
https://stackoverflow.com/questions/73791130/cant-get-bert-model-to-run-using-ktrain-and-pandas-dataframe
Question: <p>I am trying to make a binary predictor on some data which has one columns with text and some additional columns with numerical values. My first solution was to use word2vec on the text to extract 30 features and use them with the other values in a Random Forest. It produces good result. I am interested in ...
https://stackoverflow.com/questions/58061775/how-to-extract-features-from-text-based-on-fine-tuned-bert-model
Question: <p>I am trying to implement BERT Model for Question Answering tasks, but Its a little different from the existing Q&amp;A models, The Model will be given some text(3-4 pages) and will be asked questions based on the text, and the expected answer may be asked in short or descriptive subjective type</p> <p>I t...
https://stackoverflow.com/questions/74654341/how-to-answer-subjective-descriptive-types-of-lquestions-using-bert-model
Question: <p>I need assistance in my NLP project, where the goal is to predict a list of possible answers for a given crossword clue. The idea is to <strong>fine tune a BERT model using a dataset of crossword clue - answer pairs</strong>.</p> <p>train.source looks like this : Line at an airport, Kind of omelet, Susa wa...
https://stackoverflow.com/questions/78636736/fine-tuning-bert-model-for-text-generation-crossword-solver
Question: <p>There are 2 types of Generalized Linear Models: <br>1. Log-Linear Regression, also known as Poisson Regression <br>2. Logistic Regression</p> <p>How to implement the Poisson Regression in Python for Price Elasticity prediction?</p> Answer: <p>Have a look at the <a href="https://pypi.python.org/pypi/sta...
https://stackoverflow.com/questions/37941881/how-to-implement-poisson-regression
Question: <p>I've been trying for a while to implement my first regression neural network in MATLAB, following the example from figure 5.3 in page 231 from '<a href="http://users.isr.ist.utl.pt/~wurmd/Livros/school/Bishop%20-%20Pattern%20Recognition%20And%20Machine%20Learning%20-%20Springer%20%202006.pdf" rel="nofollow...
https://stackoverflow.com/questions/51189147/problems-implementing-regression-neural-network
Question: <p>As part of pursuing a course, I was trying to implement L1 logistic regression using scikit-learn in Python. Unfortunately for the code</p> <pre><code>clf, pred = fit_and_plot_classifier(LogisticRegression(penalty = 'l1', C=1000000)) </code></pre> <p>I get the error message</p> <pre><code>ValueError: So...
https://stackoverflow.com/questions/59881343/how-to-implement-l1-logistic-regression
Question: <p>I want to implement <a href="https://en.wikipedia.org/wiki/Ordinal_regression" rel="nofollow noreferrer">ordinal regression</a> in Theano. But I've no idea how to implement the middle part: threshold definition and usage.</p> <p>For example(simply say): </p> <pre><code>X = T.matrix('X', dtype='float32') ...
https://stackoverflow.com/questions/44666127/implement-ordinal-regression-in-theano
Question: <p>I'm trying to implement my own linear regression likelihood ratio test.</p> <p>The test is where you take the sum of squares of a reduced model and the sum of squares of a full model and compare it to the F statistic.</p> <p>However, I am having some trouble implementing the function, especially when dea...
https://stackoverflow.com/questions/49764026/manually-implementing-regression-likelihood-ratio-test
Question: <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...
https://stackoverflow.com/questions/78572569/how-can-i-implement-regression-after-multi-class-multi-label-classification
Question: <p>In excel it is possible to implement linear regression graph. But in ms access I could not find anything similar to excel. If there is nothing built in then how can I implement it.?</p> Answer: <p>just take the data that you generated in Excel for the line regression and export it to Access.Then click on ...
https://stackoverflow.com/questions/30661809/ms-access-how-to-implement-linear-regression
Question: <p>I’m implementing softmax regression in Octave. Currently I’m using a non-vectorized implementation using following cost function and derivatives.</p> <p><a href="https://i.sstatic.net/l6AQf.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/l6AQf.png" alt="alt text"></a> </p> <p><a href="http...
https://stackoverflow.com/questions/8998321/vectorized-implementation-of-softmax-regression
Question: <p>I am applying multiple ML algorithm to this dataset so I tried logistic regression and I plotted the predictions and it seems completely off since the plot only shows data points from one class. Here is the data and what I attempted</p> <pre><code>set.seed(10) x1 &lt;- runif(500) - 0.5 x2 &lt;- runif(50...
https://stackoverflow.com/questions/47278604/implement-logistic-regression
Question: <p>I am new to exploring the fable package, and I was wanting to implement Regressors in a Hierarchical Time Series model. How should the Dimensionality of the data be? Should there be an additional column inside the <code>tsibble</code> object? For example, in an ARIMA model. Thank you very much in advance.<...
https://stackoverflow.com/questions/65685672/how-to-implement-regressors-in-a-hierarchical-series-in-r-with-the-fable-packag
Question: <p>I refer to the link <a href="https://stats.stackexchange.com/questions/105516/how-to-implement-a-2-d-gaussian-processes-regression-through-gpml-matlab">https://stats.stackexchange.com/questions/105516/how-to-implement-a-2-d-gaussian-processes-regression-through-gpml-matlab</a> and create a 2-d Gaussian Pro...
https://stackoverflow.com/questions/69673457/problem-with-implement-a-4-d-gaussian-processes-regression-through-gpml
Question: <p>I am practicing simple regression models as an intro to machine learning. I have reviewed a few sample models for multiple regression, which is, I believe, an extension of linear regression, but with more than 1 feature. From the examples I have seen, the syntax is the same for linear regression and multip...
https://stackoverflow.com/questions/61335228/how-to-implement-multiple-regression
Question: <p>I tried to implement logistic regression only with numpy in Python, but the result is not satisfying. The predictions seems incorrect and loss is not improving so it is probably something wrong with the code. Does anyone know what could fix it? Thank you very much!</p> <p>Here is algorithm:</p> <pre><code>...
https://stackoverflow.com/questions/66051281/logistic-regression-python-implementation
Question: <p>I am using <code>tbl_uvregression</code> doing logistic regression but some of the categorical explanatory variables have missing values. The missing value category is being chosen as the reference category. How do I implement the function such that I only use complete cases for each variable?</p> <p>Sampl...
https://stackoverflow.com/questions/63180323/how-do-you-properly-implement-regression-with-categorical-explanatory-variables
Question: <p>I have a regression problem on which I want to use logistic regression - not logistic classification - because my target variables <code>y</code> are continuopus quantities between 0 and 1. However, the common implementations of logistic regression in Python seem to be exclusively logistic classification. ...
https://stackoverflow.com/questions/65268985/python-implementation-of-logistic-regression-as-regression-not-classification
Question: <p>I want to implement kernel ridge regression in R. My problem is that I can't figure out how to generate the kernel values and I do not know how to use them for the ridge regression. I want to use the following kernel function:</p> <pre><code>kernel.eval &lt;- function(x1,x2,ker) { k=0 if (kertype == 'RBF'...
https://stackoverflow.com/questions/33863234/implementing-kernel-ridge-regression-in-r
Question: <p>I want to implement Random forest regression in pyspark after all data preparation. I want sample code for implementation.</p> Answer: <p>From the doc (<a href="https://spark.apache.org/docs/latest/api/python/pyspark.ml.html#pyspark.ml.regression.RandomForestRegressor" rel="nofollow noreferrer">https://sp...
https://stackoverflow.com/questions/57587475/random-forest-regression-implementation-in-pyspark
Question: <p>I want to implement single variable regression using ordinary least squares. I have no access to linear algebra or calculus libraries, so any matrix operations or differentiation methods needs to be implemented by me. What is the least complex method?</p> Answer: <p>John D. Cook has an <a href="http://www...
https://stackoverflow.com/questions/31735595/what-is-the-easiest-to-implement-linear-regression-algorithm
Question: <p>I implemented simple linear regression in <a href="http://dlib.net/" rel="nofollow noreferrer">Dlib</a> as a single-layer perceptron with MSE-loss with a single output. The network type is:</p> <pre><code>dlib::loss_mean_squared&lt;dlib::fc&lt;1,dlib::input&lt;dlib::matrix&lt;float&gt;&gt;&gt;&gt; </code>...
https://stackoverflow.com/questions/54633033/how-to-implement-multivariate-regularized-linear-regression-in-dlib
Question: <p>I'm trying to build and implement a regression tree algorithm on some raster data in python, and can't seem to find the best way to do so. I will attempt to explain what I'm trying to do:</p> <p>My desired output is a raster image, whose values represent lake depth, call it depth.tif. I have a series of r...
https://stackoverflow.com/questions/26104434/method-for-implementing-regression-tree-on-raster-data-python
Question: <p>I am performing a resource selection function using use and availability locations for a set of animals. For this type of analysis, an infinitely weighted logistic regression is suggested (Fithian and Hastie 2013) and is done by setting weights of used locations to 1 and available locations to some large n...
https://stackoverflow.com/questions/67762244/how-to-implement-a-weighted-logistic-regression-in-jags
Question: <p>Trying to understand and implement GridSearch method for the Keras Regression. Here is my simple producible regression application. </p> <pre><code>import pandas as pd import numpy as np import sklearn from sklearn.model_selection import train_test_split from sklearn import metrics from keras.models impor...
https://stackoverflow.com/questions/52551511/gridsearch-implementation-for-keras-regression
Question: <p>Is it possible to use GridsearchCV for models which doesn't deal with regression? I have been able to implement HyperOpt and Bayes_Opt for the said model.</p> Answer:
https://stackoverflow.com/questions/73031371/how-to-implement-gridsearch-for-models-other-than-regression-models
Question: <p>I am trying to implement linear regression in R. Below is my code:</p> <pre><code>library(ggplot2) df &lt;- data.frame() df&lt;-cbind(c(10000,20000,5000,5123,5345,5454,11000,23000,6000,6100,6300), c(5600,21000,1000,2000,2300,3000,7000,21400,3200,3250,3300)) df &lt;- as.data.frame(df) colnames(df)&lt;-c(...
https://stackoverflow.com/questions/49600778/getting-nan-while-implementing-linear-regression
Question: <p>This is my try to implement multi-class logistic regression in python using softmax as activation function and mnist digit data set as training and test set.</p> <pre><code>import numpy as np def softmax(z): return np.array([(np.exp(el)/np.sum(np.exp(el))) for el in z]) def cost(W,F,L): m = F.shap...
https://stackoverflow.com/questions/57911771/multiclass-logistic-regression-implementation-question
Question: <p>[<a href="https://docs.google.com/spreadsheets/d/1AVNrWBwn22c1QWc6X9zG8FkvTMXHXZGuZH2sPAT9a00/edit?usp=sharing" rel="nofollow noreferrer">Dataset</a>]<a href="https://docs.google.com/spreadsheets/d/1AVNrWBwn22c1QWc6X9zG8FkvTMXHXZGuZH2sPAT9a00/edit?usp=sharing" rel="nofollow noreferrer">1</a>I'm attempting ...
https://stackoverflow.com/questions/66756559/trying-to-implement-linear-regression-with-stochastic-gradient-descent
Question: <p>I would like to implement regression algorithms using python-weka-wrapper in Jupyter Notebook. However, I couldn't find the correct function in <a href="https://fracpete.github.io/python-weka-wrapper/api.html#classifiers" rel="nofollow noreferrer">https://fracpete.github.io/python-weka-wrapper/api.html#cla...
https://stackoverflow.com/questions/66135163/how-to-use-regression-in-python-weka-wrapper
Question: <p>I am keen to implement a conditional (bivariate?) poisson regression in R to assess the change in rates of a variable (stratified by treatment condition) pre- / post- an intervention. Is anyone familiar with a package that runs this type of analysis?</p> Answer: <p>Check out this <a href="https://cran.r-p...
https://stackoverflow.com/questions/49024652/how-does-one-implement-a-conditional-poisson-regression-in-r
Question: <p>I am implementing linear regression in Python, and I think I am doing something wrong while converting matrix to numpy array, but cannot seem to figure it out. Any help will be appreciated.</p> <p>I am loading data from a csv file that has 100 columns. y is the last column. I am not using col 1 and 2 for...
https://stackoverflow.com/questions/26678708/trying-to-implement-linear-regression-in-python
Question: <p>I am new to Machine learning and I was trying to implement vectorized linear regression from scratch using numpy. I tried testing out the implementation using y=x. But my loss is increasing and I am unable to understand why. It will be great if someone could point out why is this happening. Thanks in advan...
https://stackoverflow.com/questions/60133065/problem-in-the-linear-regression-implementation
Question: <p>I'm trying to implement linear regression with only one feature using <code>fminunc</code> in Octave.</p> <p>Here is my code.</p> <pre class="lang-matlab prettyprint-override"><code>x = load('/home/battousai/Downloads/ex2Data/ex2x.dat'); y = load('/home/battousai/Downloads/ex2Data/ex2y.dat'); m = leng...
https://stackoverflow.com/questions/44848279/linear-regression-using-fminunc-implementation
Question: <p>I am trying to implement Ridge regression but I feel like I am missing something with the Python operators. Here is my code:</p> <pre><code>import numpy as np x = np.random.rand(10, 2) y = np.random.rand(10, 1) lambda_reg = 0.1 alpha = 0.1 num_iterations = 100000 X_train = np.hstack((np.ones(...
https://stackoverflow.com/questions/79299410/scratch-implementation-of-ridge-regression
Question: <p>I'm taking the Machine Learning class by Prof. Ng. There is a homework need to implement logistic regression gradient descent. And here is my code:</p> <pre><code>function [J, grad] = costFunction(theta, X, y) %COSTFUNCTION Compute cost and gradient for logistic regression % J = COSTFUNCTION(theta, X, y)...
https://stackoverflow.com/questions/63046676/logistic-regression-gradient-descent-octave-implementation
Question: <p>Recently, I have been reading about machine learning of which logistic regression is one. After reading, to test my understanding, I tried to implement LR in Java. When I tested it on Logical OR and Logical AND, it seemed to work. But, when I tried it on marks to decide accepted or rejected job applicants,...
https://stackoverflow.com/questions/56041493/logistic-regression-implementation-not-working