def test_feedback_graph_too_long(): x, y = get_feedback1() start_time = datetime.now() hr = SpaceRepetitionReference(epoch=start_time) hf = SpaceRepetitionFeedback(x, y, epoch=start_time) hdl, _ = hf.plot_graph(stop=50) # it should automatically fit the data hr.save_figure("results/space_feedback_too_long.pdf") hdl.close()
def test_feedback_graph_too_short(): x, y = get_feedback1() start_time = datetime.now() hr = SpaceRepetitionReference(epoch=start_time) hf = SpaceRepetitionFeedback(x, y, epoch=start_time) hdl, _ = hf.plot_graph(stop=4) hr.save_figure("results/space_feedback_too_short.pdf") hdl.close()
def test_control_predition_for_feature(): start_time = datetime.now() x, y = get_feedback1() hr = SpaceRepetitionReference(epoch=start_time) hf = SpaceRepetitionFeedback(x[0:4], y, epoch=start_time) hctrl = SpaceRepetitionController(epoch=start_time, reference=hr, feedback=hf) graph_handle, data_dict = hctrl.plot_graphs(stop=30) training_moments_1 = hctrl.range_for(stop=30, curve=1, day_step_size=0.1) results_1 = [ hctrl.recollect_scalar(training_moment, curve=1) for training_moment in training_moments_1 ] training_moments_2 = hctrl.range_for(stop=30, curve=2, day_step_size=0.1) results_2 = [ hctrl.recollect_scalar(training_moment, curve=2) for training_moment in training_moments_2 ] training_moments_3 = hr.range_for(stop=30, curve=3, day_step_size=0.1) results_3 = [ hctrl.recollect_scalar(training_moment, curve=3) for training_moment in training_moments_3 ] ctrl_plot = graph_handle.axarr[-1] ctrl_plot.plot(training_moments_1, results_1, color='xkcd:azure') ctrl_plot.plot(training_moments_2, results_2, color='xkcd:darkgreen') ctrl_plot.plot(training_moments_3, results_3, color='xkcd:maroon') hr.save_figure("results/space_ctrl_predictions.pdf") graph_handle.close()
def test_control_graph_too_short(): start_time = datetime.now() x, y = get_feedback1() stop_date = 5 hr = SpaceRepetitionReference(epoch=start_time) hf = SpaceRepetitionFeedback(x[0:2], y, epoch=start_time) hctrl = SpaceRepetitionController(reference=hr, feedback=hf, epoch=start_time) graph_handle, data_dict = hctrl.plot_graphs(stop=stop_date) hctrl.save_figure("results/spaced_control_too_short.pdf") graph_handle.close()
def test_generator_controller(): start_time = datetime.now() x, y = get_feedback1() hr = SpaceRepetitionReference(epoch=start_time) hf = SpaceRepetitionFeedback(x[0:4], y, epoch=start_time) hctrl = SpaceRepetitionController(reference=hr, feedback=hf, epoch=start_time) hdl, _ = hctrl.plot_graphs(stop=43) hctrl.save_figure("results/space_control.pdf") hdl.close()
def test_control_predition_range_for_feature(): start_time = datetime.now() x, y = get_feedback1() hr = SpaceRepetitionReference(epoch=start_time) hf = SpaceRepetitionFeedback(x[0:4], y, epoch=start_time) hctrl = SpaceRepetitionController(epoch=start_time, reference=hr, feedback=hf) training_moments = hctrl.range_for(stop=30, curve=1, day_step_size=0.1) assert training_moments[0] == hctrl.days_offset_from_epoch_to_datetime( hctrl.dates_as_day_offsets[0]) training_moments = hctrl.range_for(stop=30, curve=2, day_step_size=0.1) assert training_moments[0] == hctrl.days_offset_from_epoch_to_datetime( hctrl.dates_as_day_offsets[1])
def test_a_control_series(): start_time = datetime.now() x, y = get_feedback1() stop_date = 2 * x[-1] * 0.5 hr = SpaceRepetitionReference(epoch=start_time) hf = SpaceRepetitionFeedback(x[0:2], y, epoch=start_time) hctrl = SpaceRepetitionController(reference=hr, feedback=hf, epoch=start_time) graph_handle, data_dict = hctrl.plot_graphs(stop=stop_date) hctrl.save_figure("results/spaced_0.pdf") graph_handle.close() #hr = SpaceRepetitionReference(plot=False, range=range_, epoch=start_time) hf = SpaceRepetitionFeedback(x[0:3], y, epoch=start_time) hctrl.initialize_feedback(feedback=hf) graph_handle, _ = hctrl.plot_graphs(stop=stop_date) hctrl.save_figure("results/spaced_1.pdf") graph_handle.close() #hr = SpaceRepetitionReference(plot=False,range=range_,epoch=start_time) hf = SpaceRepetitionFeedback(x[0:4], y, epoch=start_time) hctrl.initialize_feedback(feedback=hf) graph_handle, _ = hctrl.plot_graphs(stop=stop_date) hctrl.save_figure("results/spaced_2.pdf") graph_handle.close() #hr = SpaceRepetitionReference(plot=False,range=range_,epoch=start_time) hf = SpaceRepetitionFeedback(x[0:5], y, epoch=start_time) hctrl.initialize_feedback(feedback=hf) graph_handle, _ = hctrl.plot_graphs(stop=stop_date) data_dict.clear() hctrl.save_figure("results/spaced_3.pdf") graph_handle.close() #hr = SpaceRepetitionReference(plot=False,range=range_,epoch=start_time) hf = SpaceRepetitionFeedback(x[0:6], y, epoch=start_time) hctrl.initialize_feedback(feedback=hf) graph_handle, _ = hctrl.plot_graphs(stop=stop_date) data_dict.clear() hctrl.save_figure("results/spaced_4.pdf") graph_handle.close() #hr = SpaceRepetitionReference(plot=False,range=range_,epoch=start_time) hf = SpaceRepetitionFeedback(x[0:7], y, epoch=start_time) hctrl.initialize_feedback(feedback=hf) graph_handle, _ = hctrl.plot_graphs(stop=stop_date) data_dict.clear() hctrl.save_figure("results/spaced_5.pdf") graph_handle.close() #hr = SpaceRepetitionReference(plot=False,range=range_,epoch=start_time) hf = SpaceRepetitionFeedback(x[0:8], y, epoch=start_time) hctrl.initialize_feedback(feedback=hf) graph_handle, _ = hctrl.plot_graphs(stop=stop_date) graph_handle.epoch # the epoch graph_handle.axarr # array of matplotlib axes mapping the subplots graph_handle.figure # the matplotlib figure graph_handle.axarr[-1] # the control plot data_dict.clear() hctrl.save_figure("results/spaced_6.pdf") graph_handle.close()