Como esse script python ficaria em java?
19/06/2018
0
Como esse script python ficaria em Java?
# Function: Probability Matrix
def city_probability (attractiveness, thau, city = 0, alpha = 1, beta = 2, city_list = []):
probability = pd.DataFrame(0, index = attractiveness.index, columns = [''''''''atraction'''''''',''''''''probability'''''''',''''''''cumulative_probability''''''''])
for i in range(0, probability.shape[0]):
if (i+1 not in city_list):
probability.iloc[i, 0] = (thau.iloc[i, city]**alpha)*(attractiveness.iloc[i, city]**beta)
for i in range(0, probability.shape[0]):
if (i+1 not in city_list and probability[''''''''atraction''''''''].sum() != 0):
probability.iloc[i, 1] = probability.iloc[i, 0]/probability[''''''''atraction''''''''].sum()
if (i == 0):
probability.iloc[i, 2] = probability.iloc[i, 1]
else:
probability.iloc[i, 2] = probability.iloc[i, 1] + probability.iloc[i - 1, 2]
if (len(city_list) > 0):
for i in range(0, len(city_list)):
probability.iloc[city_list[i]-1, 2] = 0.0
return probability
# Function: Probability Matrix
def city_probability (attractiveness, thau, city = 0, alpha = 1, beta = 2, city_list = []):
probability = pd.DataFrame(0, index = attractiveness.index, columns = [''''''''atraction'''''''',''''''''probability'''''''',''''''''cumulative_probability''''''''])
for i in range(0, probability.shape[0]):
if (i+1 not in city_list):
probability.iloc[i, 0] = (thau.iloc[i, city]**alpha)*(attractiveness.iloc[i, city]**beta)
for i in range(0, probability.shape[0]):
if (i+1 not in city_list and probability[''''''''atraction''''''''].sum() != 0):
probability.iloc[i, 1] = probability.iloc[i, 0]/probability[''''''''atraction''''''''].sum()
if (i == 0):
probability.iloc[i, 2] = probability.iloc[i, 1]
else:
probability.iloc[i, 2] = probability.iloc[i, 1] + probability.iloc[i - 1, 2]
if (len(city_list) > 0):
for i in range(0, len(city_list)):
probability.iloc[city_list[i]-1, 2] = 0.0
return probability
Fernando Jínior
Curtir tópico
+ 0
Responder
Clique aqui para fazer login e interagir na Comunidade :)