Spaces:
Running
Running
Upload 4 files
Browse files
Procfile
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
web: python app.py
|
app.py
ADDED
|
@@ -0,0 +1,84 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#!/usr/bin/env python
|
| 2 |
+
# coding: utf-8
|
| 3 |
+
|
| 4 |
+
# In[1]:
|
| 5 |
+
|
| 6 |
+
|
| 7 |
+
import pandas as pd
|
| 8 |
+
import numpy as np
|
| 9 |
+
|
| 10 |
+
# Örnek veri seti oluşturma
|
| 11 |
+
np.random.seed(42) # Tekrarlanabilir sonuçlar için
|
| 12 |
+
|
| 13 |
+
# Özellikler ve etiketler oluşturma
|
| 14 |
+
data = pd.DataFrame({
|
| 15 |
+
'feature1': np.random.rand(100),
|
| 16 |
+
'feature2': np.random.rand(100),
|
| 17 |
+
'target': np.random.randint(0, 2, 100)
|
| 18 |
+
})
|
| 19 |
+
|
| 20 |
+
# Veri setini kaydetme
|
| 21 |
+
data.to_csv('data.csv', index=False)
|
| 22 |
+
print("Örnek veri seti 'data.csv' dosyasına kaydedildi.")
|
| 23 |
+
|
| 24 |
+
|
| 25 |
+
# In[2]:
|
| 26 |
+
|
| 27 |
+
|
| 28 |
+
from sklearn.ensemble import RandomForestClassifier
|
| 29 |
+
import pickle
|
| 30 |
+
import numpy as np
|
| 31 |
+
import pandas as pd
|
| 32 |
+
|
| 33 |
+
# Örnek veri seti ve model eğitimi
|
| 34 |
+
data = pd.read_csv('data.csv')
|
| 35 |
+
X = data.drop('target', axis=1)
|
| 36 |
+
y = data['target']
|
| 37 |
+
|
| 38 |
+
model = RandomForestClassifier()
|
| 39 |
+
model.fit(X, y)
|
| 40 |
+
|
| 41 |
+
# Modeli kaydedin
|
| 42 |
+
with open('static/model/ai_model.pkl', 'wb') as file:
|
| 43 |
+
pickle.dump(model, file)
|
| 44 |
+
|
| 45 |
+
|
| 46 |
+
# In[3]:
|
| 47 |
+
|
| 48 |
+
|
| 49 |
+
from flask import Flask, render_template, request, jsonify
|
| 50 |
+
import pickle
|
| 51 |
+
import numpy as np
|
| 52 |
+
import pandas as pd
|
| 53 |
+
|
| 54 |
+
app = Flask(__name__)
|
| 55 |
+
|
| 56 |
+
# Yapay zeka modelini yükleyin
|
| 57 |
+
with open('static/model/ai_model.pkl', 'rb') as file:
|
| 58 |
+
ai_model = pickle.load(file)
|
| 59 |
+
|
| 60 |
+
@app.route('/')
|
| 61 |
+
def index():
|
| 62 |
+
return render_template('index.html')
|
| 63 |
+
|
| 64 |
+
@app.route('/simulate', methods=['POST'])
|
| 65 |
+
def simulate():
|
| 66 |
+
user_input = request.json
|
| 67 |
+
# Yapay zeka modelini kullanarak tahmin yapın
|
| 68 |
+
features = np.array([user_input['data']]).reshape(1, -1)
|
| 69 |
+
prediction = ai_model.predict(features)[0]
|
| 70 |
+
return jsonify({'prediction': prediction})
|
| 71 |
+
|
| 72 |
+
@app.route('/result')
|
| 73 |
+
def result():
|
| 74 |
+
return render_template('result.html')
|
| 75 |
+
|
| 76 |
+
if __name__ == '__main__':
|
| 77 |
+
app.run(debug=True)
|
| 78 |
+
|
| 79 |
+
|
| 80 |
+
# In[ ]:
|
| 81 |
+
|
| 82 |
+
|
| 83 |
+
|
| 84 |
+
|
data.csv
ADDED
|
@@ -0,0 +1,101 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
feature1,feature2,target
|
| 2 |
+
0.3745401188473625,0.03142918568673425,1
|
| 3 |
+
0.9507143064099162,0.6364104112637804,1
|
| 4 |
+
0.7319939418114051,0.3143559810763267,0
|
| 5 |
+
0.5986584841970366,0.5085706911647028,0
|
| 6 |
+
0.15601864044243652,0.907566473926093,1
|
| 7 |
+
0.15599452033620265,0.24929222914887494,1
|
| 8 |
+
0.05808361216819946,0.41038292303562973,1
|
| 9 |
+
0.8661761457749352,0.7555511385430487,1
|
| 10 |
+
0.6011150117432088,0.22879816549162246,1
|
| 11 |
+
0.7080725777960455,0.07697990982879299,1
|
| 12 |
+
0.020584494295802447,0.289751452913768,0
|
| 13 |
+
0.9699098521619943,0.16122128725400442,1
|
| 14 |
+
0.8324426408004217,0.9296976523425731,1
|
| 15 |
+
0.21233911067827616,0.808120379564417,0
|
| 16 |
+
0.18182496720710062,0.6334037565104235,0
|
| 17 |
+
0.18340450985343382,0.8714605901877177,0
|
| 18 |
+
0.3042422429595377,0.8036720768991145,0
|
| 19 |
+
0.5247564316322378,0.18657005888603584,1
|
| 20 |
+
0.43194501864211576,0.8925589984899778,1
|
| 21 |
+
0.2912291401980419,0.5393422419156507,1
|
| 22 |
+
0.6118528947223795,0.8074401551640625,1
|
| 23 |
+
0.13949386065204183,0.8960912999234932,1
|
| 24 |
+
0.29214464853521815,0.3180034749718639,1
|
| 25 |
+
0.3663618432936917,0.11005192452767676,0
|
| 26 |
+
0.45606998421703593,0.22793516254194168,1
|
| 27 |
+
0.7851759613930136,0.4271077886262563,0
|
| 28 |
+
0.19967378215835974,0.8180147659224931,0
|
| 29 |
+
0.5142344384136116,0.8607305832563434,1
|
| 30 |
+
0.5924145688620425,0.006952130531190703,0
|
| 31 |
+
0.046450412719997725,0.5107473025775657,1
|
| 32 |
+
0.6075448519014384,0.417411003148779,0
|
| 33 |
+
0.17052412368729153,0.22210781047073025,1
|
| 34 |
+
0.06505159298527952,0.1198653673336828,0
|
| 35 |
+
0.9488855372533332,0.33761517140362796,1
|
| 36 |
+
0.9656320330745594,0.9429097039125192,1
|
| 37 |
+
0.8083973481164611,0.32320293202075523,1
|
| 38 |
+
0.3046137691733707,0.5187906217433661,1
|
| 39 |
+
0.09767211400638387,0.7030189588951778,1
|
| 40 |
+
0.6842330265121569,0.363629602379294,0
|
| 41 |
+
0.4401524937396013,0.9717820827209607,0
|
| 42 |
+
0.12203823484477883,0.9624472949421112,0
|
| 43 |
+
0.4951769101112702,0.25178229582536416,1
|
| 44 |
+
0.034388521115218396,0.49724850589238545,0
|
| 45 |
+
0.9093204020787821,0.30087830981676966,1
|
| 46 |
+
0.2587799816000169,0.2848404943774676,1
|
| 47 |
+
0.662522284353982,0.036886947354532795,0
|
| 48 |
+
0.31171107608941095,0.6095643339798968,0
|
| 49 |
+
0.5200680211778108,0.5026790232288615,1
|
| 50 |
+
0.5467102793432796,0.05147875124998935,0
|
| 51 |
+
0.18485445552552704,0.27864646423661144,1
|
| 52 |
+
0.9695846277645586,0.9082658859666537,1
|
| 53 |
+
0.7751328233611146,0.23956189066697242,1
|
| 54 |
+
0.9394989415641891,0.1448948720912231,1
|
| 55 |
+
0.8948273504276488,0.489452760277563,1
|
| 56 |
+
0.5978999788110851,0.9856504541106007,0
|
| 57 |
+
0.9218742350231168,0.2420552715115004,0
|
| 58 |
+
0.0884925020519195,0.6721355474058786,1
|
| 59 |
+
0.1959828624191452,0.7616196153287176,1
|
| 60 |
+
0.045227288910538066,0.23763754399239967,0
|
| 61 |
+
0.32533033076326434,0.7282163486118596,0
|
| 62 |
+
0.388677289689482,0.3677831327192532,1
|
| 63 |
+
0.2713490317738959,0.6323058305935795,0
|
| 64 |
+
0.8287375091519293,0.6335297107608947,1
|
| 65 |
+
0.3567533266935893,0.5357746840747585,0
|
| 66 |
+
0.28093450968738076,0.0902897700544083,1
|
| 67 |
+
0.5426960831582485,0.835302495589238,0
|
| 68 |
+
0.14092422497476265,0.32078006497173583,1
|
| 69 |
+
0.8021969807540397,0.18651851039985423,0
|
| 70 |
+
0.07455064367977082,0.040775141554763916,0
|
| 71 |
+
0.9868869366005173,0.5908929431882418,1
|
| 72 |
+
0.7722447692966574,0.6775643618422824,0
|
| 73 |
+
0.1987156815341724,0.016587828927856152,1
|
| 74 |
+
0.005522117123602399,0.512093058299281,0
|
| 75 |
+
0.8154614284548342,0.22649577519793795,1
|
| 76 |
+
0.7068573438476171,0.6451727904094499,0
|
| 77 |
+
0.7290071680409873,0.17436642900499144,1
|
| 78 |
+
0.7712703466859457,0.690937738102466,0
|
| 79 |
+
0.07404465173409036,0.3867353463005374,1
|
| 80 |
+
0.3584657285442726,0.9367299887367345,0
|
| 81 |
+
0.11586905952512971,0.13752094414599325,1
|
| 82 |
+
0.8631034258755935,0.3410663510502585,1
|
| 83 |
+
0.6232981268275579,0.11347352124058907,1
|
| 84 |
+
0.3308980248526492,0.9246936182785628,0
|
| 85 |
+
0.06355835028602363,0.877339353380981,1
|
| 86 |
+
0.3109823217156622,0.2579416277151556,0
|
| 87 |
+
0.32518332202674705,0.659984046034179,1
|
| 88 |
+
0.7296061783380641,0.8172222002012158,0
|
| 89 |
+
0.6375574713552131,0.5552008115994623,1
|
| 90 |
+
0.8872127425763265,0.5296505783560065,0
|
| 91 |
+
0.4722149251619493,0.24185229090045168,0
|
| 92 |
+
0.1195942459383017,0.09310276780589921,1
|
| 93 |
+
0.713244787222995,0.8972157579533268,0
|
| 94 |
+
0.7607850486168974,0.9004180571633305,0
|
| 95 |
+
0.5612771975694962,0.6331014572732679,1
|
| 96 |
+
0.770967179954561,0.3390297910487007,0
|
| 97 |
+
0.49379559636439074,0.3492095746126609,0
|
| 98 |
+
0.5227328293819941,0.7259556788702394,0
|
| 99 |
+
0.42754101835854963,0.8971102599525771,1
|
| 100 |
+
0.02541912674409519,0.8870864242651173,0
|
| 101 |
+
0.10789142699330445,0.7798755458576239,1
|
requirements.txt
ADDED
|
@@ -0,0 +1,4 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
Flask==2.0.3
|
| 2 |
+
scikit-learn==1.0.2
|
| 3 |
+
pandas==1.3.3
|
| 4 |
+
numpy==1.21.2
|