Beispiel #1
0
def read_data():
    import models
    df = pd.read_csv('udemy_data.csv')
    for index, _df in df.iterrows():
        #     date型への変更
        date = datetime.datetime.strptime(_df['date'], '%Y/%m/%d').date()
        row = models.Data(date=date,
                          subscribers=_df['subscribers'],
                          reviews=_df['reviews'])
        db_session.add(row)
    db_session.commit()
Beispiel #2
0
def getDataInOrange():
    data = json.loads(request.data.decode('utf-8'))
    if len(data) > 0:
        device_id = data['device_id']
        print(data)
        for sensor in data["sensors"]:
            print(sensor)
            sensor_data = models.Data()
            sensor_data.device_id = device_id
            sensor_data.sensor_id = sensor['id']
            sensor_data.data = sensor['data']
            sensor_data.save()
        return jsonify({'message': 'data send', 'code': 200})
    return jsonify({'message': 'dont send data', 'code': 500})
Beispiel #3
0
import models

LSTM256 = models.LSTM(256, 3)
LSTM256.create_model()
Data = models.Data([1, 1, 1], 20000, 0.01)
Data.getData()
LSTM256.fit_model(5, Data)
LSTM256.print_stats()
LSTM256.model.summary()
LSTM256_States = models.States(1100, 1000)
LSTM256_States.create_unperturbed(LSTM256, Data)
LSTM256_States.create_pertrurbed(LSTM256, Data)
print(LSTM256_States.unperturbed - LSTM256_States.perturbed)
LSTM256_lyapunov = models.Lyapunov(LSTM256_States)
LSTM256_lyapunov.plot_exponent(LSTM256_States)

LSTM_Layer = LSTM256.model.layers[0]
LSTM_Layer.weights

import matplotlib.pyplot as plt

plt.plot(np.linspace(1, 10, 20), line)
Beispiel #4
0
def parse_implementation_schedule(schedule, out, package_filename):

    out["last_updated_date"] = datetime.datetime.now()
    out["publisher_actual"] = schedule.find("metadata").find("publisher").text
    out["publisher_code_actual"] = schedule.find("metadata").find(
        "publisher").get("code")
    out["schedule_version_actual"] = schedule.find("metadata").find(
        "version").text
    out["schedule_date_actual"] = schedule.find("metadata").find("date").text

    out["publisher_original"] = schedule.find("metadata").find(
        "publisher").text
    out["publisher_code_original"] = schedule.find("metadata").find(
        "publisher").get("code")
    out["schedule_version_original"] = schedule.find("metadata").find(
        "version").text
    out["schedule_date_original"] = schedule.find("metadata").find("date").text

    sched = models.ImpSchedule(**out)
    db.session.add(sched)
    db.session.commit()

    pd = {}

    #properties come from module properties.py
    for k, v in properties.properties.items():
        try:
            pd[k] = (eval(v["data"]))
        except AttributeError:
            pass

    for k, v in pd.items():
        d = models.ImpScheduleData()
        d.publisher_id = sched.id
        d.segment = k
        d.segment_value_actual = v
        d.segment_value_original = v
        db.session.add(d)

    elements = models.Element.query.all()
    for element in elements:
        # element name is element.name
        for p in (models.Property.query.filter_by(
                parent_element=element.id).all()):
            data = models.Data()
            data.property_id = p.id
            data.impschedule_id = sched.id

            if (p.defining_attribute is not None):
                path = "/[@" + p.defining_attribute + '="' + p.defining_attribute_value + '"]'
                element_name = element.name + path
            else:
                element_name = element.name
            try:
                data.status_actual = schedule.find(element.level).find(
                    element_name).find("status").get("category")
            except AttributeError:
                pass
            try:
                data.exclusions = schedule.find(element.level).find(
                    element_name).find("exclusions").find("narrative").text
            except AttributeError:
                pass
            if (data.exclusions is None):
                data.exclusions = ""
            try:
                data.notes_actual = schedule.find(
                    element.level).find(element_name).find("notes").text
            except AttributeError:
                data.notes_actual = ""
            try:
                data.date_actual = datetime.datetime.strptime(
                    schedule.find(element.level).find(element_name).find(
                        "publication-date").text, "%Y-%m-%d")
            except AttributeError:
                pass

            data.date_recorded = datetime.datetime.now()
            db.session.add(data)

    db.session.commit()
    return "Done "
Beispiel #5
0
 def setUp(self):
     self._data_file = models.Data(filename='test_data.csv')