Object of type 'closure' is not subsettable topic modeling - error-handling

I am attempting some data analysis via topic modeling. I have followed the guide posted here: https://bookdown.org/joone/ComputationalMethods/topicmodeling.html
The code works fine until the last step. Here is my code snippet for your reference:
LePen_top <- tibble(topic = terms$topicnums, prob = apply(terms$prob, 1, paste, collapse = ", "),
frex = apply(terms$frex, 1, paste, collapse = ", "))
When I run it, the following message pops up: Error in terms$topicnums : object of type 'closure' is not subsettable
I have looked around the forums, but I have not been able to solve it due to my inexperience. I would greatly appreciate your help, and if you could explain what have I done wrong.
Best regards,
MRizak

Related

Some clarification around sql verbage within R, specifically with dbListFields

I'm using R to connect to an Oracle Database. I'm able to do so with this code:
library(rJava)
library(RJDBC)
jdbcDriver <- JDBC(driverClass="oracle.jdbc.driver.OracleDriver", classPath="jar files/ojdbc8.jar")
jdbcConnection <- dbConnect(jdbcDriver, "jdbc:oracle:thin:#(DESCRIPTION=(ADDRESS=(PROTOCOL=tcps)(HOST=blablablablabla.com)(PORT=1234))(CONNECT_DATA=(SERVICE_NAME=pdblhs)))", "myusername", "mypassword")
DataFrame <- dbGetQuery(jdbcConnection, "select protocol_id, disease_site_code, disease_site
From abc_place_prod.Rv_sip_PCL_disease_site
order by protocol_id")
# Close connection
dbDisconnect(jdbcConnection)
This snippet of code works. It downloads the data I want into a neat data frame and works as planned.
But I'm trying to learn how to navigate with R/SQL more and I wanted to use dbListFields to explore all the possible column names in that table I'm pulling from. Per the documentation here, you could type something like this:
dbListFields(con, "mtcars")
and it would work. So I tried:
dbListFields(jdbcConnection, "abc_place_prod.Rv_sip_PCL_disease_site")
and it returned this error:
Error in dbSendQuery(conn, paste("SELECT * FROM ", dbQuoteIdentifier(conn, :
Unable to retrieve JDBC result set
JDBC ERROR: ORA-00933: SQL command not properly ended
It seems like someone else experienced something similar here and I'm not sure it ever got answered. I've tried it with a semicolon at the end (that "ended" something else properly for me, and its mentioned in the comments of this question) and no luck.

How to index correctly using Python 3.7 and address associated errors

I have been having issues indexing in Python 3.7. I would greatly appreciate your insights and clarification on this.
I have tried to research and fix this issue but I am not able to understand what I am doing. I would greatly appreciate your help
enroll = pd.read_csv('enrollment_forecast.csv')
enroll.columns = ['year','roll','unem','hgrad','inc']
# the correlation between variables
enroll.corr()
enroll_data = enroll.ix[:(2,3)].values
print(enroll_data)
enroll_target = enroll.ix[:,1].values
print(enroll_target)
enroll_data_names = ['unem','hgrad']
Exception has occurred: AssertionError
End slice bound is non-scalar
Just a heads up, Pandas .ix index accessor is deprecated.
It's throwing the error error because you are passing it a tuple:
enroll_data = enroll.ix[:(2,3)].values
Try passing it a list instead of a tuple:
enroll_data = enroll.ix[:[2,3]].values

Google -Bigquery Error " Not found: Dataset prime-poc:churn was not found in location US"

While predicting the Customer churn for Kaggle dataset using Google's Big query. I am hitting "Not found: Dataset prime-poc:churn was not found in location US".
This is depie the fact that churn_table is loaded in US location. Please let me know how to overcome this issue. My verification efforts are stalled due to this issue. Any quick help will be greatly appreciate.
Big query command used :
FROM
ccpchurndataset.Churn_table
NOTE : both ccpchurndataset and Churn_table are in US location only.
Specify fully qualified name ProjectId.DatasetId.TableId enclosed in () tick sign.

Using Jython to extract business data from the WebSphere Failed Event Manager

I normally work with shellscript, but I'm dabbling in Jython for my current client. I need to extract and display business data from a failed event in WebSphere, and I can't figure out how to do it.
The code I have so far is
green='\033[0;32m'
cyan='\033[0;36m'
clear='\033[0m'
##########################################################################
import time
today=time.asctime().split(' ')
objstr = AdminControl.completeObjectName('WebSphere:*,type=FailedEventManager')
obj = AdminControl.makeObjectName(objstr)
fecount = AdminControl.invoke(objstr,"getFailedEventCount")
msglist = AdminControl.invoke_jmx(obj,'getAllFailedEvents',[0],['int'])
i=0
for fe in msglist:
i+=1
ftd=str(fe.getFailureDateTime()).split(' ')
if ftd[1]==today[1] and ftd[2]==today[2] and ftd[5]==today[4]:
col=green
else:
col=cyan
fstr="%4d: %-46s "+col+"%s"+clear
print fstr % (i, fe.getMsgId(), fe.getFailureDateTime() )
Which displays the message ID and the timestamp of the event. But I've looked around the net, and can't figure out how to get from what I've got to actually extracting specific parameters from the business data for each failed event.
I'd appreciate if somebody with greater knowledge of Jython than I have could point me in the right direction.
Thanks
Douglas
Not sure if you got your answer.
Posting what I know to help who is looking for:
You can use getFailedEventParameters to get business data of failed events.
scaDetail = AdminControl.invoke_jmx(obj,'getEventDetailForSCA',[event], ['com.ibm.wbiserver.manualrecovery.FailedEvent'])
eventDetailParameter = scaDetail.getFailedEventParameters()
for failedParameter in eventDetailParameter:
print failedParameter.getName()
print failedParameter.getType()
print failedParameter.getValue()

Dymola Results of checkModel()

checkmodel([Some Model]) opens the GUI "Dymola Messages", tab "Translation" and displays Errors, Warnings, and Messages.
Does anyone know how to write these infos to a logfile or get them as kind of return value of checkModel(). All I've found in the documentation was, that checkModel() only returns a success-boolean. Are these infos saved temporarily somewhere?
Note, that I only want to apply checkModel() but not actually translating the code.
I finally found a solution at least for Dymola 2016 and newer, so if someone is interested - here it is (it is not very user-friendly, but it works):
The key-command is getLastError() which not only returns the last error (as one could think...), but all errors that are detected by checkModel() as well as the overall statistics.
All informations are sampled in one string, in which the last lines looks like:
"[...]
Local classes checked, checking <[Some Path]>
ERROR: 2 errors were found
WARNING: 13 warnings were issued
= false
"
Following operations will return the number of actual errors (for warnings it is more or less the same):
b = checkmodel([Some Model])
s = getLastError()
ind1 = Modelica.Utilities.Strings.findLast(s,"ERROR:")
ind2 = Modelica.Utilities.Strings.findLast(s," errors were found")
nErrors = Modelica.Utilities.Strings.substring(s,ind1+6,ind2) //6 = len(ERROR:)
nErrors = Modelica.Utilities.Strings.replace(nErrors," ","")
nErrors
= "2"
Note:
I used findLast as I know, that the lines of interest are at the very end of the string. So this is significantly faster than using find
This only works, if the line "ERROR: ...." actually exists. Otherwise, the substring call will throw an error.
Of course this could be done in less lines, but maybe this version is easier to read.
NOTE: This will only works with Dymola 2016 and newer. The return-string of getLastError is of a different structure in Dymola 2015 and older.
The following should handle it:
clearlog(); // To start fresh
Advanced.TranslationInCommandLog=true;
checkModel(...);
savelog(...);
This is mentioned in the Dymola User Manual Volume 1, section "Parameter studies by running Dymola a number of time in “batch mode”" on pg 630 or so.