Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- I am working on an school project that calculates an average of numbers and compares it to an actual number, for example:
- My data is:
- data = [0,1,2,3,4,5,6,7,8,9]
- And my function is:
- def test(number_of_heats, length):
- all_mean_errors = []
- all_means = []
- for heat in range(number_of_heats, len(heats_chem)-length, length):
- train_data = heats_chem[heat:heat+number_of_heats]
- test_data = heats_chem[heat + number_of_heats : heat + number_of_heats + length]
- prediction_mean = mean(train_data)
- all_means.append(prediction_mean)
- mean_error = get_error(prediction_mean, test_data)
- all_mean_errors.append(mean_error)
- With number_of_heats being how many elements to calculate a prediction and length being how many of next elements I am trying to predict. Now I am trying to make a function which does this, but also I am able to use more "windows" of elements to make a more accurate prediction, so I am going to use another parameter called window
- def test(number_of_heats, length, windows)
- Now for example with parameters `2,1,3`, it should do `0,1,2,3,4,5` calculate mean, check `2,3,4,5` caluclate mean, check `4,5` and calculate mean, than switch to next one and do `2,3,4,5,6,7` mean, `4,5,6,7` mean etc. but for the life of me I am having the hardest time trying to fit it inside another for loop to be able to do this. Could anyone help me please?
Advertisement
Add Comment
Please, Sign In to add comment