Python Forum
Classification of Request
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Classification of Request
#1
Python: How to categorize the request in different categories for example in 3 categories based on any 3 ex. aa, bb, cc (any):, using KMeans or any other classification technique, I need just categories. help will be highly appreciated. thanks in advance! Smile

import random


class Req():
    def __init__(self,reqNum,node_num):
        self.reqNum = reqNum
        self.location = random.randint(0,node_num//10)
        self.firewall_demand = random.randint(300,600)
        self.storage_demand = random.randint(100,300)
        self.bandwidth_demand = random.randint(200,500)
        self.fw_dm = random.randint(200,400)
        self.st_dm = random.randint(150,350)
        self.bw_dm = random.randint(250,550)

def createSetOfRequest(req_num, node_num):
    sr = []
    for i in range(0, req_num):
        sr.append(Req(i, node_num))
    return sr
# (i have to categorise in 3 category, scenario will be like that you can change accordingly, this is just for example)
ns = createSetOfRequest(20,200)
for i in range(0,20):
    print(sr[i].reqNum,sr[i].firewall_demand ,sr[i].firewall_demand ,sr[i].bandwidth_demand)
Reply
#2
I do not understand what you are trying to achieve or what error you are facing.

But the sr variable (bad name by the way) it is defined within the function createSetOfRequest so it will not be reachable from the for loop that you have at the end. You should work with ns.
Reply
#3
sir thanks for your reply, let me more precise, I just need three different categories on the basis of any mentioned parameters using any method of classification. for example KMeans or any other classification method, I want to use these categories in my coding, like in the beginning first category then second and then third.

import random
 
 
class Req():
    def __init__(self,reqNum,node_num):
        self.reqNum = reqNum
        self.location = random.randint(0,node_num//10)
        self.firewall_demand = random.randint(300,600)
        self.storage_demand = random.randint(100,300)
        self.bandwidth_demand = random.randint(200,500)
        self.fw_dm = random.randint(200,400)
        self.st_dm = random.randint(150,350)
        self.bw_dm = random.randint(250,550)
Reply
#4
I'm unclear on whether this is a Python question, or a data science question in which you happen to be using Python. Your question may be more appropriate in a data-science dedicated forum (and I don't mean our subforum, since regulars who look there would likely have seen this).
Reply
#5
"""Python: How to categorize the request in different categories for example in 3 categories based on any 3 parameters, aa, bb, cc (any):, using KMeans or any other classification technique, I need just categories. help will be highly appreciated. thanks in advance"""

import random

class Request:
def init(self,reqNum,nodenum): 
self.reqNum = reqNum 
self.firewalldemand = random.randint(300,600)
self.storagedemand = random.randint(100,300) 
self.bandwidthdemand = random.randint(200,500)

def createRequest(reqnum, nodenum):
req = []
for i in range(0, reqnum): req.append(Request(i, nodenum))
return req 
Reply
#6
(Nov-25-2019, 09:03 PM)micseydel Wrote: I'm unclear on whether this is a Python question, or a data science question in which you happen to be using Python. Your question may be more appropriate in a data-science dedicated forum (and I don't mean our subforum, since regulars who look there would likely have seen this).

thanks a lot, I already posted there
Reply
#7
what happened to your indentation?
Reply
#8
(Dec-09-2019, 04:06 AM)PythonLearner703 Wrote: thanks a lot, I already posted there
I merged the two threads.
Also I think you misread this part of @micseydel's suggestion: and I don't mean our subforum
If you can't explain it to a six year old, you don't understand it yourself, Albert Einstein
How to Ask Questions The Smart Way: link and another link
Create MCV example
Debug small programs

Reply
#9
(Dec-09-2019, 11:24 AM)buran Wrote: Also I think you misread this part of @micseydel's suggestion: and I don't mean our subforum
To clarify, if anyone can answer here then great, I just expect that if it was going to get answered here, it already would have been
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
Sad Miss-Classification problem with shuffled batch Faebs94 0 1,556 Sep-02-2021, 11:55 AM
Last Post: Faebs94
  Probabilities of binary classification problem Troublesome1996 0 2,421 Apr-19-2021, 06:40 PM
Last Post: Troublesome1996
  GridSearchCV for multi-label classification mapypy 0 3,697 Mar-29-2021, 01:58 AM
Last Post: mapypy
  GNN For Graph "Classification" BennyS 1 1,783 Feb-09-2021, 12:09 PM
Last Post: BennyS
  Help with multiclass classification in perceptron code Nimo_47 0 3,738 Nov-09-2020, 10:32 PM
Last Post: Nimo_47
  Classification and Regression tree (CART) kumarants 2 2,724 May-26-2020, 11:04 AM
Last Post: Larz60+
  CNN Speech Classification Mitchie87 0 1,614 Dec-06-2019, 06:17 PM
Last Post: Mitchie87
  Keras: Time series classification midarq 0 1,995 Sep-25-2019, 09:03 AM
Last Post: midarq
  Classification with shuffling PythonNewbie 1 2,429 Nov-12-2017, 10:23 AM
Last Post: PythonNewbie

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020