Study names not showing in forest in R - forestplot

I am trying to make forest function show the study names in forest plot using slab argument , but it still doesnt show there. Could someone please help?
forest(meta1,
header= "Author(s), Year",
xlab="Correlation coefficient",
slab=paste(meta1$author, meta1$year, sep = ","),
weight.study = "random")
Thank you!!!

Related

How do I align the user input in the output code?

I am currently taking Web, Pgm & DB Foundation and I am learning python but I am struggling with this assignment.
In the original assignment, you were to create an expense calculator (code below):
print("This program calculates and displays travel expenses", '\n')
user_budget = int(input("Enter Budget:"))
user_destination = input("Enter your travel destination:")
user_fuel = int(input("How much do you think you will spend on gas?"))
user_lodging = int(input("Approximately, how much will you need for accommodation/hotel?"))
user_meals = int(input("Last, how much do you need for food?"))
print('\n')
print('----------Travel Expenses----------')
print('Location:', user_destination)
print('Initial Budget:', user_budget)
print('Fuel:', user_fuel)
print('Accommodation:', user_lodging)
print('Food:', user_meals)
print('___________________________________')
user_total = (user_budget-(user_fuel+user_lodging+user_meals))
print('Remaining Balance:', user_total)
For the next assignment, we are asked to make the output look like this:
expected output:
I was able to figure out how to add the $ next to the output, but this is my first time ever learning python so I am pulling my hair out trying to figure out how to align the output as shown in the image above.
I've updated the code to this:
print('----------Travel Expenses----------')
print('Location:', user_destination)
print('Initial Budget:', "${:.2f}".format(user_budget))
print('Fuel:', "${:.2f}".format(user_fuel))
print('Accommodation:', "${:.2f}".format(user_lodging))
print('Food:', "${:.2f}".format(user_meals))
print('____________________________________')
user_total = (user_budget-(user_fuel+user_lodging+user_meals))
print('Remaining Balance:',"${:.2f}".format(user_total))
But I am completely lost as to how to align the output to the right.
Any help is greatly appreciated and if you could break it down barney style, that would be awesome.

how to apply model developped in fast.ai / pytorch?

I've trained a model which i'm trying to apply onto new data. I'm totally new to fast.ai
i'm creating my databunch as below (ds being the data i want to score):
bs = 64
data_lm = (TextList.from_df(df, path, cols='comment_text')
.split_by_rand_pct(0.1)
.label_for_lm()
.databunch(bs=bs))
The problem being that I cannot ommit the .split_by_rand_pct(0.1), so I cannot score the whole data
I then go and load/apply the model as below
data_clas = load_data(path, 'data_clas.pkl', bs=bs)
learn = text_classifier_learner(data_clas, AWD_LSTM, drop_mult=0.5)
learn.load_encoder('fine_tuned_enc')
learn.load('third');
preds, target = learn.get_preds(DatasetType.Test, ordered=True)
labels = preds.numpy()
But the problem is i'm only scoring 0.1 pct of my data as the first piece of code when I create the databunch is not correct...i'm wanting to apply the saved/loaded model onto the overall DF.
Many thanks in advance
a colleague of mine actually provided me with the solution, I'm posting it here in case it's useful to anyone.
learn.data.add_test(df['Contact_Text'])
preds,y = learn.get_preds(ds_type=DatasetType.Test)
preds

How to get the interceipt from model summary in Python linearmodels?

I am running a panel reggression using Python linearmodels, something like:
import pandas as pd
from linearmodels.panel import PanelOLS
data = pd.read_csv('data.csv', sep=',')
data = data.set_index(['panel_id', 'date'])
controls = ['A','B','C']
controls['const'] = 1
model = PanelOLS(data.Y, controls, entity_effects= True)
result = model.fit(use_lsdv=True)
I really need to pull out the coefficient on the constant, but looks like this would not work
intercept = result.summary.const
Could not really find the answer in
linearmodels' documentation on github
More generally, does anyone know how to pull out the estimate coefficients from the linearmodels summary? Thank you!
result.params['const']
would give the intercept, in general result.params gives the series of regression coefficients in linearmodels

pyramid-arima auto_arima order selection

I am working on Time Series Forecasting(Daily entry) using pyramid-arima auto_arima in python where y is my target and x_features are all exogenous variables. I want best order model based on lowest aic, But auto_arima returns only few order combinations.
PFA where 1st code line (start_p = start_q = 0 & max_p = 0, max_q = 3) returns all 4 combinations, but 2nd code line(start_p = start_q = 0 & max_p = 3, max_q = 3) returns only 7 combinations , din't gave (0,1,2) and (0,1,3) and others, which leads wrong model selection based on aic. All other parameters are as default e.g max_order = 10
Is there anything I am missing or wrongly done?
Thankyou in advance.
You say error_action='ignore', so probably (0,1,2) and (0,1,3) (and other orders) gave errors, so they didn't appear in the results.
(I don't have enough reputation to write a comment, sorry).
The number of models autoarima trains is based on the data you feed in and also the stepwise= True if it is True autoarima uses a proven way to reduce number of iterations to find the best model and it is the best 90% cases unless data is very varying.
If you want the rest of models also to run as it isnt taking alot of time to execute try keeping stepwise=False where it trains with all possible param combinations.
Hope this helps

Getting an error while executing perplexity function to evaluate the LDA model

I am trying to evaluate the topic modeling(LDA). Getting a error while execting perplexity function as: Error in (function (classes, fdef, mtable) : unable to find an inherited method for function ‘perplexity’ for signature ‘"LDA_Gibbs", "numeric"’ someone please help to solve this.
As you haven't provided any example of your code, it's difficult to know what your exact issue is. However, I found this question when I was facing the same error so I will provide the problem I faced and solution here in the hope that it may help someone else.
In the topicmodels package, when fitting using Gibbs the perplexity() function requires newdata to be supplied in a document-term format. If you give it something else, you get this error. Going by your error message you were probably giving it something numeric instead of a dtm.
Here is a working example, using the newsgroups data from the lda package converted to the dtm format:
library(topicmodels)
# load the required data from lda package
data("newsgroup.train.documents", "newsgroup.test.documents", "newsgroup.vocab", package="lda")
# create document-term matrix using newsgroups training data
dtm <- ldaformat2dtm(documents = newsgroup.train.documents, vocab = newsgroup.vocab)
# fit LDA model using Gibbs sampler
fit <- LDA(x = dtm, k = 20, method="Gibbs")
# create document-term matrix using newsgroups test data
testdtm <- ldaformat2dtm(documents = newsgroup.test.documents, vocab = newsgroup.vocab)
# calculate perplexity
perplexity(fit, newdata = testdtm)

Resources