O’quv tanlanma bo’yicha obyektlarni tasniflash (5 ball)



Yüklə 27,54 Kb.
tarix29.11.2022
ölçüsü27,54 Kb.
#71126
timsollar


O’quv tanlanma bo’yicha obyektlarni tasniflash (5 ball)
1. IRIS
https://archive.ics.uci.edu/ml/datasets/iris
2. Wine
https://archive.ics.uci.edu/ml/datasets/wine
3. Glass (Стекло)
https://archive.ics.uci.edu/ml/datasets/glass+identification
4. Car
https://archive.ics.uci.edu/ml/datasets/car+evaluation
5. Tulipa



TR

FIO

MB

1

A'zamov Tohirmalik Ikromjon o'g'li

IRIS

2

Abdiqulov Muxiddin Maxmud o‘g‘li

IRIS

3

Axmedov Sardorjon Murodjon O'g'li

IRIS

4

Bahronov Bobur Bahodir O'g'li

IRIS

5

Beketov G‘alimjon Baurjan o‘g‘li

IRIS

6

Bosimbekov Bekzod Olimjon o'g'li

Wine

7

Erkinov Ismoiljon Isroiljon o'g'li

Wine

8

G'aniyev Asadullo Maxmud-o'g'li

Wine

9

Izzatov Abdumalikxon Qandiyor o'g'li

Wine

10

Jahonov Asilbek Tolib o'g'li

Wine

11

Jo'rayev Sardorbek Mamatmurod O'g'li

Glass

12

Maxmudov Islomjon Dilmurod O'g'li

Glass

13

Poyanov Durbek Shamil o‘g‘li

Glass

14

Qo'ziboyev Jasurbek Isomiddin o'g'li

Glass

15

Rahmonov Jabborbek Asliddin o'g'li

Glass

16

Salimov Mirzohidjon Muhammadjon o'g'li

Car

17

Sharipov Jasurbek Farhodjon o'g'li

Car

18

Sharipov Sunnatillo Jamshid o'g'li

Car

19

Sharofiddinov Shaxriyor Pahlavon O'g'li

Car

20

Sultonov Komron Olimovich

Car

21

Tilavov Yusuf Hasan O'g'li

Tulipa

22

Toshtemirov Zafar O'ktam o'g'li

Tulipa

23

Umarov Doniyor Obidjon o'g'li

Tulipa

24

Umarxonov Faxriyor Jahongir O'g'li

Tulipa

25

Xaydarov Temurbek Siddiq o'g'li

Tulipa

ZooData MB misolida amaliy masalaning bajarilishiga namuna


package zoodata;


import java.io.File;


import java.io.FileNotFoundException;
import java.io.IOException;
import java.util.Arrays;
import java.util.Scanner;
import javax.swing.JFileChooser;
import javax.swing.filechooser.FileFilter;
import javax.swing.filechooser.FileNameExtensionFilter;

public class ZooData {


String animalName;


byte hair;
byte feathers;
byte eggs;
byte milk;
byte airborne;
byte aquatic;
byte predator;
byte toothed;
byte backbone;
byte breathes;
byte venomous;
byte fins;
int legs;
byte tail;
byte domestic;
byte catsize;
byte classType;

int l;
int n;


int m;
float[] Pr = new float[8];

public ZooData() {


}

public void OpenTextFile() throws IOException {


//tt = new double[263][49];
//double[][] mas = new double[263][49];
Scanner scan = null;
String stroka = new String();

JFileChooser DB = new JFileChooser();


File Papka = new File("."); //". " "..", "/ ", "C:/../"

FileFilter ft = new FileNameExtensionFilter("Текстовые файлы", "txt");


DB.addChoosableFileFilter(ft);

DB.setCurrentDirectory(Papka);


DB.setCurrentDirectory(new File(DB.getCurrentDirectory() + "/ZooData"));
System.out.println(DB.getCurrentDirectory());
int ReturnVal = DB.showOpenDialog(null);
System.out.println(DB.getSelectedFile().getPath());
java.io.File fayl = DB.getSelectedFile();

// if (ReturnVal == javax.swing.JFileChooser.APPROVE_OPTION)


// {
// //System.out.println(fayl);
// }
try {
scan = new Scanner(new File(fayl.toString()));
} catch (FileNotFoundException e) {
}

stroka = scan.nextLine();


//System.out.println("Birinchi qator: "+qator);


int[] rezerv = new int[3];
int counter = 0;
for (String s : stroka.split(" ")) {
rezerv[counter] = Integer.parseInt(s);
counter++;
}

setL(rezerv[0]); //определено количество классов


setN(rezerv[1]); //определено количество признаков
setM(rezerv[2]); //определено количество объектов

System.out.println("Sinflar soni : " + l);


System.out.println("Belgilar soni : " + n);
System.out.println("Ob'yektlar soni : " + m);
ZooData[] animals = new ZooData[getM()];

for (int j = 0, i; j < m; j++) {


animals[j] = new ZooData();
stroka = scan.nextLine();
//if (j==0) //Proverka
// System.out.println("qator"+j+": "+qator);

String[] s = stroka.split(",");


animals[j].setAnimalName(s[0]);


animals[j].setHair(Byte.parseByte(s[1]));
animals[j].setFeathers(Byte.parseByte(s[2]));
animals[j].setEggs(Byte.parseByte(s[3]));
animals[j].setMilk(Byte.parseByte(s[4]));
animals[j].setAirborne(Byte.parseByte(s[5]));
animals[j].setAquatic(Byte.parseByte(s[6]));
animals[j].setPredator(Byte.parseByte(s[7]));
animals[j].setToothed(Byte.parseByte(s[8]));
animals[j].setBackbone(Byte.parseByte(s[9]));
animals[j].setBreathes(Byte.parseByte(s[10]));
animals[j].setVenomous(Byte.parseByte(s[11]));
animals[j].setFins(Byte.parseByte(s[12]));
animals[j].setLegs(Integer.parseInt(s[16]));
animals[j].setTail(Byte.parseByte(s[13]));
animals[j].setDomestic(Byte.parseByte(s[14]));
animals[j].setCatsize(Byte.parseByte(s[15]));
animals[j].setClassType(Byte.parseByte(s[17]));

} // for


// for (int j = 0; j < m; j++) {


//
// System.out.print(animals[j].getAnimalName() + ",");
// System.out.print(animals[j].getHair() + ",");
// System.out.print(animals[j].getFeathers() + ",");
// System.out.print(animals[j].getEggs() + ",");
// System.out.print(animals[j].getMilk() + ",");
// System.out.print(animals[j].getAirborne() + ",");
// System.out.print(animals[j].getAquatic() + ",");
// System.out.print(animals[j].getPredator() + ",");
// System.out.print(animals[j].getToothed() + ",");
// System.out.print(animals[j].getBackbone() + ",");
// System.out.print(animals[j].getBreathes() + ",");
// System.out.print(animals[j].getVenomous() + ",");
// System.out.print(animals[j].getFins() + ",");
// System.out.print(animals[j].getLegs() + ",");
// System.out.print(animals[j].getTail() + ",");
// System.out.print(animals[j].getDomestic() + ",");
// System.out.print(animals[j].getCatsize() + ",");
// System.out.print(animals[j].getClassType());
// System.out.println("");
//
// } // for
System.out.println("Obyeklarni belgilar bo'yicha yaqinligini aniqlash:");
ZooData cow = new ZooData();
cow.setAnimalName("cow");
cow.setHair(Byte.parseByte("1"));
cow.setFeathers(Byte.parseByte("0"));
cow.setEggs(Byte.parseByte("0"));
cow.setMilk(Byte.parseByte("1"));
cow.setAirborne(Byte.parseByte("0"));
cow.setAquatic(Byte.parseByte("0"));
cow.setPredator(Byte.parseByte("0"));
cow.setToothed(Byte.parseByte("1"));
cow.setBackbone(Byte.parseByte("1"));
cow.setBreathes(Byte.parseByte("1"));
cow.setVenomous(Byte.parseByte("0"));
cow.setFins(Byte.parseByte("0"));
cow.setLegs(Integer.parseInt("4"));
cow.setTail(Byte.parseByte("1"));
cow.setDomestic(Byte.parseByte("1"));
cow.setCatsize(Byte.parseByte("0"));
int P[] = new int[m];

for (int j = 0; j < m; j++) {


P[j] = 0;


if (animals[j].getHair() == cow.getHair()) {


P[j] += 1;
}
if (animals[j].getFeathers() == cow.getFeathers()) {
P[j] += 1;
}
if (animals[j].getEggs() == cow.getEggs()) {
P[j] += 1;
}
if (animals[j].getMilk() == cow.getMilk()) {
P[j] += 1;
}
if (animals[j].getAirborne() == cow.getAirborne()) {
P[j] += 1;
}
if (animals[j].getAquatic() == cow.getAquatic()) {
P[j] += 1;
}
if (animals[j].getPredator() == cow.getPredator()) {
P[j] += 1;
}
if (animals[j].getToothed() == cow.getToothed()) {
P[j] += 1;
}
if (animals[j].getBackbone() == animals[j].getBackbone()) {
P[j] += 1;
}
if (animals[j].getBreathes() == cow.getBreathes()) {
P[j] += 1;
}
if (animals[j].getVenomous() == cow.getVenomous()) {
P[j] += 1;
}
if (animals[j].getFins() == cow.getFins()) {
P[j] += 1;
}
if (animals[j].getLegs() == cow.getLegs()) {
P[j] += 1;
}
if (animals[j].getTail() == cow.getTail()) {
P[j] += 1;
}
if (animals[j].getDomestic() == cow.getDomestic()) {
P[j] += 1;
}
if (animals[j].getCatsize() == cow.getCatsize()) {
P[j] += 1;
}

//System.out.println( animals[j].animalName + " hayvonga )=" + P[j]+" belgisi yaqin.");


}
System.out.println("Определение класса нового объекта:");

int[] K = new int[l];


int g = 12;
int[] Y = new int[8];
int count[] = new int[8];
int k = 0;
for (byte u = 1; u <= 7; u++) {
count[u] = 0;
for (int j = 0; j < m; j++) {
if (animals[j].getClassType() == u) {
count[u] += 1;
if (P[j] >= g) {
Y[u] += 1;
}

}


}
Pr[u] = ((float) Y[u] / (float) count[u]) * 100;
System.out.println(u + "-sinfdagi obyektlar soni =" + count[u]);
System.out.println(u + "-sinfning " + Y[u] + " ta obyektiga yaqin");

System.out.println(u + " - klassga " + Pr + " % yaqin");


//System.out.print(u +" - klassga "+(Y[u]/count[u])*100 +" % yaqin");


// try {
// System.out.println(u +" - klassga "+((Y[u]/count[u])*100) +" % yaqin");
// } catch (ArithmeticException e) {
//System.out.println("Nolga bo'linmoqda");
}
float max = Pr[1];
byte tek =0;
for (byte u1 = 2; u1 <= 7; u1++) {
if (max < Pr[u1]) {
max = Pr[u1];
tek = u1;
}
}
for (byte u1 = 1; u1 <= 7; u1++) {
if(u1!=tek)
if (max == Pr[tek]) {
System.out.println("Объект " + u + " - klassga " + Pr + " % yaqin");
}
}

} //end of OpenTextFile()


public static void main(String[] args) {


try {
(new ZooData()).OpenTextFile();

} catch (IOException ex) {


}
}

public String getAnimalName() {
return animalName;
}

public byte getHair() {


return hair;
}

public byte getFeathers() {


return feathers;
}

public byte getEggs() {


return eggs;
}

public byte getMilk() {


return milk;
}

public byte getAirborne() {


return airborne;
}

public byte getAquatic() {


return aquatic;
}

public byte getPredator() {


return predator;
}

public byte getToothed() {


return toothed;
}

public byte getBackbone() {


return backbone;
}

public byte getBreathes() {


return breathes;
}

public byte getVenomous() {


return venomous;
}

public byte getFins() {


return fins;
}

public int getLegs() {


return legs;
}

public byte getTail() {


return tail;
}

public byte getDomestic() {


return domestic;
}

public byte getCatsize() {


return catsize;
}

public byte getClassType() {


return classType;
}

public int getL() {


return l;
}

public int getN() {


return n;
}

public int getM() {


return m;
}

public void setAnimalName(String animalName) {


this.animalName = animalName;
}

public void setHair(byte hair) {


this.hair = hair;
}

public void setFeathers(byte feathers) {


this.feathers = feathers;
}

public void setEggs(byte eggs) {


this.eggs = eggs;
}

public void setMilk(byte milk) {


this.milk = milk;
}

public void setAirborne(byte airborne) {


this.airborne = airborne;
}

public void setAquatic(byte aquatic) {


this.aquatic = aquatic;
}

public void setPredator(byte predator) {


this.predator = predator;
}

public void setToothed(byte toothed) {


this.toothed = toothed;
}

public void setBackbone(byte backbone) {


this.backbone = backbone;
}

public void setBreathes(byte breathes) {


this.breathes = breathes;
}

public void setVenomous(byte venomous) {


this.venomous = venomous;
}

public void setFins(byte fins) {


this.fins = fins;
}

public void setLegs(int legs) {


this.legs = legs;
}

public void setTail(byte tail) {


this.tail = tail;
}

public void setDomestic(byte domestic) {


this.domestic = domestic;
}

public void setCatsize(byte catsize) {


this.catsize = catsize;
}

public void setClassType(byte classType) {


this.classType = classType;
}

public void setL(int l) {


this.l = l;
}

public void setN(int n) {


this.n = n;
}

public void setM(int m) {


this.m = m;
}
}
Yüklə 27,54 Kb.

Dostları ilə paylaş:




Verilənlər bazası müəlliflik hüququ ilə müdafiə olunur ©azkurs.org 2024
rəhbərliyinə müraciət

gir | qeydiyyatdan keç
    Ana səhifə


yükləyin