Thank you.
Sorry i was not aware that this is linked to the stack overflow.
- i didnt set any thing on the standalone julia process
- Here is my python and Julia code, please suggest me what is wrong here
import sys
import julia
import time
from itertools import combinations
start_time = time.time()
print("asdasdasda")
import csv
import pandas as pd
df = pd.read_csv('/home/hpcuser/test.csv')
schema = list(df.columns)
inputData = [schema]+df.values.tolist()
inputFormula = 'volume ~ 1 + logprice + col1 + col2 + col3 + price1 + price2 + price3 + price4 + ( ( 0 + logprice ) | employee ) + ( ( 0 + col1 ) | employee ) + ( ( 0 + col2 ) | employee ) + ( ( 0 + col3 ) | employee )'
#result = juliaCall(inputData, inputFormula, allRand=0,resid= 0)
def juliaCall(inputData, inputFormula, allRand=0,resid= 0):
j = julia.Julia()
# Create the final Julia code to be run
juliaCode = """
using DataFrames
using MixedModels
function calc_lmm(raw_data::Array)
addprocs(5)
dataset = convert(DataFrame, Dict(raw_data[1,:], [raw_data[2:end,i] for i in 1:size(raw_data,2)]))
id = convert(Array, dataset[:id])
delete!(dataset, :id)
modelREML = lmm({formula}, dataset)
reml!(modelREML,true)
lmeModel = fit(modelREML)
fixedDF = DataFrame(fixedEffVar = coeftable(lmeModel).rownms,estimate = coeftable(lmeModel).mat[:,1],
stdError = coeftable(lmeModel).mat[:,2],zVal = coeftable(lmeModel).mat[:,3])
if ({resid} == 1 || {allRand} == 1)
randomEffectTerms = map(string, filter(x -> contains(string(x), "("), lmeModel.mf.terms.terms))
byVar = strip(string(randomEffectTerms[1])[search(string(randomEffectTerms[1]), "|")[1] + 1:end])
byVarValues = unique(lmeModel.mf.df[symbol(byVar)])
randomDF = convert(DataFrame, ranef(lmeModel)[1])
rename!(randomDF, randomDF.colindex.names, map(x -> symbol(string(byVar,x)), byVarValues))
randomDF[:randomEffVar] = randomEffectTerms
randomDF = stack(randomDF, [1:length(randomDF)-1], :randomEffVar)
rename!(randomDF, [:variable, :value], [symbol(byVar), :estimate])
end
if {allRand} == 1
result = ["fixedEffEstimates" => convert(Array, fixedDF), "randomEffEstimates" => convert(Array, randomDF), "residuals" => hcat(id, lmeModel.resid)]
elseif {resid} == 1
result = ["fixedEffEstimates" => convert(Array, fixedDF), "randomEffEstimates" => convert(Array, randomDF), "residuals" => ""]
else
result = ["fixedEffEstimates" => convert(Array, fixedDF), "randomEffEstimates" => "", "residuals" => ""]
end
return result
end""".format(formula = inputFormula, allRand = allRand, resid = resid)
# Evaluate the code, note this is not running the code
calcLME = j.eval(juliaCode)
result = calcLME(inputData)
del inputData
return result
result = juliaCall(inputData, inputFormula, allRand=0,resid= 0)
print(result)