t - table and degrees of freedom2019 Community Moderator ElectionCorrelation between time to event data and continuous dataCalculation and Visualization of Correlation Matrix with PandasHow to scrape a table from a webpage?Statistics - Train and test data splitSimple Q-Table Learning: Understanding Example CodeAre Hadoop and Python SciPy used for the same?Out of Memory Error when Selecting Data from Redshift TableOptimizing an averaged perceptron algorithm using numpy and scipy instead of dictionariesPandas: Assign back to table from grouping by column and indexError in Calculating the z Score for Normality Detection using numpy and scipy
Transcription Beats per minute
Is there a good way to store credentials outside of a password manager?
Personal Teleportation as a Weapon
What defines a dissertation?
Was Spock the First Vulcan in Starfleet?
What is the oldest known work of fiction?
Best way to store options for panels
Products and sum of cubes in Fibonacci
Is it okay / does it make sense for another player to join a running game of Munchkin?
What is difference between behavior and behaviour
Do I need a multiple entry visa for a trip UK -> Sweden -> UK?
Irreducibility of a simple polynomial
Can I Retrieve Email Addresses from BCC?
Coordinate position not precise
Using parameter substitution on a Bash array
Trouble understanding overseas colleagues
How can I get through very long and very dry, but also very useful technical documents when learning a new tool?
At which point does a character regain all their Hit Dice?
Valid Badminton Score?
What is the intuitive meaning of having a linear relationship between the logs of two variables?
Lay out the Carpet
How could Frankenstein get the parts for his _second_ creature?
Will it be accepted, if there is no ''Main Character" stereotype?
Student evaluations of teaching assistants
t - table and degrees of freedom
2019 Community Moderator ElectionCorrelation between time to event data and continuous dataCalculation and Visualization of Correlation Matrix with PandasHow to scrape a table from a webpage?Statistics - Train and test data splitSimple Q-Table Learning: Understanding Example CodeAre Hadoop and Python SciPy used for the same?Out of Memory Error when Selecting Data from Redshift TableOptimizing an averaged perceptron algorithm using numpy and scipy instead of dictionariesPandas: Assign back to table from grouping by column and indexError in Calculating the z Score for Normality Detection using numpy and scipy
$begingroup$
I am interested if someone can review this process and give me some tips. (I don't have any data science coworkers or friends to collaborate with...) When the script (.py file) below runs, it will output/print
:
The total savings are 9793 kWh + - 192 kWh
The total savings are 9793 kWh + - 2.0 %
Ultimately I am attempting calculate "precision" with my results (+ - 192 kWh AND + - 2.0 %
) ..
For starters, I cant find this info online so here's a snip from a book I am referencing on calculating data set standard error, then absolute precision, relative precision.
For retrieving my critical t value, I am following these steps from machinelearningmastery.com. This is where the scipy.stats import t
package is required.
I cant remember where degrees of freedom comes into play. The machinelearningmastery example, the author uses df = 10
So until I can figure out this, I left that as a default value in my code below. If someone wanted to copy and paste the code below it should run...
I cant remember from college where degrees of freedom comes into play and how to utilize it. The length of the data
when its converted into df2
Pandas dataframe is 31, which represents one months data 31 days. Any tips greatly appreciated..
import os
import numpy as np
import pandas as pd
import math
from scipy.stats import t
#actual electrical energy in kWh
actual = 40000
#calculated savings in kWh, output from Keras regression
data = [np.array([[1083.8748]], dtype='float32'), np.array([[998.98773]], dtype='float32'), np.array([[1137.0487]], dtype='float32'), np.array([[1077.2798]], dtype='float32'), np.array([[926.41284]], dtype='float32'),
np.array([[1030.7125]], dtype='float32'), np.array([[1028.0048]], dtype='float32'), np.array([[523.9799]], dtype='float32'), np.array([[1125.092]], dtype='float32'), np.array([[1119.7738]], dtype='float32'),
np.array([[918.6966]], dtype='float32'), np.array([[1112.5186]], dtype='float32'), np.array([[555.6942]], dtype='float32'), np.array([[1096.5643]], dtype='float32'), np.array([[826.35657]], dtype='float32'),
np.array([[1014.35406]], dtype='float32'), np.array([[1027.6962]], dtype='float32'), np.array([[924.20087]], dtype='float32'), np.array([[1035.217]], dtype='float32'), np.array([[1008.9658]], dtype='float32'),
np.array([[970.54047]], dtype='float32'), np.array([[847.0671]], dtype='float32'), np.array([[913.5519]], dtype='float32'), np.array([[1047.0747]], dtype='float32'), np.array([[920.0606]], dtype='float32'),
np.array([[994.2266]], dtype='float32'), np.array([[991.4501]], dtype='float32'), np.array([[972.43256]], dtype='float32'), np.array([[934.8802]], dtype='float32'), np.array([[912.04004]], dtype='float32'), np.array([[1131.297]], dtype='float32')]
#convert data to pandas series then DataFrame
df = pd.Series(data)
df2 = pd.DataFrame(df)
#define sum, standard deviation, mean of calculated savings data
total = df2.sum()
totalStd = np.std(df2.values)
totalMean = df2.mean()
#calculate saings
diff = int(actual - total)
#compute precision of results, starting with standard error
stdErr = totalStd / math.sqrt(len(total.index))
# define probability & degrees of freedom
p = 0.90
degf = 10
# retrieve t value <= probability
t = t.ppf(p, degf)
#calculate absolute precision
absPrec = t * stdErr
#calculate relative precision
relPrec = (100 * (absPrec / diff)).round(decimals=1)
#print results
absSavings = f'The total savings are int(diff) kWh + - int(absPrec) kWh'
print(absSavings)
relSavings = f'The total savings are int(diff) kWh + - float(relPrec) %'
print(relSavings)
python statistics scipy
$endgroup$
add a comment |
$begingroup$
I am interested if someone can review this process and give me some tips. (I don't have any data science coworkers or friends to collaborate with...) When the script (.py file) below runs, it will output/print
:
The total savings are 9793 kWh + - 192 kWh
The total savings are 9793 kWh + - 2.0 %
Ultimately I am attempting calculate "precision" with my results (+ - 192 kWh AND + - 2.0 %
) ..
For starters, I cant find this info online so here's a snip from a book I am referencing on calculating data set standard error, then absolute precision, relative precision.
For retrieving my critical t value, I am following these steps from machinelearningmastery.com. This is where the scipy.stats import t
package is required.
I cant remember where degrees of freedom comes into play. The machinelearningmastery example, the author uses df = 10
So until I can figure out this, I left that as a default value in my code below. If someone wanted to copy and paste the code below it should run...
I cant remember from college where degrees of freedom comes into play and how to utilize it. The length of the data
when its converted into df2
Pandas dataframe is 31, which represents one months data 31 days. Any tips greatly appreciated..
import os
import numpy as np
import pandas as pd
import math
from scipy.stats import t
#actual electrical energy in kWh
actual = 40000
#calculated savings in kWh, output from Keras regression
data = [np.array([[1083.8748]], dtype='float32'), np.array([[998.98773]], dtype='float32'), np.array([[1137.0487]], dtype='float32'), np.array([[1077.2798]], dtype='float32'), np.array([[926.41284]], dtype='float32'),
np.array([[1030.7125]], dtype='float32'), np.array([[1028.0048]], dtype='float32'), np.array([[523.9799]], dtype='float32'), np.array([[1125.092]], dtype='float32'), np.array([[1119.7738]], dtype='float32'),
np.array([[918.6966]], dtype='float32'), np.array([[1112.5186]], dtype='float32'), np.array([[555.6942]], dtype='float32'), np.array([[1096.5643]], dtype='float32'), np.array([[826.35657]], dtype='float32'),
np.array([[1014.35406]], dtype='float32'), np.array([[1027.6962]], dtype='float32'), np.array([[924.20087]], dtype='float32'), np.array([[1035.217]], dtype='float32'), np.array([[1008.9658]], dtype='float32'),
np.array([[970.54047]], dtype='float32'), np.array([[847.0671]], dtype='float32'), np.array([[913.5519]], dtype='float32'), np.array([[1047.0747]], dtype='float32'), np.array([[920.0606]], dtype='float32'),
np.array([[994.2266]], dtype='float32'), np.array([[991.4501]], dtype='float32'), np.array([[972.43256]], dtype='float32'), np.array([[934.8802]], dtype='float32'), np.array([[912.04004]], dtype='float32'), np.array([[1131.297]], dtype='float32')]
#convert data to pandas series then DataFrame
df = pd.Series(data)
df2 = pd.DataFrame(df)
#define sum, standard deviation, mean of calculated savings data
total = df2.sum()
totalStd = np.std(df2.values)
totalMean = df2.mean()
#calculate saings
diff = int(actual - total)
#compute precision of results, starting with standard error
stdErr = totalStd / math.sqrt(len(total.index))
# define probability & degrees of freedom
p = 0.90
degf = 10
# retrieve t value <= probability
t = t.ppf(p, degf)
#calculate absolute precision
absPrec = t * stdErr
#calculate relative precision
relPrec = (100 * (absPrec / diff)).round(decimals=1)
#print results
absSavings = f'The total savings are int(diff) kWh + - int(absPrec) kWh'
print(absSavings)
relSavings = f'The total savings are int(diff) kWh + - float(relPrec) %'
print(relSavings)
python statistics scipy
$endgroup$
add a comment |
$begingroup$
I am interested if someone can review this process and give me some tips. (I don't have any data science coworkers or friends to collaborate with...) When the script (.py file) below runs, it will output/print
:
The total savings are 9793 kWh + - 192 kWh
The total savings are 9793 kWh + - 2.0 %
Ultimately I am attempting calculate "precision" with my results (+ - 192 kWh AND + - 2.0 %
) ..
For starters, I cant find this info online so here's a snip from a book I am referencing on calculating data set standard error, then absolute precision, relative precision.
For retrieving my critical t value, I am following these steps from machinelearningmastery.com. This is where the scipy.stats import t
package is required.
I cant remember where degrees of freedom comes into play. The machinelearningmastery example, the author uses df = 10
So until I can figure out this, I left that as a default value in my code below. If someone wanted to copy and paste the code below it should run...
I cant remember from college where degrees of freedom comes into play and how to utilize it. The length of the data
when its converted into df2
Pandas dataframe is 31, which represents one months data 31 days. Any tips greatly appreciated..
import os
import numpy as np
import pandas as pd
import math
from scipy.stats import t
#actual electrical energy in kWh
actual = 40000
#calculated savings in kWh, output from Keras regression
data = [np.array([[1083.8748]], dtype='float32'), np.array([[998.98773]], dtype='float32'), np.array([[1137.0487]], dtype='float32'), np.array([[1077.2798]], dtype='float32'), np.array([[926.41284]], dtype='float32'),
np.array([[1030.7125]], dtype='float32'), np.array([[1028.0048]], dtype='float32'), np.array([[523.9799]], dtype='float32'), np.array([[1125.092]], dtype='float32'), np.array([[1119.7738]], dtype='float32'),
np.array([[918.6966]], dtype='float32'), np.array([[1112.5186]], dtype='float32'), np.array([[555.6942]], dtype='float32'), np.array([[1096.5643]], dtype='float32'), np.array([[826.35657]], dtype='float32'),
np.array([[1014.35406]], dtype='float32'), np.array([[1027.6962]], dtype='float32'), np.array([[924.20087]], dtype='float32'), np.array([[1035.217]], dtype='float32'), np.array([[1008.9658]], dtype='float32'),
np.array([[970.54047]], dtype='float32'), np.array([[847.0671]], dtype='float32'), np.array([[913.5519]], dtype='float32'), np.array([[1047.0747]], dtype='float32'), np.array([[920.0606]], dtype='float32'),
np.array([[994.2266]], dtype='float32'), np.array([[991.4501]], dtype='float32'), np.array([[972.43256]], dtype='float32'), np.array([[934.8802]], dtype='float32'), np.array([[912.04004]], dtype='float32'), np.array([[1131.297]], dtype='float32')]
#convert data to pandas series then DataFrame
df = pd.Series(data)
df2 = pd.DataFrame(df)
#define sum, standard deviation, mean of calculated savings data
total = df2.sum()
totalStd = np.std(df2.values)
totalMean = df2.mean()
#calculate saings
diff = int(actual - total)
#compute precision of results, starting with standard error
stdErr = totalStd / math.sqrt(len(total.index))
# define probability & degrees of freedom
p = 0.90
degf = 10
# retrieve t value <= probability
t = t.ppf(p, degf)
#calculate absolute precision
absPrec = t * stdErr
#calculate relative precision
relPrec = (100 * (absPrec / diff)).round(decimals=1)
#print results
absSavings = f'The total savings are int(diff) kWh + - int(absPrec) kWh'
print(absSavings)
relSavings = f'The total savings are int(diff) kWh + - float(relPrec) %'
print(relSavings)
python statistics scipy
$endgroup$
I am interested if someone can review this process and give me some tips. (I don't have any data science coworkers or friends to collaborate with...) When the script (.py file) below runs, it will output/print
:
The total savings are 9793 kWh + - 192 kWh
The total savings are 9793 kWh + - 2.0 %
Ultimately I am attempting calculate "precision" with my results (+ - 192 kWh AND + - 2.0 %
) ..
For starters, I cant find this info online so here's a snip from a book I am referencing on calculating data set standard error, then absolute precision, relative precision.
For retrieving my critical t value, I am following these steps from machinelearningmastery.com. This is where the scipy.stats import t
package is required.
I cant remember where degrees of freedom comes into play. The machinelearningmastery example, the author uses df = 10
So until I can figure out this, I left that as a default value in my code below. If someone wanted to copy and paste the code below it should run...
I cant remember from college where degrees of freedom comes into play and how to utilize it. The length of the data
when its converted into df2
Pandas dataframe is 31, which represents one months data 31 days. Any tips greatly appreciated..
import os
import numpy as np
import pandas as pd
import math
from scipy.stats import t
#actual electrical energy in kWh
actual = 40000
#calculated savings in kWh, output from Keras regression
data = [np.array([[1083.8748]], dtype='float32'), np.array([[998.98773]], dtype='float32'), np.array([[1137.0487]], dtype='float32'), np.array([[1077.2798]], dtype='float32'), np.array([[926.41284]], dtype='float32'),
np.array([[1030.7125]], dtype='float32'), np.array([[1028.0048]], dtype='float32'), np.array([[523.9799]], dtype='float32'), np.array([[1125.092]], dtype='float32'), np.array([[1119.7738]], dtype='float32'),
np.array([[918.6966]], dtype='float32'), np.array([[1112.5186]], dtype='float32'), np.array([[555.6942]], dtype='float32'), np.array([[1096.5643]], dtype='float32'), np.array([[826.35657]], dtype='float32'),
np.array([[1014.35406]], dtype='float32'), np.array([[1027.6962]], dtype='float32'), np.array([[924.20087]], dtype='float32'), np.array([[1035.217]], dtype='float32'), np.array([[1008.9658]], dtype='float32'),
np.array([[970.54047]], dtype='float32'), np.array([[847.0671]], dtype='float32'), np.array([[913.5519]], dtype='float32'), np.array([[1047.0747]], dtype='float32'), np.array([[920.0606]], dtype='float32'),
np.array([[994.2266]], dtype='float32'), np.array([[991.4501]], dtype='float32'), np.array([[972.43256]], dtype='float32'), np.array([[934.8802]], dtype='float32'), np.array([[912.04004]], dtype='float32'), np.array([[1131.297]], dtype='float32')]
#convert data to pandas series then DataFrame
df = pd.Series(data)
df2 = pd.DataFrame(df)
#define sum, standard deviation, mean of calculated savings data
total = df2.sum()
totalStd = np.std(df2.values)
totalMean = df2.mean()
#calculate saings
diff = int(actual - total)
#compute precision of results, starting with standard error
stdErr = totalStd / math.sqrt(len(total.index))
# define probability & degrees of freedom
p = 0.90
degf = 10
# retrieve t value <= probability
t = t.ppf(p, degf)
#calculate absolute precision
absPrec = t * stdErr
#calculate relative precision
relPrec = (100 * (absPrec / diff)).round(decimals=1)
#print results
absSavings = f'The total savings are int(diff) kWh + - int(absPrec) kWh'
print(absSavings)
relSavings = f'The total savings are int(diff) kWh + - float(relPrec) %'
print(relSavings)
python statistics scipy
python statistics scipy
asked Mar 21 at 14:24
HenryHubHenryHub
1617
1617
add a comment |
add a comment |
0
active
oldest
votes
Your Answer
StackExchange.ifUsing("editor", function ()
return StackExchange.using("mathjaxEditing", function ()
StackExchange.MarkdownEditor.creationCallbacks.add(function (editor, postfix)
StackExchange.mathjaxEditing.prepareWmdForMathJax(editor, postfix, [["$", "$"], ["\\(","\\)"]]);
);
);
, "mathjax-editing");
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "557"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fdatascience.stackexchange.com%2fquestions%2f47742%2ft-table-and-degrees-of-freedom%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
0
active
oldest
votes
0
active
oldest
votes
active
oldest
votes
active
oldest
votes
Thanks for contributing an answer to Data Science Stack Exchange!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
Use MathJax to format equations. MathJax reference.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fdatascience.stackexchange.com%2fquestions%2f47742%2ft-table-and-degrees-of-freedom%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown