Sort by

recency

|

18 Discussions

|

  • + 0 comments

    Is there are method through which I can embed this on my black friday website?

  • + 0 comments

    this test is so aestethic ..done alhamdulillah

  • + 1 comment

    even after passing both test cases it is showing "try again"? Can anyone suggest what to do

  • + 0 comments

    what the consept I should know to solved this question

  • + 1 comment
    # Enter your code here. Read input from STDIN. Print output to STDOUT
    
    import sys
    import numpy as np
    from sklearn.linear_model import LogisticRegression
    from sklearn.ensemble import RandomForestClassifier
    
    data = []
    for line in sys.stdin:
        
        l = [i for i in line.split()]
        data.append(l)
        
    #print(data)
    
    num = int(data[0][0])
    param = int(data[0][1])
    q = int(data[num+1][0])
    
    #print(num,param,q)
    
    X = np.array(data[1:num])
    X_train = []
    y_train = []
    
    for i in X:
        
        X_train.append(i[2:])
        y_train.append(int(i[1]))
    l = []
    temp = []
    for j in X_train:
        l = []
        for i in j:
            
            t = i.split(":")
            l.append(float(t[1]))
        temp.append(l)
    
    X_train = np.array(temp)
    #print(X_train)
    y_train = np.array(y_train)
    X_t = np.array(data[num+2:])
    
    X_test = []
    for i in X_t:
       
        X_test.append(i[1:])
        
    temp = []
    l1 = []
    for j in X_test:
        l1 = []
        for i in j:
            
            t1 = i.split(":")
            l1.append(float(t1[1]))
        temp.append(l1)
        
    X_test = np.array(temp)
    #print(X_test)
    #print(X_train.shape,y_train.shape,X_test.shape)
    
    rfc = RandomForestClassifier()
    
    clf = rfc.fit(X_train,y_train)
    
    predict = clf.predict(X_test)
    
    for i in range(len(predict)):
        
        if predict[i]>0:
            
            print(X_t[i][0],"+1")
            
        else:
            print(X_t[i][0],"-1")