Commit e7c26a1d authored by Odair M.'s avatar Odair M.

analises course e metodo rates de Analysis com valor default para Nan

parent e2f79af8
This diff is collapsed.
# -*- coding: utf-8 -*-
#import pandas
import json
import numpy
import numpy as np
from script.utils.situations import Situation as sit
from collections import namedtuple
rate = namedtuple("rate", ["name", "collumn_name", "fields_x", "fields_X"])
......@@ -66,7 +64,9 @@ class Analysis(object):
for rate in rates:
x = self.count(groups, rate.collumn_name, rate.fields_x)
X = self.count(groups, rate.collumn_name, rate.fields_X)
rate_dict[rate.name] = [x/X, x, X]
rate_c = x/X
rate_c[np.isnan(rate_c)] = 0.0
rate_dict[rate.name] = [rate_c, x, X]
return rate_dict
# -*- coding: utf-8 -*-
#import pandas
import json
import numpy
from script.utils.situations import Situation as sit
from script.analysis.analysis import Analysis
from collections import namedtuple
from script.analysis.analysis import Analysis, rate, mean
class Course(Analysis):
"""
......@@ -63,6 +60,7 @@ class Course(Analysis):
list(sit.SITUATION_AFFECT_IRA),
"MEDIA_FINAL")
]
__semestral_rate = [__rates[1]]
def __init__(self, df):
df_filted = df[df['SITUACAO'].isin(sit.SITUATION_COURSED)]
......@@ -138,10 +136,10 @@ class Course(Analysis):
groups = self.__data["normal_general_groupby"]
rates = self.calc_rate(groups, self.__rates)
self.analysis["general_rates"] = rates
for rate in self.__rates:
rate_mean = self.analysis["general_rates"][rate.name][0].mean()
rate_std = self.analysis["general_rates"][rate.name][0].std()
self.analysis[rate.name] = [rate_mean, rate_std]
for rate_it in self.__rates:
rate_mean = self.analysis["general_rates"][rate_it.name][0].mean()
rate_std = self.analysis["general_rates"][rate_it.name][0].std()
self.analysis[rate_it.name] = [rate_mean, rate_std]
def semestral_rate(self):
"""
......@@ -264,12 +262,12 @@ class Course(Analysis):
# cria cache
cache = {}
for rate in self.__rates:
rate_calc = self.analysis["general_rates"][rate.name][0]
for rate_it in self.__rates:
rate_calc = self.analysis["general_rates"][rate_it.name][0]
for course in self.analysis["courses"].index:
if course not in cache:
cache[course] = {}
cache[course][rate.name] = rate_calc[course]
cache[course][rate_it.name] = rate_calc[course]
courses["cache"] = cache
# cria o campo compara_aprov
......@@ -285,6 +283,22 @@ class Course(Analysis):
Cria o dicionario para cada json de disciplina, ex 'CI055.json'.
"""
courses = []
aprovacao_d = {}
# semestral
for rate_it in self.__semestral_rate:
# pega uma lista no qual o primeiro elemento é a taxa, o segundo
# e o terceiro são quantidades
rate_data = self.analysis["semestral_rate"][rate_it.name]
for i in rate_data[0].index:
if i[0] not in aprovacao_d:
aprovacao_d[i[0]] = {}
periodo = str(i[1])+"/"+str(i[2])
aprovacao_d[i[0]][periodo] = [
float(rate_data[0][i]),
int(rate_data[1][i])
]
for course in self.analysis["courses"].index:
course_dict = {}
course_dict["disciplina_codigo"] = course
......@@ -294,15 +308,15 @@ class Course(Analysis):
course_dict["qtd_alunos"] = count
# taxas
for rate in self.__rates:
rate_data = self.analysis["general_rates"][rate.name]
course_dict[rate.name] = rate_data[0][course]
course_str = rate.name.replace("taxa", "qtd")
course_dict[course_str] = rate_data[1][course]
for rate_it in self.__rates:
rate_data = self.analysis["general_rates"][rate_it.name]
course_dict[rate_it.name] = float(rate_data[0][course])
course_str = rate_it.name.replace("taxa", "qtd")
course_dict[course_str] = float(rate_data[1][course])
course_dict["grafico_qtd_cursada_aprov"] = \
self.analysis["coursed_count"][course]
if(course == "CI055"):
print(course_dict)
# rate_calc = self.analysis["general_rates"][rate_it.name][0]
course_dict["aprovacao_semestral"] = aprovacao_d[course]
courses.append(course_dict)
return courses
......@@ -2,7 +2,6 @@
import time
from script.base.dataframe_base import load_dataframes
from script.build_cache import build_cache
from script.analysis.course_analysis import *
from datetime import timedelta
......@@ -10,10 +9,10 @@ from datetime import timedelta
def analyze(submission):
start_time = time.clock()
start_time_exec = time.time()
path = submission.path()
path = submission.path()
dataframe = load_dataframes(path)
build_cache(dataframe,path)
build_cache(dataframe, path)
submission.set_done(round(time.clock() - start_time))
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment