本文整理汇总了Python中orangecontrib.timeseries.Timeseries.from_numpy方法的典型用法代码示例。如果您正苦于以下问题:Python Timeseries.from_numpy方法的具体用法?Python Timeseries.from_numpy怎么用?Python Timeseries.from_numpy使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类orangecontrib.timeseries.Timeseries
的用法示例。
在下文中一共展示了Timeseries.from_numpy方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: _as_table
# 需要导入模块: from orangecontrib.timeseries import Timeseries [as 别名]
# 或者: from orangecontrib.timeseries.Timeseries import from_numpy [as 别名]
def _as_table(self, values, what):
"""Used for residuals() and fittedvalues() methods."""
from Orange.data import Domain, ContinuousVariable
attrs = []
n_vars = values.shape[1] if values.ndim == 2 else 1
if n_vars == 1:
values = np.atleast_2d(values).T
tvar = None
# If 1d, time var likely not already present, so lets add it if possible
if n_vars == 1 and self._table_timevar:
values = np.column_stack((self._table_timevals[-values.shape[0]:],
values))
tvar = self._table_timevar
attrs.append(tvar)
for i, name in zip(range(n_vars),
self._table_var_names or range(n_vars)):
attrs.append(ContinuousVariable('{} ({})'.format(name, what)))
# Make the fitted time variable time variable
if self._table_timevar and self._table_timevar.name == name:
tvar = attrs[-1]
table = Timeseries.from_numpy(Domain(attrs), values)
table.time_variable = tvar
table.name = (self._table_name or '') + '({} {})'.format(self, what)
return table
示例2: _predict_as_table
# 需要导入模块: from orangecontrib.timeseries import Timeseries [as 别名]
# 或者: from orangecontrib.timeseries.Timeseries import from_numpy [as 别名]
def _predict_as_table(self, prediction, confidence):
from Orange.data import Domain, ContinuousVariable
means, lows, highs = [], [], []
n_vars = prediction.shape[2] if len(prediction.shape) > 2 else 1
for i, name in zip(range(n_vars),
self._table_var_names or range(n_vars)):
mean = ContinuousVariable('{} (forecast)'.format(name))
low = ContinuousVariable('{} ({:d}%CI low)'.format(name, confidence))
high = ContinuousVariable('{} ({:d}%CI high)'.format(name, confidence))
low.ci_percent = high.ci_percent = confidence
mean.ci_attrs = (low, high)
means.append(mean)
lows.append(low)
highs.append(high)
domain = Domain(means + lows + highs)
X = np.column_stack(prediction)
table = Timeseries.from_numpy(domain, X)
table.name = (self._table_name or '') + '({} forecast)'.format(self)
return table
示例3: exogenous
# 需要导入模块: from orangecontrib.timeseries import Timeseries [as 别名]
# 或者: from orangecontrib.timeseries.Timeseries import from_numpy [as 别名]
gui.checkBox(box, self, 'use_exog',
'Use exogenous (independent) variables (ARMAX)',
callback=self.apply)
def forecast(self, model):
if self.use_exog and self.exog_data is None:
return
return model.predict(self.forecast_steps,
exog=self.exog_data,
alpha=1 - self.forecast_confint / 100,
as_table=True)
def create_learner(self):
return ARIMA((self.p, self.d, self.q), self.use_exog)
if __name__ == "__main__":
from AnyQt.QtWidgets import QApplication
from Orange.data import Domain
a = QApplication([])
ow = OWARIMAModel()
data = Timeseries('airpassengers')
domain = Domain(data.domain.attributes[:-1], data.domain.attributes[-1])
data = Timeseries.from_numpy(domain, data.X[:, :-1], data.X[:, -1])
ow.set_data(data)
ow.show()
a.exec()