Commit e86966aa by Vik Paruchuri

Abstract out grader model files from ml repo.

parent f48373e3
......@@ -17,7 +17,8 @@ from statsd import statsd
@statsd.timed('open_ended_assessment.machine_learning.creator.time')
def create(text,score,prompt_string,model_path):
results = {'errors': [],'success' : False, 'cv_kappa' : 0, 'cv_mean_absolute_error': 0}
results = {'errors': [],'success' : False, 'cv_kappa' : 0, 'cv_mean_absolute_error': 0,
'feature_ext' : "", 'classifier' : ""}
try:
e_set = model_creator.create_essay_set(text, score, prompt_string)
except:
......@@ -28,15 +29,11 @@ def create(text,score,prompt_string,model_path):
feature_ext, classifier, cv_error_results = model_creator.extract_features_and_generate_model(e_set)
results['cv_kappa']=cv_error_results['kappa']
results['cv_mean_absolute_error']=cv_error_results['mae']
except:
msg = "feature extraction and model creation failed."
results['errors'].append(msg)
log.exception(msg)
try:
model_creator.dump_model_to_file(prompt_string, feature_ext, classifier, text, score, model_path)
results['feature_ext']=feature_ext
results['classifier']=classifier
results['success']=True
except:
msg = "could not write model to: {0}".format(model_path)
msg = "feature extraction and model creation failed."
results['errors'].append(msg)
log.exception(msg)
......
......@@ -27,7 +27,7 @@ log = logging.getLogger(__name__)
TEMPORARY_WANTS_CONFIG=True
@statsd.timed('open_ended_assessment.machine_learning.grader.time')
def grade(grader_path,grader_config,submission,sandbox=None):
def grade(grader_data,grader_config,submission,sandbox=None):
results = {'errors': [],'tests': [],'score': 0, 'feedback' : "", 'success' : False, 'confidence' : 0}
......@@ -35,11 +35,6 @@ def grade(grader_path,grader_config,submission,sandbox=None):
#Try to find and load the model file
try:
grader_data=pickle.load(file(grader_path,"r"))
except:
results['errors'].append("Could not find a valid model file.")
has_error=True
grader_set=EssaySet(type="test")
#Try to add essays to essay set object
......
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