如何查看网站ftp地址用asp做的大型网站

当前位置: 首页 > news >正文

如何查看网站ftp地址,用asp做的大型网站,网站的图片怎么做,南京电商代运营定义了一套与时间特征相关的类和函数#xff0c;旨在从时间序列数据中提取有用的时间特征#xff0c;以支持各种时间序列分析和预测任务
from typing import Listimport numpy as np import pandas as pd from pandas.tseries import offsets from pandas.tseries.frequenc…定义了一套与时间特征相关的类和函数旨在从时间序列数据中提取有用的时间特征以支持各种时间序列分析和预测任务  from typing import Listimport numpy as np import pandas as pd from pandas.tseries import offsets from pandas.tseries.frequencies import to_offset 1 TimeFeature 类 这是一个基础类其他与时间特征相关的类都继承自它。它提供了一个基本框架但没有实现具体的功能。 class TimeFeature:def init(self):passdef call(self, index: pd.DatetimeIndex) - np.ndarray:passdef repr(self):return self.class.name () 2 时间特征类 SecondOfMinute、MinuteOfHour、HourOfDay、DayOfWeek、DayOfMonth、DayOfYear、MonthOfYear、WeekOfYear这些类都继承自TimeFeature每个类都实现了一个特定的时间特征提取方法。例如HourOfDay类提取一天中的小时数并进行规范化处理使得值在[-0.5, 0.5]之间。 class SecondOfMinute(TimeFeature):Minute of hour encoded as value between [-0.5, 0.5]def call(self, index: pd.DatetimeIndex) - np.ndarray:return index.second / 59.0 - 0.5class MinuteOfHour(TimeFeature):Minute of hour encoded as value between [-0.5, 0.5]def call(self, index: pd.DatetimeIndex) - np.ndarray:return index.minute / 59.0 - 0.5class HourOfDay(TimeFeature):Hour of day encoded as value between [-0.5, 0.5]def call(self, index: pd.DatetimeIndex) - np.ndarray:return index.hour / 23.0 - 0.5class DayOfWeek(TimeFeature):Hour of day encoded as value between [-0.5, 0.5]def call(self, index: pd.DatetimeIndex) - np.ndarray:return index.dayofweek / 6.0 - 0.5class DayOfMonth(TimeFeature):Day of month encoded as value between [-0.5, 0.5]def call(self, index: pd.DatetimeIndex) - np.ndarray:return (index.day - 1) / 30.0 - 0.5class DayOfYear(TimeFeature):Day of year encoded as value between [-0.5, 0.5]def call(self, index: pd.DatetimeIndex) - np.ndarray:return (index.dayofyear - 1) / 365.0 - 0.5class MonthOfYear(TimeFeature):Month of year encoded as value between [-0.5, 0.5]def call(self, index: pd.DatetimeIndex) - np.ndarray:return (index.month - 1) / 11.0 - 0.5class WeekOfYear(TimeFeature):Week of year encoded as value between [-0.5, 0.5]def call(self, index: pd.DatetimeIndex) - np.ndarray:return (index.week - 1) / 52.0 - 0.5 3 time_features_from_frwquency_str def time_features_from_frequency_str(freq_str: str) - List[TimeFeature]:根据给定的频率字符串如12H, 5min, 1D等返回一组适当的时间特征类实例features_by_offsets {offsets.YearEnd: [],offsets.QuarterEnd: [MonthOfYear],offsets.MonthEnd: [MonthOfYear],offsets.Week: [DayOfMonth, WeekOfYear],offsets.Day: [DayOfWeek, DayOfMonth, DayOfYear],offsets.BusinessDay: [DayOfWeek, DayOfMonth, DayOfYear],offsets.Hour: [HourOfDay, DayOfWeek, DayOfMonth, DayOfYear],offsets.Minute: [MinuteOfHour,HourOfDay,DayOfWeek,DayOfMonth,DayOfYear,],offsets.Second: [SecondOfMinute,MinuteOfHour,HourOfDay,DayOfWeek,DayOfMonth,DayOfYear,],}特征映射字典 features_by_offsets:这个字典将pandas的时间偏移类如YearEnd、QuarterEnd、MonthEnd等映射到对应的时间特征类列表。例如对于每月的数据MonthEnd它映射到MonthOfYear类对于每小时的数据Hour它映射到HourOfDay、DayOfWeek、DayOfMonth和DayOfYear类。offset to_offset(freq_str)#使用pandas的to_offset函数将频率字符串如12H转换为相应的pandas时间偏移对象。for offset_type, feature_classes in features_by_offsets.items():if isinstance(offset, offset_type):return [cls() for cls in feature_classes]遍历映射字典检查提供的偏移对象是否属于字典中的某个偏移类型。如果找到匹配为每个相关的特征类创建一个实例并将这些实例作为列表返回。supported_freq_msg fUnsupported frequency {freq_str}The following frequencies are supported:Y - yearlyalias: AM - monthlyW - weeklyD - dailyB - business daysH - hourlyT - minutelyalias: minS - secondlyraise RuntimeError(supported_freq_msg) 4 time_features 从日期数据中提取有用的时间特征def time_features(dates, timeenc0, freqh): time_features takes in a dates dataframe with a dates column and extracts the date down to freq where freq can be any of the following if timeenc is 0: * m - [month] * w - [month] * d - [month, day, weekday] * b - [month, day, weekday] * h - [month, day, weekday, hour] * t - [month, day, weekday, hour, *minute] If timeenc is 1, a similar, but different list of freq values are supported (all encoded between [-0.5 and 0.5]): * Q - [month] * M - [month] * W - [Day of month, week of year] * D - [Day of week, day of month, day of year] * B - [Day of week, day of month, day of year] * H - [Hour of day, day of week, day of month, day of year] * T - [Minute of hour*, hour of day, day of week, day of month, day of year] * S - [Second of minute, minute of hour, hour of day, day of week, day of month, day of year]*minute returns a number from 0-3 corresponding to the 15 minute period it falls into.if timeenc0:dates[month] dates.date.apply(lambda row:row.month,1)dates[day] dates.date.apply(lambda row:row.day,1)dates[weekday] dates.date.apply(lambda row:row.weekday(),1)dates[hour] dates.date.apply(lambda row:row.hour,1)dates[minute] dates.date.apply(lambda row:row.minute,1)dates[minute] dates.minute.map(lambda x:x//15)freq_map {y:[],m:[month],w:[month],d:[month,day,weekday],b:[month,day,weekday],h:[month,day,weekday,hour],t:[month,day,weekday,hour,minute],}return dates[freq_map[freq.lower()]].values此模式下函数直接从日期中提取特定的时间特征如月份、日期、星期几、小时和分钟。freq参数指定要提取的时间特征的精度。例如如果freq为d则提取月、日和星期几。对于分钟它被转换为一个从0到3的数字表示15分钟的时间段。if timeenc1:dates pd.to_datetime(dates.date.values)return np.vstack([feat(dates) for feat in time_features_from_frequency_str(freq)]).transpose(1,0)此模式下函数使用time_features_from_frequency_str函数来获取一组特征提取器并应用它们来转换时间数据。这些特征提取器提取的特征被编码在[-0.5, 0.5]的范围内以提供规范化的时间特征。 freq参数在这种情况下也指定了提取的时间特征的类型和精度。