Zaktualizuj 'RaportSzymonParafiński.md'
This commit is contained in:
parent
eccc3b22f5
commit
f71fee9980
@ -111,6 +111,8 @@ void stanPola(int x, int y) {
|
|||||||
//[x][x][0] = 3 - środek i nawóz
|
//[x][x][0] = 3 - środek i nawóz
|
||||||
//[x][x][1] - wartość wzrostu rośliny
|
//[x][x][1] - wartość wzrostu rośliny
|
||||||
|
|
||||||
|
polecenie = "python pliki/injectCode.py 1 ";
|
||||||
|
|
||||||
if (stan[x][y][0] == 0)
|
if (stan[x][y][0] == 0)
|
||||||
polecenie.append("0 0 ");
|
polecenie.append("0 0 ");
|
||||||
if (stan[x][y][0] == 1)
|
if (stan[x][y][0] == 1)
|
||||||
@ -122,6 +124,8 @@ void stanPola(int x, int y) {
|
|||||||
int w = (stan[x][y][1]);
|
int w = (stan[x][y][1]);
|
||||||
std::string s = std::to_string(w);
|
std::string s = std::to_string(w);
|
||||||
polecenie.append(s);
|
polecenie.append(s);
|
||||||
|
|
||||||
|
decisionTree(polecenie);
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
@ -134,6 +138,21 @@ void decisionTree(string polecenie) {
|
|||||||
std::string str = polecenie;
|
std::string str = polecenie;
|
||||||
const char* c = str.c_str();
|
const char* c = str.c_str();
|
||||||
system(c);
|
system(c);
|
||||||
|
|
||||||
|
int line = 0;
|
||||||
|
ifstream inFile;
|
||||||
|
inFile.open("pliki/dec.txt");
|
||||||
|
if (!inFile) {
|
||||||
|
cout << "Unable to open file";
|
||||||
|
exit(1); // terminate with error
|
||||||
|
}
|
||||||
|
|
||||||
|
while (inFile >> line) {
|
||||||
|
decyzja = line;
|
||||||
|
}
|
||||||
|
|
||||||
|
inFile.close();
|
||||||
|
akcja();
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
#### injectCode(): [python]
|
#### injectCode(): [python]
|
||||||
@ -144,10 +163,16 @@ import sys
|
|||||||
|
|
||||||
|
|
||||||
def prediction(warzywo, nawoz ,srodek, stan_wzrostu):
|
def prediction(warzywo, nawoz ,srodek, stan_wzrostu):
|
||||||
filename = 'decisionTree.sav'
|
filename = 'pliki/decisionTree.sav'
|
||||||
tree = pickle.load(open(filename, 'rb'))
|
tree = pickle.load(open(filename, 'rb'))
|
||||||
val = (tree.predict([[warzywo, nawoz, srodek, stan_wzrostu]]))
|
val = (tree.predict([[warzywo, nawoz, srodek, stan_wzrostu]]))
|
||||||
print(decision(val))
|
save(val)
|
||||||
|
|
||||||
|
def save(prediction):
|
||||||
|
pred = str(prediction)
|
||||||
|
plik = open('pliki/dec.txt', 'w')
|
||||||
|
plik.write(pred[1])
|
||||||
|
plik.close()
|
||||||
|
|
||||||
def decision(prediction):
|
def decision(prediction):
|
||||||
if prediction == 0:
|
if prediction == 0:
|
||||||
@ -173,7 +198,6 @@ python injectCode.py a b c d
|
|||||||
```
|
```
|
||||||
Gdzie:
|
Gdzie:
|
||||||
* a -> rodzaj warzywa
|
* a -> rodzaj warzywa
|
||||||
* 1: "burak"
|
|
||||||
* b -> czy roślina była nawożona
|
* b -> czy roślina była nawożona
|
||||||
* 0: "nie"
|
* 0: "nie"
|
||||||
* 1: "tak"
|
* 1: "tak"
|
||||||
|
Loading…
Reference in New Issue
Block a user