Esempio n. 1
0
def post():
    title = u"Train"
    if request.method == 'POST':
        mongo_server_ip = request.form['mongo_server_ip']
        mongo_server_port = request.form['mongo_server_port']
        jubatus_server_ip = request.form['jubatus_server_ip']
        jubatus_server_port = request.form['jubatus_server_port']
        db_name = request.form['db_name']
        collection_name = request.form['collection_name']
        # POSTで得られる値はstr型なのでintに変換する
        jubatus_server_port = int(jubatus_server_port)
        mongo_server_port = int(mongo_server_port)

        # jubaclassifierのtrainの実行および表示
        client = jubatus.Classifier(jubatus_server_ip, jubatus_server_port,
                                    name)
        lux_classifier = LuxClassifier()
        result_list = lux_classifier.train(client, mongo_server_ip,
                                           mongo_server_port, db_name,
                                           collection_name)

        # データフレームの取得
        convert_mongo = convertMongo()
        train_sensors_dic = convert_mongo.getTrainSensorsDic(
            mongo_server_ip, mongo_server_port, db_name, collection_name)
        data_frame = convert_mongo.getTable(train_sensors_dic)
        # とりあえずターミナル上に表示
        print data_frame

        return render_template('index.html',
                               title=title,
                               jubatus_server_ip=jubatus_server_ip,
                               jubatus_server_port=jubatus_server_port,
                               mongo_server_ip=mongo_server_ip,
                               mongo_server_port=mongo_server_port,
                               result_list=result_list)
    else:
        # エラーなどでリダイレクトしたい場合はこんな感じで
        print train_sensor_data
        return redirect(url_for('hello'))
Esempio n. 2
0
def post():
    title = u"Train"
    if request.method == 'POST':
        mongo_server_ip     = request.form['mongo_server_ip']
        mongo_server_port   = request.form['mongo_server_port']
        jubatus_server_ip   = request.form['jubatus_server_ip']
        jubatus_server_port = request.form['jubatus_server_port']
        db_name             = request.form['db_name']
        collection_name     = request.form['collection_name']
        # POSTで得られる値はstr型なのでintに変換する
        jubatus_server_port = int(jubatus_server_port)
        mongo_server_port   = int(mongo_server_port)
        
        # jubaclassifierのtrainの実行および表示
        client = jubatus.Classifier(jubatus_server_ip, jubatus_server_port, name)
        lux_classifier = LuxClassifier()
        result_list = lux_classifier.train(client, mongo_server_ip, mongo_server_port, db_name, collection_name)

        # データフレームの取得
        convert_mongo     = convertMongo()
        train_sensors_dic = convert_mongo.getTrainSensorsDic(mongo_server_ip,
                                                             mongo_server_port,
                                                             db_name,
                                                             collection_name)
        data_frame = convert_mongo.getTable(train_sensors_dic)
        # とりあえずターミナル上に表示
        print data_frame

        return render_template('index.html',
                               title               = title,
                               jubatus_server_ip   = jubatus_server_ip,
                               jubatus_server_port = jubatus_server_port,
                               mongo_server_ip     = mongo_server_ip,
                               mongo_server_port   = mongo_server_port,
                               result_list         = result_list)
    else:
        # エラーなどでリダイレクトしたい場合はこんな感じで
        print train_sensor_data
        return redirect(url_for('hello'))
Esempio n. 3
0
#!/usr/bin/env python
# coding: utf-8

import jubatus
from lux_classifier import LuxClassifier

# host = '192.168.33.10'
host = '127.0.0.1'
port = 9199
name = 'test2'

client = jubatus.Classifier(host, port, name)
lux_classifier = LuxClassifier()
lux_classifier.predict(client)
Esempio n. 4
0
#!/usr/bin/env python
# -*- coding: utf-8 -*-

from requests_oauthlib import OAuth1Session
from lux_classifier import LuxClassifier
import jubatus

CK = "a71iiYuMoJrhSSZBQBWF5bDVm"
CS = 'bhKEUnaccqA75t9JWjHJ6A7E76RlU4ce1N23p8Y61muh8NvF2k' 
AT = '2587234754-SBW9JesNhQEOPlsrqwSpt3YlhwYCliMDfyAbvPU' 
AS = 'ntqzPEeLlvXsG14KCEkdxeGLSKRKIVrQT3dg3E9rA7njj'      

client = jubatus.Classifier('127.0.0.1', 9199, 'tweet')
lux_classifier = LuxClassifier()

# ツイート投稿用のURL
url = "https://api.twitter.com/1.1/statuses/update.json"

# ツイート本文
while True :
    result_dictionary = lux_classifier.predict(client)
    print result_dictionary['Value']
    previous_params = ""
    if previous_result != result :
        if result == "True":
            params = {"status": u"いるよ"}
        else :
            params = {"status": u"いないよ"}
        previous_result = result 

Esempio n. 5
0
#!/usr/bin/env python
# -*- coding: utf-8 -*-

from requests_oauthlib import OAuth1Session
from lux_classifier import LuxClassifier
import jubatus

CK = "a71iiYuMoJrhSSZBQBWF5bDVm"
CS = 'bhKEUnaccqA75t9JWjHJ6A7E76RlU4ce1N23p8Y61muh8NvF2k'
AT = '2587234754-SBW9JesNhQEOPlsrqwSpt3YlhwYCliMDfyAbvPU'
AS = 'ntqzPEeLlvXsG14KCEkdxeGLSKRKIVrQT3dg3E9rA7njj'

client = jubatus.Classifier('127.0.0.1', 9199, 'tweet')
lux_classifier = LuxClassifier()

# ツイート投稿用のURL
url = "https://api.twitter.com/1.1/statuses/update.json"

# ツイート本文
while True:
    result_dictionary = lux_classifier.predict(client)
    print result_dictionary['Value']
    previous_params = ""
    if previous_result != result:
        if result == "True":
            params = {"status": u"いるよ"}
        else:
            params = {"status": u"いないよ"}
        previous_result = result

# OAuth認証で POST method で投稿
Esempio n. 6
0
    "consumer_key": "a71iiYuMoJrhSSZBQBWF5bDVm",
    "consumer_secret": "bhKEUnaccqA75t9JWjHJ6A7E76RlU4ce1N23p8Y61muh8NvF2k",
    "access_token": "2587234754-SBW9JesNhQEOPlsrqwSpt3YlhwYCliMDfyAbvPU",
    "access_token_secret": "ntqzPEeLlvXsG14KCEkdxeGLSKRKIVrQT3dg3E9rA7njj"
}

CK = oath_key_dict["consumer_key"]
CS = oath_key_dict["consumer_secret"]
AT = oath_key_dict["access_token"]
AS = oath_key_dict["access_token_secret"]

# ツイート投稿用のURL
url = "https://api.twitter.com/1.1/statuses/update.json"

# ツイート本文
lux_classifier = LuxClassifier()
result = lux_classifier.predict(client)
print result

if (result != previous_result):
    if (result == 'True'):
        params = {
            "status": u"明るいよ " + datetime.now().strftime("%Y/%m/%d %H:%M:%S")
        }
    else:
        params = {
            "status": u"暗いよ   " + datetime.now().strftime("%Y/%m/%d %H:%M:%S")
        }
    previous_result = result

# OAuth認証で POST method で投稿
Esempio n. 7
0
        "consumer_key"       : "a71iiYuMoJrhSSZBQBWF5bDVm",
        "consumer_secret"    : "bhKEUnaccqA75t9JWjHJ6A7E76RlU4ce1N23p8Y61muh8NvF2k",
        "access_token"       : "2587234754-SBW9JesNhQEOPlsrqwSpt3YlhwYCliMDfyAbvPU",
        "access_token_secret": "ntqzPEeLlvXsG14KCEkdxeGLSKRKIVrQT3dg3E9rA7njj"
        }

CK = oath_key_dict["consumer_key"]
CS = oath_key_dict["consumer_secret"]
AT = oath_key_dict["access_token"]
AS = oath_key_dict["access_token_secret"]

# ツイート投稿用のURL
url = "https://api.twitter.com/1.1/statuses/update.json"

# ツイート本文
lux_classifier = LuxClassifier()
result         = lux_classifier.predict(client)
print result

if(result != previous_result):
    if (result == 'True'):
        params = {"status": u"明るいよ " + datetime.now().strftime("%Y/%m/%d %H:%M:%S")}
    else :
        params = {"status": u"暗いよ   " + datetime.now().strftime("%Y/%m/%d %H:%M:%S")}
    previous_result = result

# OAuth認証で POST method で投稿
twitter = OAuth1Session(CK, CS, AT, AS)
req = twitter.post(url, params = params)

# レスポンスを確認
Esempio n. 8
0
#!/usr/bin/env python
# coding: utf-8
import jubatus
from lux_classifier import LuxClassifier

# host = '192.168.33.10'
host = '127.0.0.1'
port = 9199
name = 'test2'

client = jubatus.Classifier(host, port, name)
lux_classifier = LuxClassifier()
lux_classifier.train(client)