Ejemplo n.º 1
0
def main(argv):
    setPlotDesign()
    data = qry.queryDB(
        "select Date_format(First_Occurrence_Date, '%H') as 'Hour', Count(1) as 'Crime_Count' from DenverCrime where Is_Crime = 1 group by Date_format(First_Occurrence_Date, '%H');"
    )
    queryToPlot(data, "#6DA2BE", 0, "All Crimes")
    data = qry.queryDB(
        "select Date_format(First_Occurrence_Date, '%H') as 'Hour', Count(1) as 'Crime_Count' from DenverCrime where Is_Crime = 1 and Offense_Code = "
        + offense[0] + " group by Date_format(First_Occurrence_Date, '%H');")
    #plt.subplot(112)
    queryToPlot(data, "#C16F65", .3, offense[1])

    plt.legend(loc="upper center", frameon=False, fontsize=12)
    #plt.show()
    plt.savefig("CrimeHourlyBarGraphs/AllCrimes-" + offense[2] +
                "-percent.png",
                bbox_inches="tight",
                dpi=300)
Ejemplo n.º 2
0
def main(argv):
    cursor = qry.queryDB(
        "select TMax, Round(Sum(Crime_Count)/Count(1)) as CrimeCountAvg from DenverDailyCrimeWeather group by TMax"
    )
    tMaxList = []
    crimeCountAvgList = []
    for (tMax, crimeCountAvg) in cursor:
        if tMax is not None:
            tMaxList.append(float(tMax))
            crimeCountAvgList.append(int(crimeCountAvg))

    plot(tMaxList, crimeCountAvgList)
Ejemplo n.º 3
0
def main(argv):
    cursor = qry.queryDB(
        "select Geo_Lon, Geo_Lat from DenverCrime where Geo_Lat > " +
        str(minGeoLat) + " and Geo_Lat < " + str(maxGeoLat) +
        " and Geo_Lon < " + str(maxGeoLon) + " and Geo_Lon > " +
        str(minGeoLon) + " and Offense_Code = " + crime[1])
    locations = []
    for (geoLon, geoLat) in cursor:
        if geoLon is not None and geoLat is not None:
            locations.append(Location(geoLon, geoLat))

    #downloadMap()

    kMeans(locations, k, iteration)
Ejemplo n.º 4
0
db_host = '127.0.0.1'
db_user = '******'
db_pw = ''
db_name = 'infouser'

# dlf_project_id = 'fir-thesis-v1'
# dlf_session_id = 'a409931f1c2ea9842c238469417ae2ac490b36bd'

# mgDLF = mgdia.manageDLF(projectID=dlf_project_id,
#                         sessionID=dlf_session_id)

conDB = conn.connectDB(host=db_host,
                       username=db_user,
                       password=db_pw,
                       database=db_name)

qy = qr.queryDB(conDB.getConnection())

dis_data = [
    'มีอารมณ์ซึมเศร้า', 'มีอารมณ์หงุดหงิด', 'มีอารมณ์ก้าวร้าว',
    'ขาดความสนใจสิ่งรอบข้าง', 'ไม่ค่อยมีสมาธิเวลาทำสิ่งต่างๆ',
    'รู้สึกอ่อนเพลีย', 'ทำอะไรก็เชื่องช้า', '่รับประทานอาหารมากขึ้น',
    'รับประทานน้อยลง', 'นอนมากขึ้น', 'นอนน้อยลง',
    'ตำหนิตัวเองเป็นอันดับแรกถ้ามีอะไรพลาด', 'พยายามฆ่าตัวตาย'
]

print(dis_data)

for dis in dis_data:
    query = 'INSERT INTO fact_data(fact_name) VALUES (\'{}\')'.format(dis)