How to print the classification report, I want to know the f1 score for each label - report

I want to modify that code to print the f1 score for each label
Can anyone give a hint what to add to this colab code?
https://colab.research.google.com/drive/1M0ls7EPUi1dwqIDh6HNfJ5y826XvcgGX?usp=sharing

Related

Stata tables/collect confidence interval in one cell

I work a lot with the new tables collect command in stata 17. Does anybody know how to get the confidence interval in one cell in the table vs. One column for lower bound and one column for the upper bound estimate?
Alternatively a quick fix in word (or excel though my final document is word. Saving the output in excel takes so long)
Is I see it there is no option to put it in one column, so maybe a layout work around?
From the stata documentation of the collect command, the quick start mentions
table (colname) (result), command(_r_b _r_ci: regress y x1 x2 x3). You should be able to use collect with it, but without a minimum reproducible example of your specific case, it is hard to verify if this works as intended in your case. For the general idea of a minimum reproducible example please see here and for specific advice on how to create a minimum reproducible example please see here.
Here is a general example that uses table, collect and putdocx to create a word document to get the confidence interval in one cell:
use https://www.stata-press.com/data/r17/nlsw88.dta
table (colname) (result), command(_r_b _r_ci: regress wage union occupation married age)
collect layout (colname) (result)
putdocx begin
putdocx collect
putdocx save Table, replace

How to add a sum to a formula field in FastReports

I am trying to add a sum for a formula field, but it is not working. It works if I create a sum for a normal field, but not with a formula.
Can someone please help me with this ?
Thanks.

How to calculate average annual salary in libreoffice calc

I have salary data table from 10 years period. Every column has properly set data type (date for "B", number for "C" and "E".
I'm trying to write a formula to calculate average salary for every year. In column "E" I've manually entered all possible years and in column "F" should be an yearly average, according to year from "E".
So, my best try is this formula: =AVERAGEIF(YEAR(B2:B133);"="&E2;C2:C133)
Trying so calculate an average from column C, where year in date from column B equals a year in column E
But all I get is an error Err:504. Figured out, that problem is in YEAR(interval) part, but can't get what exactly...
Can someone point that out?
Thank you!
There are actually many possibilities to solve this.
#JvdV answer;
using an array formula with #JvdV solution;
using an array formula with a combination of AVERAGE() and IF();
using the SUMPRODUCT() function;
and surely many other solutions that I don't know about!
Please beware: I use , instead of ; as formula separator, according to my locale; adapt to your needs.
A side note on "array formulas"
This kind of formulas are applied by mandatory pressing the Ctrl + Shift + Enter key combination to insert them, not only Enter or Tab or mouse-clicking elsewhere on the sheet.
The resulting formula is shown between brackets {}, which are not inserted by the user but are automatically shown by the software to inform that this is actually an array formula.
More on array formulas i.e. on the LibreOffice help system.
Usually you cannot drag and drop array formulas, you have to copy-paste them instead.
Array formula with #JvdV solution
The solution of JvdV could be slighly modified like this, and then inserted as an array formula:
=AVERAGEIFS(C$2:C$133,YEAR($B$2:$B$133),"="&E2)
When you insert this formula with the Ctrl + Shift + Enter key combination, the software puts the formula into brackets, so that you see it like this: {=AVERAGEIFS(C$2:C$133,YEAR($B$2:$B$133),"="&E2)}
You cannot simply drag the formula down, but you can copy-paste it.
Array formula with a combination of AVERAGE() and IF():
For your example, put this formula in cell F2 (for the year 2010):
=AVERAGE(IF(YEAR($B$2:$B$133)=E2,$C$2:$C$133))
When you insert this formula with the Ctrl + Shift + Enter key combination, the software puts the formula into brackets, so that you see it like this {=AVERAGE(IF(YEAR($B$2:$B$133)=E2,$C$2:$C$133))}
You cannot simply drag the formula down, but you can copy-paste it.
SUMPRODUCT() formula:
My loved one...
Plenty of resources on the web to explain this formula.
In your situation, this would give:
=SUMPRODUCT($C$2:$C$133,--(YEAR($B$2:$B$133)=E2))/SUMPRODUCT(--(YEAR($B$2:$B$133)=E2))
This one you can drag down to your needs.
Unfortunately AVERAGEIF() expects a range reference instead of a calculated array. Therefor it will error out. That's the theory at least for Excel, and I expect this to be the same for LibreCalc.
One way around it is using the AVERAGEIFS() function and check against first and last days of the year, for example:
=AVERAGEIFS(C$2:C$133;B$2:B$133;">="&DATE(E2;1;1);B$2:B$133;"<="&DATE(E2;12;31))
Drag the formula down.

Inline results (tests, descriptives etc) with RMarkdown

I posted this question a couple of minutes ago and it got instant minuses so I figured that it was stupid and deleted it.
After reconsideration I still can think of a solution.
This might be due I'm new to R, coding in general, and all those things that are not point and click analysis in SPSS followed by MS Word description of results.
So please forgive me if the answer is basic - I clearly lack intelligence or can't find proper wording for a successful search.
I'm looking for a way to automatically (in order to reduce chance of mistyping errors) pass test results into text (within rmarkdown written in rstudio).
I'm wondering if it's possible to include results from R functions within plain text? If yes, is it matter of markdown formatting or do I need some additional R packages?
For example if I want to describe results of a simple anova
set.seed(111)
y = rnorm(18, 0, 1)
x = rnorm(18, 1, 1)
a = c(1,2,3,1,2,3,1,2,3,1,2,3,1,2,3,1,2,3)
df<- data.frame(a, x, y)
anova<- aov(x~a)
summary(anova)
Df Sum Sq Mean Sq F value Pr(>F)
a 1 0.39 0.3882 0.178 0.678
Residuals 16 34.84 2.1775
Instead of writing by hand:
"We conducted a one way anova that showed no effect of a over x (F(1;16)=0.93; p=0.347 (ns)
I'd like to go with (or anything similar):
"We conducted a one way anova that showed no effect of a over x code pasting results in proper format"
I know I can use `r followed by a function to inline simple results, but it's still not clear if this would work for formatted tests and if so, how.
The more general the solution the better - as I'm describing mostly linear models, mixed linear models and lot's of descriptive statistics.
Once again, sorry if it's too basic and not worth answering - I can delete it again if anyone comments so.
Regards
You have to extract the different statistics yourself and combine them. For the anova example you show above, something like this should get you started:
F(`r summary(anova)[[1]][1, "Df"]`; `r summary(anova)[[1]][2,
"Df"]`)=`r format(summary(anova)[[1]][1, "F value"], digits = 2,
nsmall = 2)`;
In order to extract the statistics, you should have a look at the help files. Often they contain detailed descriptions of the return value. Alternatively you can just have a look at the names of your results. In your example that is names((anova)) and names(summary(anova)[[1]]).
While method posted by #shadow would work for any result, for the purpose of my research a much simpler and quicker way is by using apa package developed by #dgromer at https://github.com/dgromer/apa
For the example given in my original question, posting an inline result from one way anova
anova<- aov(x~a)
requires only one line of code
devtools::install_github("dgromer/apa")
anova_apa(anova, a) # where "a" is effect name
and produces an inline text as this: F(1, 16) = 0.18, p = .678, petasq = .01

R editor that looks similar to Mathematica

Is there an R editor that looks similar to Mathematica?
In Mathematica, we have cells, where we can write our code. We can then run that code, and the output shows in another cell below. The cells are independent, and in a way I can run all the functions I want independently, and if the output is too much, I just double click on the right side, and the output cell hides all info, but the first line. Also, there's this pretty colour matching so that we do not forget to which '(' matches ')' and so on.
Any help would be appreciated.

Resources